简体   繁体   中英

Plotting Map in R (Track Values Falling out of a specific region)

我已经在R中绘制了一个地图,该地图对应于我拥有的经纬度值,某些经纬度值落在特定区域之外(假设印度),有没有办法知道那些经纬度值呢?

Here's an example

library(sp)
spoly = SpatialPolygons(list(Polygons(list( Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2))) ), "s1")), 1L)
spoints <- SpatialPoints(matrix(c(1:4, 2:5), ncol=2))
plot(spoly)
plot(spoints, add=T)
axis(1);axis(2)

在此处输入图片说明

(ov <- spoints %over% spoly)
#  1  2  3  4 
# NA  1  1  1 
coordinates(spoints)[is.na(ov),]
# coords.x1 coords.x2 
#         1         2 

See help("%over%") for all the variations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM