3
检查点是否在多边形Shapefile中
Zillow 为美国主要城市的不同社区提供了一组shapefile。我想使用R检查某些社区中是否存在某些建筑物: library(rgeos) library(sp) library(rgdal) df <- data.frame(Latitude =c(47.591351, 47.62212,47.595152), Longitude = c(-122.332271,-122.353985,-122.331639), names = c("Safeco Field", "Key Arena", "Century Link")) coordinates(df) <- ~ Latitude + Longitude wa.map <- readOGR("ZillowNeighborhoods-WA.shp", layer="ZillowNeighborhoods-WA") sodo <- wa.map[wa.map$CITY == "Seattle" & wa.map$NAME == "Industrial District", ] 我可以毫无问题地绘图 plot(sodo) points(df$Latitude ~ df$Longitude, col = "red", …