如何从具有正确轮廓的 shapefile 中获取子集?

How to get a subset from a shapefile with the correct outline?

我有一个兴都库什喜马拉雅地区的 shapefile,可以在 http://rds.icimod.org/Home/DataDetail?metadataId=3924 , and I have lat long of Nepal that have taken from this website (http://rds.icimod.org/Home/DataDetail?metadataId=19590&searchlist=True) 中找到。

尼泊尔的地理范围是 东地理范围:88.19456,地理范围 West:80.0522,地理范围 North:30.42472,南地理范围:26.36836

现在我正在尝试从 Hindu Kush Himalayan shapefile 中提取尼泊尔的子集。这是我的代码:

mountains<-readOGR("outline.shp") #hindukushhimalayanshapefile
sub <- crop(mountains, extent( 80.0522, 88.18456, 26.36836, 30.42472))
plot(sub)

但是情节子(尼泊尔的)没有用正确的轮廓正确显示。顶部有直线显示。如何获得具有正确轮廓的尼泊尔的适当子集。我把范围错了吗?帮助将不胜感激

您不能从该 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