버퍼 해안선

Sep 10 2020

라이브러리의 st_buffer()데이터를 사용하여 해안선 버퍼를 생성하려고합니다 rnaturalearth. 그러나 버퍼를 만들면 다른 "측면"으로 감싸지 않고 프로젝션 영역 외부로 확장됩니다. 이는 다운 스트림 형상 사용에 문제를 일으 킵니다. GIS SE의 다른 해안선 버퍼 문제 (예 : 1 , 2 )는 투영 가장자리 문제와 관련이 없거나 R에 없었습니다.

library(rgdal)
library(rnaturalearth)
library(sf)
library(ggplot2)

robin = CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")

ROI = ne_countries(returnclass = 'sf') %>%
  st_combine() %>%
  st_transform(robin)
coastalWaters = ROI %>%
  st_buffer(500000)
ggplot() +
  geom_sf(data = coastalWaters, fill = "lightblue", col = "transparent") +
  geom_sf(data = ROI)

위의 재현 가능한 코드는 다음과 같은 플롯으로 이어집니다 (내가 주석 처리 한 빨간색 원).

제 질문은 "이해 된"래핑으로 글로벌 폴리곤 세트를 버퍼링하는 방법입니다. 솔루션은 바람직하게는 sf 함수 라이브러리를 사용합니다.

답변

2 Roger-123 Sep 11 2020 at 07:41

편집 : 결과 그림 추가

FSimardGIS가 의견에서 언급했듯이 여기서 핵심은 st_wrap_dateline. 트릭은 st_transformation버퍼를 만들기 전에 사용할 수 없다는 것입니다. 왜냐하면 st_wrap_dateline필요한 위도 / 경도가 아닌 투영 좌표로 변환하기 때문 입니다.

st_buffer 그런 다음 버퍼 거리를 호 각도로 원하므로 빠른 계산을 통해 km를 호 초로 변환했지만 미세 조정이 필요할 수 있습니다.

그런 다음 coord_sfggplot에 추가 하여 ggplot이 비주얼에 대한 투영을 수행 할 수 있도록했습니다.

library(rgdal)
library(rnaturalearth)
library(sf)
library(ggplot2)

robin = CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")

ROI = ne_countries(returnclass = 'sf') %>%
  st_combine() 

#Please check the math on this part.
#KM/earth circumference * degrees in circle
buffer_in_km <- 500
buffer_as_arc_degrees<- buffer_in_km/40075*360

coastalWaters = ROI %>%
  st_buffer(buffer_as_arc_degrees)  %>% st_wrap_dateline()

ggplot() +
  geom_sf(data = coastalWaters, fill = "lightblue", col = "transparent") +
  geom_sf(data = ROI) +
  coord_sf(crs = robin)