【发布时间】:2022-01-12 20:56:07
【问题描述】:
我正在使用 R 中的 sf 包和 arcpullr 包从 ArcGIS REST 服务中提取数据并将其作为 sf 对象使用。我遇到了 MULTIPOLYGON 的问题,其中sf 仅缓冲 MULTIPOLYGON 的一部分(即,它缓冲一个多边形,但只缓冲另一个多边形)。在缓冲找到here 的示例时,我无法复制该问题。
这是一个 MRE(抱歉,如果没有,您必须安装 arcpullr)。
# install.packages("arcpullr")
library(arcpullr)
library(sf) # redundant since loaded with arcpullr, but here for brevity
library(ggplot2)
tax_parcel_url <- paste0(
"https://mapservices.legis.wisconsin.gov/arcgis/rest/services/",
"WLIP/Parcels/FeatureServer/0"
)
parcel <-
get_spatial_layer(tax_parcel_url, where = "PARCELID = 'HA-11'") %>%
st_transform(crs = 3071)
parcel_buffer <- st_buffer(parcel, dist = 10)
# map of parcel
ggplot(data = parcel) + geom_sf() # this is correct
# map of parcel and buffer - buffer "misses" part of multipolygon
ggplot(data = parcel_buffer) +
geom_sf(color = "blue") +
geom_sf(data = parcel, color = "red", alpha = 0.3) +
theme_bw()
【问题讨论】:
-
嗨!我只想指出,运行 get_spatial_layer 时出现“已达到超时”错误。您可以尝试重新运行代码吗?或者可能以其他方式共享对象?
-
谢谢@agila。我的运行时间为 0.41 秒。运行它时可能存在服务器问题。再试一次?