我有一个县(shape)的shapefile和一个带坐标的数据点(epoints)的.csv文件。 我可以使用plot()和points()绘制多边形上的点,并构建空间点和空间点数据帧。
我正在试图弄清楚如何根据县创建主题或等值线图来绘制数据点的频率计数(图例也)。所有点都在多边形内。
我以前做过over()只选择研究多边形中的那些点,这就是为什么你看到点数据集中变量的多余部分
代码示例如下:
county <- readOGR(".", "RichmondMSA")
epoints<- read.csv("Richmond MSA stores.csv", header=TRUE)
epoints.sp <- SpatialPoints(epoints [,c(3,4)])
epoints.spdf <- SpatialPointsDataFrame(epoints.sp, epoints, match.ID = TRUE)
plot(county, main="Stores in Richmond MSA")
points(epoints.sp, pch=20, col=26)
names(county)
[1] "STATEFP" "COUNTYFP" "COUNTYNS"
[4] "GEOID" "NAME" "NAMELSAD"
[7] "LSAD" "CLASSFP" "MTFCC"
[10] "CSAFP" "CBSAFP" "METDIVFP"
[13] "FUNCSTAT" "ALAND" "AWATER"
[16] "INTPTLAT" "INTPTLON"
> names(epoints.spdf)
[1] "FID" "Score"
[3] "X" "Y"
[5] "Match_addr" "STORE.NAME"
[7] "ADDRESS" "CITY"
[9] "STATE" "ZIP"
[17] "YELP" "county.STATEFP"
[19] "county.COUNTYFP" "county.COUNTYNS"
[21] "county.GEOID" "county.NAME"
[23] "county.NAMELSAD" "county.LSAD"
[25] "county.CLASSFP" "county.MTFCC"
[27] "county.CSAFP" "county.CBSAFP"
[29] "county.METDIVFP" "county.FUNCSTAT"
[31] "county.ALAND" "county.AWATER"
[33] "county.INTPTLAT" "county.INTPTLON"
[35] "county.Count" "tracts.STATEFP"
[37] "tracts.COUNTYFP" "tracts.TRACTCE"
[39] "tracts.GEOID" "tracts.NAME"
[41] "tracts.NAMELSAD" "tracts.MTFCC"
[43] "tracts.FUNCSTAT" "tracts.ALAND"
[45] "tracts.AWATER" "tracts.INTPTLAT"
[47] "tracts.INTPTLON" "tracts.FID_1"
[49] "tracts.STATEFP_1" "tracts.COUNTYFP_1"
[51] "tracts.COUNTYNS" "tracts.GEOID_1"
[53] "tracts.NAME_1" "tracts.NAMELSAD_1"
[55] "tracts.LSAD" "tracts.CLASSFP"
[57] "tracts.MTFCC_1" "tracts.CSAFP"
[59] "tracts.CBSAFP" "tracts.METDIVFP"
[61] "tracts.FUNCSTAT_1" "tracts.ALAND_1"
[63] "tracts.AWATER_1" "tracts.INTPTLAT_1"
[65] "tracts.INTPTLON_1"