admin管理员组文章数量:1432196
When the raster package was still active, I would usually have to do the following to crop the rasterlayer to an irregular polygon (with some functions updated for terra). I am wondering there is a faster/more efficient way to do this same thing?:
kml <- vect("pathtokml.kml")
r <- rast("pathtoraster.tif")
crp <- mask(r, project(kml, r)) #fix for different CRS's
crp2 <- crop(crp, ext(kml))
plot(crp2)
When the raster package was still active, I would usually have to do the following to crop the rasterlayer to an irregular polygon (with some functions updated for terra). I am wondering there is a faster/more efficient way to do this same thing?:
kml <- vect("pathtokml.kml")
r <- rast("pathtoraster.tif")
crp <- mask(r, project(kml, r)) #fix for different CRS's
crp2 <- crop(crp, ext(kml))
plot(crp2)
Share
Improve this question
asked Nov 19, 2024 at 4:07
AndrewAndrew
1712 silver badges6 bronze badges
1
|
1 Answer
Reset to default 2It is more efficient to first crop and then mask, and with terra you can do this in one step.
x <- crop(r, project(kml, r), mask=TRUE)
本文标签: geospatialMask and Crop functions in Terra RStack Overflow
版权声明:本文标题:geospatial - Mask and Crop functions in Terra R - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745587689a2665008.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
mask = TRUE
incrop()
- stackoverflow/questions/77998525/… – margusl Commented Nov 19, 2024 at 8:02