标签: rnaturalearth

在R中创建距海岸线25公里的缓冲区并计算近岸面积

我正在尝试创建一个包含多边形的地图,这些多边形代表从每个国家/地区的海岸线到海洋的 25 公里缓冲区,以便我可以计算每个国家/地区的缓冲区内的面积。我在使用上传的海岸线文件和自然地球数据执行此操作时遇到困难。到目前为止,这是我尝试过的:

library(rgdal)
library(sf)
library(rnaturalearthdata)
library(rnaturalearth)
library(rgeos)
library(maps)
library(countrycode)

# World polygons from the maps package

world_shp <- sf::st_as_sf(maps::map("world", plot = T, fill = TRUE))

world_shp_df <- world_shp %>%
  mutate(Alpha.3.code = countrycode(ID, "country.name", "iso3c", warn = FALSE))

# Get coastlines using rnaturalearth
coastline <- ne_coastline(scale = "medium", returnclass = "sf")

# Buffer the coastlines by 25 km
buffer_distance <- 25000  # 25 km in meters
coastline_buffers <- st_buffer(coastline, dist = buffer_distance) %>%
  st_make_valid() 

ggplot() +
  geom_sf(data = coastline_buffers , …
Run Code Online (Sandbox Code Playgroud)

mapping maps r geospatial rnaturalearth

6
推荐指数
1
解决办法
212
查看次数

标签 统计

geospatial ×1

mapping ×1

maps ×1

r ×1

rnaturalearth ×1