从R中的地点名称查找多边形坐标

问题描述 投票:0回答:1

我有印度德里的地点名称列表。我想要它们对应的多边形。

但是,到目前为止,我只能获取他们的纬度和经度。

这是我正在使用的代码

library(tidygeocoder)
library(dplyr)

some_addresses <- tibble::tribble(
  ~name,  "Anand Niketan", "Asian Games Village Complex", "Basalt Lok DDA Complex", "Bhikaji Cama Place")

lat_longs <- some_addresses %>%
  tidygeocoder::geocode(name, method = 'arcgis', lat = latitude , long = longitude, full_results = TRUE)

这将返回一个包含纬度、经度以及纬度和经度的最大值和最小值的数据框。

另外,虽然我知道 ArcGIS 和 Google 在纬度和经度方面会有细微差别,但使用一种方法而不是另一种方法有什么理由吗?

非常感谢您在这方面的任何帮助! :)

r arcgis ggmap google-geocoder geocode
1个回答
0
投票

感谢您的评论!根据平台上收到的帮助,我能够解决我的问题。以下是一个地点的多边形代码:

library(osmdata)
library(dplyr)
library(sf)

anand <- getbb ("Anand Niketan", format_out = "polygon")
#creates an array of the coordinates of the polygon

anand <- as.data.frame(anand)
#output is a data frame with latitude and longitude as two columns

anand_polygon <- anand %>%
  st_as_sf(coords = c("V1", "V2"), crs = 4326) %>% #converts the data frame to a spatial object
  summarise(geometry = st_combine(geometry)) %>% #combines all the coordinates to form a single geometry
  st_cast("POLYGON") #casts the geometry to a polygon

类似地,我们可以将其缩放为 n 个多边形。

谢谢你!我真的很感谢收到的帮助。:)

© www.soinside.com 2019 - 2024. All rights reserved.