我有以下的墨西哥地图。它展示了所有的市镇和大约400个气象站。
我希望创建一个以每个站点为中心的10公里缓冲区,并最终将每个缓冲区内的市政当局与一个站点关联起来。
地图和站点分别存储在不同的sf对象中。我尝试了以下方法:
我认为
地图和站点分别存储在不同的sf对象中。我尝试了以下方法:
buffers <- st_buffer(stations, dist = 1)
我认为
dist
参数被设置为公里,所以我尝试dist = 10
。不幸的是,这会为每个站点返回非常大的缓冲区。这就是我使用dist = 1
的原因,但即使这些缓冲区也很大,就像一个州一样!这个问题建议我将我的站点转换为Irish Grid,但我无法复制已接受的答案。我现在想知道dist
参数设置的单位是什么。
根据前面提到的问题,我假设它被设置为度数。如何在每个站周围设置10公里的缓冲区?
额外信息:
我的CRS在两个对象(墨西哥地图和车站)上都设置为4326。
这是我的stations
数据:
> dput(head(stations))
structure(list(station_number = c(1004L, 1005L, 1008L, 1012L,
1017L, 1018L), station_alt = c(1925, 1844, 2323, 1589, 2172,
2053), month = c(9L, 9L, 9L, 9L, 9L, 9L), Mean_min = c(11.6,
12.75, 12.25, 13.9666666666667, 12.9, 12.6833333333333), Mean_max = c(26.9333333333333,
26.85, 24.0833333333333, 29.0333333333333, 24.8666666666667,
26.1333333333333), months_observed = c(5L, 5L, 5L, 5L, 5L, 5L
), geometry = structure(list(structure(c(-102.199, 22.001), class = c("XY",
"POINT", "sfg")), structure(c(-102.372, 21.781), class = c("XY",
"POINT", "sfg")), structure(c(-102.135, 22.203), class = c("XY",
"POINT", "sfg")), structure(c(-102.802, 21.794), class = c("XY",
"POINT", "sfg")), structure(c(-102.444, 22.233), class = c("XY",
"POINT", "sfg")), structure(c(-102.415, 22.141), class = c("XY",
"POINT", "sfg"))), class = c("sfc_POINT", "sfc"), precision = 0, bbox = structure(c(xmin = -102.802,
ymin = 21.781, xmax = -102.135, ymax = 22.233), class = "bbox"), crs = structure(list(
epsg = NA_integer_, proj4string = NA_character_), class = "crs"), n_empty = 0L)), sf_column = "geometry", agr = structure(c(station_number = NA_integer_,
station_alt = NA_integer_, month = NA_integer_, Mean_min = NA_integer_,
Mean_max = NA_integer_, months_observed = NA_integer_), .Label = c("constant",
"aggregate", "identity"), class = "factor"), row.names = c(NA,
6L), class = c("sf", "data.frame"))
st_crs(stations)$units
的值会被使用。这不是这种情况吗?如果您包含一个简单的可重现示例,其中包含可以用于测试和验证可能的解决方案的样本输入和期望输出,那么帮助您会更容易。 - MrFlickdput
的stations
)。至于你的问题,我不知道单位是否设置为与“站点”相同的单位。我该如何验证呢? - Arturo Sbr