使用 shapefile 裁剪光栅(来自 ForestClim)但没有成功

问题描述 投票:0回答:1

我尝试使用 shapefile

crop
(
terra
) 来自 ForestClim 数据库的 SpatRaster(这里例如使用来自 ForestClim https://figshare.com/ndownloader/files/39164684 的第一个变量),仅作为示例比利时的光栅,像这样

# shapefile
ISO <- countrycode("Belgium", origin = 'country.name', destination = 'iso3c')
shp <- gadm(country=ISO, level=0, 
            path = tempdir(), 
            version="latest")
crs(shp) <- "epsg:4326"

# raster
r <- rast(~/Downloads/ForestClim_01.tif) # download link above
crs(r) <- "epsg:4326"

# crop
cr <- crop(r, shp, mask=TRUE, overwrite=TRUE)
Error: [crop] extents do not overlap

我试图理解但没有成功, 我不明白为什么这不起作用,因为它与 CHELSA 数据完美配合。

非常感谢您的帮助或建议。

r
1个回答
0
投票

ForestClim 的 EPSG 是

epsg:3035
。因此,在裁剪之前需要先将其投影到
epsg:4326

# raster
r <- rast(~/Downloads/ForestClim_01.tif) # download link above
r <- terra::project(r, shp)
© www.soinside.com 2019 - 2024. All rights reserved.