最近我研究了R,使之成为1km×1km的网格。所以,我已经做了下面的代码。但shapefile(korea, seoul and WGS84)无法准确地将(或覆盖)添加到网格中。所以我需要你的帮助来解决这个问题。
+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84+towgs84=0,0,0的CRSseoullayer_t <- spTransform(seoullayer, CRS("+init=epsg:3857")) seoullayer <- rgdal :: readOGR(dsn = 'd:/seoullayer',
layer = 'test_4326',
encoding = 'CP949')
seoullayer_t <- spTransform(seoullayer, CRS("+init=epsg:3857"))
# Define number of cells of Grid
x <- min(coordinates(seoullyaer_t)[,1]) ; x
y <- min(coordinates(seoullyaer_t)[,2]) ; y
x_cell <- 46
y_cell <- 37
cell_size <- 1000
ext <- extent(x, x + (x_cell * cell_size), y, y + (y_cell * cell_size))
ras <- raster(ext)
#Set the resolution to be
res(ras) <- c(cell_size, cell_size)
ras[] <- rnorm(ncell(ras))
projection(ras) <- CRS("+init=epsg:3857")
plot(ras)
plot(seoullayer_t, add = T)我希望使网格分辨率达到1kmx1km,并将温度、PM10密度、O3等值放到网格中。所以,最后,我想做一个“逆距离提取法”来预测那些没有实际值的值。
请帮我这样做。谢谢。
发布于 2019-07-13 16:36:59
你可以做这样的事
library(raster)
g <- getData("GADM", country="South Korea", level=1)
m <- spTransform(g, "+proj=merc +a=6378137 +b=6378137 +units=m")
r <- raster(m, res=10000)然而,您选择的坐标参考系统(mercator)并不是一个好的,因为它不是一个等面积投影。还请注意,编写"proj.4“描述要比使用EPSG代码好,因为这些代码是不透明的(您看不到相关信息)。我不知道韩国有什么好的crs,但你可以查一下。也许是合理的。
m <- spTransform(g, "+proj=utm +zone=52 +datum=WGS84")
r <- raster(floor(extent(m)), res=10000)(我计算出了整数的范围)。
https://stackoverflow.com/questions/57018154
复制相似问题