【发布时间】:2019-04-03 18:36:55
【问题描述】:
我想使用 Google 地球引擎来提取某些国家/地区的数据。我需要方形网格形式的数据,所以我想为某个国家创建这些方形网格,将它们添加到 shapefile,然后将 shapefile 导入地球引擎。我已经找到了一些创建方形网格的代码 (Create a grid inside a shapefile),但现在我遇到了两个问题。
首先,我需要导出方形网格,以便将它们导入地球引擎。我对 shapefile 的替代品持开放态度。
其次,后续代码适用于某些国家(如法国),但不适用于其他国家(如泰国)。
library(raster)
shp = getData(country = "FRA", level = 0)
shp = spTransform(shp, CRSobj = "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0")
plot(shp)
cs = c(10000, 10000)
grdpts = makegrid(shp, cellsize = cs)
spgrd = SpatialPoints(grdpts, proj4string = CRS(proj4string(shp)))
spgrdWithin = SpatialPixels(spgrd[shp,])
plot(spgrdWithin, add = T)
将第 2 行中的“FRA”替换为“THA”会导致 spTransform 出现错误。
【问题讨论】:
标签: r geospatial shapefile r-raster rasterizing