我有一个兴都库什喜马拉雅地区的shapefile,可以在http://rds.icimod.org/Home/DataDetail?metadataId=3924中找到,我还有尼泊尔的long,它取自这个网站(http://rds.icimod.org/Home/DataDetail?metadataId=19590&searchlist=True)。
尼泊尔的地理范围是地理范围东部: 88.19456,地理范围西部:80.0522,地理范围北部:30.42472,地理范围南部: 26.36836
现在,我正在尝试从兴都库什喜马拉雅shapefile中提取尼泊尔的子集。这是我的代码:
mountains<-readOGR("outline.shp") #hindukushhimalayanshapefile
sub <- crop(mountains, extent( 80.0522, 88.18456, 26.36836, 30.42472))
plot(sub)但情节潜艇(即尼泊尔)没有正确地显示与适当的轮廓。在顶部有直线显示。我怎样才能得到尼泊尔的一个正确的子集和正确的轮廓。我把范围弄错了吗?如果能帮上忙,我们将不胜感激

发布于 2019-10-16 08:52:46
您不能从该shapefile设置国家边界的子集,因为它不包含有关国家边界的信息。您必须使用这样的shapefile,它包含有关国家边界的信息:http://rds.icimod.org/Home/DataDetail?metadataId=1218,或使用单独的尼泊尔边界shapefile而不是范围的子集:
require(maptools)
require(rgdal)
hkh_shp=readOGR("/Downloads/data/outline.shp")
data(wrld_simpl) ##this shapefile is quite coarse, you could substitute another one
nepal_shp=wrld_simpl[which(wrld_simpl$NAME=="Nepal"),]
##CRS are similar but not identical, so need to transform
nepal_shp=spTransform(nepal_shp,crs(hkh_shp))
plot(hkh_shp)
lines(nepal_shp,col="red")

##crop
hkh_sub_shp=crop(hkh_shp,nepal_shp)
plot(hkh_sub_shp) ##note, will look better with higher resolution shapefile

https://stackoverflow.com/questions/58361337
复制相似问题