我想使用sf程序在都柏林机场周围绘制一个110海里(海里)的圆。
(稍后,我将通过st_intersect与ADS-B的飞行位置报告相交。)

我为NM定义了一个新单元,如下所示:

library(units)
library(tidyverse)
library(sf)
NM <- make_unit("NM")
install_conversion_constant("NM", "km", 1.852)

然后定义都柏林机场坐标:
# DUB/EIDW location, see
# https://skyvector.com/airport/EIDW/Dublin-Airport
# Coordinates:
#   N53°25.28' / W6°16.20' (Degrees Decimal Minutes (DDM) format)
#   (-6.27, 53.421333) (lon/lat Decimal Degrees (DD))
# Elevation: 242.0 feet (MSL)
dub_lon <- -6.27
dub_lat <- 53.421333
dub_elv <- set_units(242.0, ft)

dub <- st_point( x = c(dub_lon, dub_lat, dub_elv), dim = "XYZ")
dub <- dub %>% st_sfc(crs = 4326)

因此定义了机场周围的圆的半径(以米为单位):
r110 <- set_units(110, NM) %>% set_units(km)

现在,当我尝试st_buffer时,一切都无法正常进行:
> r110 <- set_units(110, NM) %>% set_units(km)
Error: cannot convert km into °
In addition: Warning message:
In st_buffer.sfc(dub, dist = r110) :
  st_buffer does not correctly buffer longitude/latitude data, dist needs to be in decimal degrees.

如果我尝试将数值(203.72,这些是km)作为距离传递,至少我只会收到警告:
> dub110 <- st_buffer(dub, dist = 203.72)
Warning message:
In st_buffer.sfc(dub, dist = 203.72) :
  st_buffer does not correctly buffer longitude/latitude data, dist needs to be in decimal degrees.

但是绘制它会显示出一个很大的圆圈
library(mapview)
mapview(dub110)

r - 使用st_buffer绕地理点旋转-LMLPHP

我应该在dist中输入的st_buffer的单位是什么?
我阅读了文档,但并没有真正发现该怎么做...

任何提示/帮助真的很感激!

最佳答案

多亏了PhilJul,第一个问题的完整解决方案如下:

library(units)
library(tidyverse)
library(sf)
library(mapview)
library(units)

# define nautical miles (as per ICAO notation)
NM <- make_unit("NM")
install_conversion_constant("NM", "km", 1.852)

# DUB/EIDW location, see
# https://skyvector.com/airport/EIDW/Dublin-Airport
# Coordinates:
#   N53°25.28' / W6°16.20' (Degrees Decimal Minutes (DDM) format)
#   (-6.27, 53.421333) (lon/lat Decimal Degrees (DD))
# Elevation: 242.0 feet (MSL)
dub_lon <- -6.27
dub_lat <- 53.421333
dub_elv <- set_units(242.0, ft)
dub <- st_point(x = c(dub_lon, dub_lat, dub_elv), dim = "XYZ")
dub <- dub %>% st_sfc(crs = 4326)

# define radious of interest, i.e. 110 NM
r110 <- set_units(110, NM) %>% set_units(km) %>% set_units(m)

# change to Irish grid, which uses meters
dub <- st_transform(dub, 29902)
dub_buffer <-  st_buffer(dub, r110)

# eventually convert back to WSG84 if needed for other purposes
dub <- st_transform(dub, 4326)
dub_buffer <- st_transform(dub_buffer, 4326)
mapview(dub_buffer)

r - 使用st_buffer绕地理点旋转-LMLPHP

关于r - 使用st_buffer绕地理点旋转,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46704878/

10-11 04:18