3

我想在 R 中的光栅文件上绘制一个 shapefile,但我不能让它们完美重叠:光栅似乎逆时针旋转了几度。投影有问题吗?

在此处输入图像描述

请考虑以下 MWE

library(raster)
library(rgdal) 

# Download from http://biogeo.ucdavis.edu/data/gadm2/shp/ITA_adm.zip
shape_file = "ITA_adm1.shp"
# Download from http://sedac.ciesin.columbia.edu/data/set/gpw-v3-population-density/data-download
# Setting Geography: Country, Italy; Data Attributes: Grid
pop_density_file ="w001001.adf"

italy_map <- readOGR(dsn = shape_file, layer = "ITA_adm1")
italy_map_dens <- raster(pop_density_file)

colPal <- colorRampPalette(c("white", "red"))( 500 )

par(mar=c(0,0,0,0))
plot(italy_map_dens, xlim = c(6.70, 18.32), ylim = c(35.2, 47.6), axes=FALSE, box=FALSE, legend=FALSE, col=colPal)
plot(italy_map, xlim = c(6.70, 18.32), ylim = c(35.2, 47.6), border="grey", add=TRUE)
4

2 回答 2

2

显然包中存在错误rgdal。在我将它更新到版本 0.8-12 后,我的问题得到了解决。

于 2013-11-21T20:42:50.807 回答
1

这似乎是投影的问题。您需要找出两个数据集的精确投影,并将其中一个数据集转换为另一个数据集的投影。

于 2013-11-21T07:44:26.623 回答