r 将栅格裁剪为复杂多边形

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 将栅格裁剪为复杂多边形相关的知识,希望对你有一定的参考价值。

library(raster)
library(rgdal)

# Load footprint from file into rasterBrick object
path_to_footprint_nc <- './footprint.nc'
footprint <- brick(path_to_footprint_nc)

# Sum values per-cell into raster object
r_all <- sum(footprint)

# Read in counties shapefile
shape <- readOGR(dsn = 'Counties', layer = 'Counties')

# Grab the SLCo polygon from the counties shapefile
slco <- spTransform(subset(shape, NAME == 'SALT LAKE'), CRS('+proj=longlat'))

# Replace values outside of SLCo with NA
r_slco <- mask(r, slco)

# Plot pre-crop and post-crop for validation
op <- par(mfrow = c(1, 2))
plot(r_all, main = 'Full Domain')
plot(r_slco, main = 'SLCo')
par(op)

以上是关于r 将栅格裁剪为复杂多边形的主要内容,如果未能解决你的问题,请参考以下文章

R:将栅格聚合为 shapefile 多边形

GIS地理处理脚本案例教程——批量栅格分割-批量栅格裁剪-批量栅格掩膜-深度学习样本批量提取

如何使用arcgis将栅格图转为矢量图,

R中多边形和线的复杂裁剪(空间交点?)

arcgis影像分幅图裁剪

r 从Gebco到栅格线和多边形