我确信这个问题已经在其他地方得到了回答,但我无法通过搜索提出这个问题。
我有代表一个国家内的城市以及每个城市的人口的点。我还有一个县的多边形文件。我想找到每个县内最大城市的位置。
如何才能做到这一点?
这是一些数据
结构(列表(国家= c(“我们”,“我们”,“我们”,“我们”,“我们”,“我们”,“我们”,“我们”,“我们”,“我们”,“我们“,
“我们”, “我们”, “我们”, “我们”, “我们”, “我们”, “我们”, “我们”, “我们”, “我们”, “我们”, “我们”, "us", "us"), City = c("cabarrus", "cox store", "cal-vel", "briarwood townhouses", "barker heights", "davie
十字路口”、“蟹点村”、“杜鹃花”、“切斯特菲尔德”、“查尔斯蒙特”、“康纳”、“三叶草花园”、“科里赫高地”、“卡利森”、“克雷斯特维尤英亩”、“克莱格”、“迦南”公园”,“尚蒂伊”,“贝尔格莱德”,“布里斯十字路口”,“虚张声势”,“巴特纳”,“底部”,“班迪”,“博斯蒂安高地”),AccentCity = c(“Cabarrus”,“Cox Store” , “Cal-Vel”, “Briarwood Townhouses”, “Barker Heights”, “Davie Crossroads”, “Crab Point Village”, “Azalea”, “Chesterfield”, “Charlesmont”, “Connor”, “Clover Garden”, “ Corriher Heights”、“Callisons”、“Crestview Acres”、“Clegg”、“Canaan Park”、“Chantilly”、“Belgrade”、“Brices Crossroads”、“Bluff”、“Butner”、“Bottom”、“Bandy”、“Bostian Heights”)、地区= c(“NC”,“NC”,“NC”,“NC”,“NC”,“NC”,“NC”,“NC”,“NC”,“NC”,“NC”,“NC” 、“NC”、“NC”、“NC”、“NC”、“NC”、“NC”、“NC”、“NC”、“NC”、“NC”、“NC”、“NC”、“ NC"), 人口 = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, A_integer_,NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_), Latitude = (35.2369444, 35.275, 36.4291667, 35.295, 35.3111111, 35.8319444, 34.7602778, 35.58, 35.81, 5.9341667, 35.7419444, 36.1883333, 35.5605556, 35.0841667, 35.0213889, 35.8655556, 36.2761111, 36.3016667, 34.88, 34.8186111, 35.8377778, 36.1319444, 36.4747222, 35.6419444, 35.7544444), Longitude = c(-80.5419444, -82.0352778, -78.9694444, -81.5238889, -82.4441667, -80.535 , -76.7305556, -82.4713889, -81.6611111, -81.5127778, -78.1486111, -79.4630556, -80.635, -76.7255556, -80.5427778, -78.8497222, -79.7852778, -76.1711111, -77.2352778, -78.1016667, -82.8580556, -78.7569444, - 80.7741667, -81.09, -80.9294444)), .Names = c("Country", "City", "AccentCity", "地区”, “人口”, “纬度”, “经度”), row.names = c(544L, 889L, 551L, 434L, 190L, 975L, 894L, 147L, 717L, 700L, 831L, 773L, 862L, 559L, 915L, 753L, 584L, 695L, 262L, 437L, 372L, 537L, 406L, 178L, 02L), 类别 = "data.frame")
以及在北卡罗来纳州阅读的一些代码
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
plot(xx)
我想找到每个县内人口最多的城市。对不起,我没有可重复的例子。如果我这样做了,我会得到答案!