我確定這個問題已經在其他地方得到了解答,但是我一直沒能通過搜索來想出它。在每個多邊形中查找一組多邊形的最大點R
我有代表一個國家的城市的點數以及每個城市的人口。我也有縣的多邊形文件。我想找到每個縣內最大城市的位置。
這怎麼辦?
下面是一些數據
結構(名單(國家= C( 「我們」, 「我們」, 「我們」, 「我們」, 「我們」, 「我們」, 「我們」,「我們我們「,」我們「,」我們「,」我們「,」我們「,」我們「,」我們「,」我們「 「,」我們「,」我們「,」我們「,」我們「,」我們「),城市= c(」cabarrus「,」cox商店「,」cal- vel「,」briarwood排屋「,」barker高度「,」davie
十字路口「,」螃蟹點村「,」杜鵑花「,」切斯特菲爾德「,」查爾斯蒙特「,」康納「,」三葉草花園「,」corriher高地「,」callisons「 ,「clegg」,「canaan park」,「chantilly」,「belgrade」,「brices crossroads」,「bluff」,「butner」,「bottom」,「bandy」,「bostian heights」),AccentCity = c(「 Cabarrus「,」C牛扒店「,」Cal-Vel「,」Briarwood Townhouses「,」Barker Heights「,」Davie Crossroads「,」Crab Point Village「,」Azalea「,」Chesterfield「,」Charlesmont「,」Connor「 「,」Corriher Heights「,」Callisons「,」Crestview Acres「,」Clegg「,」Canaan Park「,」Chantilly「,」Belgrade「,」Brices Crossroads「,」Bluff「,」Butner「,」Bottom「 「Bandy」,「Bostian Heights」),Region = c(「NC」,「NC」,「NC」,「NC」,「NC」,「NC」,「NC」,「NC」 NC,NC,NC,NC,NC,NC,NC,NC,NC,NC,NC 「,」NC「,」NC「,」NC「),人口= c(NA_整體,NA整體,NA整體,NA整體,NA整體NA_整體NA_整體NA_整體NA整體NA_整體NA_整體NA整體NA整體NA_整體NA整體,NA_整體__,NA_整體__,NA_整體__,NA_整體__,整數_整數_整數_整數_整數_整數_整數_整數_整數_整數_整數n_整數_整數_整數_ 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),經度= 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, - ),.Names = c(「Country」,「City」,「AccentCity」,「Region」,「Population」,「Latitude」,「Longitude」),row.names (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),class =「data.frame」)
and some code to read in nort h carolina
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1],
IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
plot(xx)
我想找到每個縣內人口最多的城市。對不起,我沒有一個可重複的例子。如果我這樣做,我會得到答案!
如果您提供[可重現的示例](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example),它可以得到最好的解答,試圖完成 – 2014-11-22 19:37:38
發佈'dput(data)'的輸出,其中'data'是您的「某些數據」。 – jlhoward 2014-11-22 20:06:54
對不起,感謝信息。我不知道如何在這個問題中提供數據。 – Pete 2014-11-22 20:09:00