使 Maxent 的环境栅格图层相同的问题

发布于 2025-01-09 07:42:15 字数 423 浏览 1 评论 0原文

我有九个栅格图层 (.tif),每个栅格图层都需要具有相同的范围、分辨率和 CRS 才能在 Maxent 中工作。 我尝试将每个图层转换为相同的CRS,并将它们转换为QGIS中的.asc格式。 之后,我尝试对 R 中的图层进行重新采样以匹配其中一个图层,但这会导致错误,例如范围不重叠。 我的问题是如何匹配所有这些层才能继续使用 Maxent 并使用 R 中的“堆栈”函数?

这是带有栅格的 zip 文件: https://drive.google.com/file/d/1lle95SPdQ7FyQSbFoFvmAzyuO2HUt7-L/view?usp=sharing

I have nine raster layers (.tif) and each needs to have the same extent, resolution and CRS in order to work in Maxent.
I have tried converting each layer to the same CRS and translating them to .asc format in QGIS.
After that I tried to resample the layers in R to match one of the layers, but this resulted in errors, such as that the extents do not overlap.
My question is how do I match all these layers in order to proceed with Maxent and also to use the 'stack' function in R?

Here is the zip-file with the rasters: https://drive.google.com/file/d/1lle95SPdQ7FyQSbFoFvmAzyuO2HUt7-L/view?usp=sharing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飞烟轻若梦 2025-01-16 07:42:15

所以最初的问题是使用 raster 包中的“crs”函数设置 crs(我还没有使用新的 terra 包)。然后你需要重新投影到相同的crs中。下一步是对栅格重新采样,使它们都具有相同的像元分辨率和大小。最后你可以把它们放在一个堆栈中。由于时间比较匆忙,所以没能很好地发表评论,如果有疑问请告诉我。最后一点是基岩文件。您需要先使用 QGIS 或其他程序对其进行地理配准。尝试找到一张具有与其相似的已知投影的地图。

library(raster)
ls = list.files(".",pattern ="tif")
ls = ls[-which(ls == "bedrock.tif")]
r  = lapply(ls,raster)
names(r) = ls
wgs84 = "+proj=longlat +datum=WGS84 +no_defs"
ETRS = "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs"

crs(r$wc2.1_2.5m_bio_1.tif) = wgs84
crs(r$wc2.1_2.5m_bio_12.tif) = wgs84
crs(r$wc2.1_2.5m_elev.tif) = wgs84
crs(r$SBPC1.tif) = ETRS
crs(r$SBPC2.tif) = ETRS
crs(r$SPPC1.tif) = ETRS
crs(r$SPPC2.tif) = ETRS
crs(r$U2018_CLC2018_V2020_20u1.tif) = ETRS
# aggregate for faster processing -- you'll want to change this, but my machine couldn't process it
ra <- lapply(r,aggregate,fact=10, fun=max)
# not all need to be reprojected - this is me being lazy
rp = lapply(ra,projectRaster, crs = ETRS)

# resample rasters to match
sapply(rp,area)
rpr = lapply(rp,resample, y = rp$SBPC1.tif)
sapply(rpr,area)
rs = stack(rpr)
plot(rs)

So the initial problem is to set the crs using the 'crs' function from the raster package (I haven't used the new terra package yet). Then you need to reproject into the same crs. The next step is to resample the rasters so they all have the same cell resolution and size. Last you can put them in a stack. I was in a rush, so I didn't comment very well, but let me know if you have questions. The last point is the bedrock file. You'll need to use QGIS or another program to georeference it first. Try to find a map with a known projection that looks similar to it.

library(raster)
ls = list.files(".",pattern ="tif")
ls = ls[-which(ls == "bedrock.tif")]
r  = lapply(ls,raster)
names(r) = ls
wgs84 = "+proj=longlat +datum=WGS84 +no_defs"
ETRS = "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs"

crs(r$wc2.1_2.5m_bio_1.tif) = wgs84
crs(r$wc2.1_2.5m_bio_12.tif) = wgs84
crs(r$wc2.1_2.5m_elev.tif) = wgs84
crs(r$SBPC1.tif) = ETRS
crs(r$SBPC2.tif) = ETRS
crs(r$SPPC1.tif) = ETRS
crs(r$SPPC2.tif) = ETRS
crs(r$U2018_CLC2018_V2020_20u1.tif) = ETRS
# aggregate for faster processing -- you'll want to change this, but my machine couldn't process it
ra <- lapply(r,aggregate,fact=10, fun=max)
# not all need to be reprojected - this is me being lazy
rp = lapply(ra,projectRaster, crs = ETRS)

# resample rasters to match
sapply(rp,area)
rpr = lapply(rp,resample, y = rp$SBPC1.tif)
sapply(rpr,area)
rs = stack(rpr)
plot(rs)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文