我如何使用库SP在R中像meuse.grid一样创建网格

时间:2019-11-14 10:29:32

标签: r

我想使用网格(例如meuse.grid(库sp))创建热图。

我有此代码:

# Create a data frame showing the **Latitude/Longitude**
# They are more than 5000 points (these they are only an example)
salidas <- data.frame(
  latS = datosPre$latitudS,
  longS = datosPre$longitudS,
  station = 1:4385
)

# Convert to SpatialPointsDataFrame
coordinates(salidas) <- ~ longS + latS


# Set the projection. They were latitude and longitude, so use WGS84 long-lat projection
proj4string(salidas) <- CRS("+init=epsg:4326")

#Here make a grid, but isnt run like the example.
gridS <- makegrid(salidas, cellsize = 0.01)
gridS <-
  SpatialPoints(gridS, proj4string = CRS(proj4string(salidas)))
salidas.grid <- SpatialPixelsDataFrame(salidas)

# View the station location using the mapview function
ms <- mapview(salidas)

ms

我想要这样的东西:

demo(meuse, ask = FALSE, echo = FALSE) # loads the meuse data sets
class(meuse)

mapview(meuse.grid,
        zcol = c("soil", "dist"),
        legend = TRUE)

谢谢!

0 个答案:

没有答案