在 Terra 中将 CRS 更改为长/纬度

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

我正在使用

Terra
中的
R
处理栅格数据,但我对此并不熟悉。我尝试做的是将 CRS 更改为长/纬度。 我能够将
.tif
文件加载为
SpatRaster
类。

我可以提取坐标信息为

r <- rast("file.tif")
> r
class       : SpatRaster
dimensions  : 700, 700, 1  (nrow, ncol, nlyr)
resolution  : 1000, 1000  (x, y)
extent      : 3e+05, 1e+06, 3e+05, 1e+06  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=lcc +lat_0=50.797815 +lon_0=4.35921583333333 +lat_1=49.8333333333333 +lat_2=51.1666666666667 +x_0=649328 +y_0=665262 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
source      : 20200101000000.radclim.accum1h.tif
name        : 20200101000000.radclim.accum1h
> dataframe_r <- as.data.frame(r, xy=TRUE)
> head(dataframe_r)
       x      y 2020010104
1 300500 999500          0
2 301500 999500          0
3 302500 999500          0
4 303500 999500          0
5 304500 999500          0
6 305500 999500          0

我尝试获取经/纬度格式的坐标。有人可以帮我吗?

我试过了

> proj <- project(r,  "+proj=longlat")

但是,那么我就不会使用坐标了。参考号来自 SpatRaster...

r reference coordinates terra
1个回答
0
投票

我知道您想要具有不同 crs 的栅格的栅格单元的经/纬度坐标。在这种情况下,你可以这样做

pts <- as.points(r, na.rm=FALSE) 
pts <- project(pts, "+proj=longlat")
lonlatpts <- crds(pts)
© www.soinside.com 2019 - 2024. All rights reserved.