`st_buffer` 中的 `dist` 参数默认设置为什么单位?

What unit is the `dist` argument in `st_buffer` set to by default?

我有以下墨西哥地图。它显示了其所有城市和大约 400 个气象站。

我想在每个车站周围创建一个 10 公里的缓冲区,并最终将每个城市与位于每个半径内的一个车站相关联。

地图和站点存储在不同的 sf 对象中。我厌倦了以下内容:

buffers <- st_buffer(stations, dist = 1)

我以为 dist 参数设置为公里,所以我尝试了 dist = 10。不幸的是,这为每个站点返回了 HUGE 缓冲区。这就是我使用 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"))

您的坐标是 long/lat,因此距离将以度为单位。您应该首先投影到以米为单位的空间参考,然后取 10 000 米。

st_buffer 的手册对 dist 参数是这样说的:

in case dist is a units object, it should be convertible to arc_degree if x has geographic coordinates, and to st_crs(x)$units otherwise

如果您将坐标保留在 4326 中,您应该可以取 0.1 之类的值,对于墨西哥来说应该是大约 11 公里,但是您会看到一条警告消息:

In st_buffer.sfc(st_geometry(x), dist, nQuadSegs, endCapStyle = endCapStyle, : st_buffer does not correctly buffer longitude/latitude data

所以首先转换为另一个投影(以米为单位)并输入以米为单位的距离。这应该有效,它使用 EPSG 7801:

library(sf)

pois <- st_as_sf(stations)
st_crs(pois) <- 4326
pois <- st_transform(pois, crs = 7801)
plot(st_geometry(pois))

buff <- st_buffer(pois, dist = 10000)
plot(st_geometry(buff), add = TRUE)

使用传单和测量工具进行控制:

buff <- st_transform(buff, crs = 4326)

library(leaflet)

leaflet() %>% 
  addTiles() %>% 
  addMeasure(primaryLengthUnit = "meters") %>% 
  addMarkers(data = pois) %>% 
  addPolygons(data = buff)