在terra中投影栅格失败

bqucvtff  于 2022-12-20  发布在  其他
关注(0)|答案(1)|浏览(256)

我在EPSG:7532中有一个简单栅格,尝试将其投影到EPSG:4326,但失败了
源数据是一个我可以使用lidR包处理的激光雷达点云。数据源在下面的链接中
https://rockyweb.usgs.gov/vdelivery/Datasets/Staged/Elevation/LPC/Projects/WI_BrownRusk_2020_B20/WI_Brown_2_2020/LAZ/USGS_LPC_WI_BrownRusk_2020_B20_02531702.laz

l1 = readLAS("USGS_LPC_WI_BrownRusk_2020_B20_02531702.laz")
> l1
class        : LAS (v1.4 format 6)
memory       : 2.5 Gb 
extent       : 25349, 26849, 170258, 171758 (xmin, xmax, ymin, ymax)
coord. ref.  : NAD83(2011) / WISCRS Brown (m) + NAVD88 height - Geoid18 (m) 
area         : 2.25 km²
points       : 35.57 million points
density      : 15.79 points/m²
density      : 12.89 pulses/m²

转换为spatRaster:

dsm <- rasterize_canopy(l1, res = 1.0, pitfree(c(0,2,5,10,15), c(0, 1.5))) 
> dsm
class       : SpatRaster 
dimensions  : 1500, 1501, 1  (nrow, ncol, nlyr)
resolution  : 1, 1  (x, y)
extent      : 25349, 26850, 170258, 171758  (xmin, xmax, ymin, ymax)
coord. ref. : NAD83(2011) / WISCRS Brown (m) (EPSG:7532) 
source      : memory 
name        :       Z 
min value   : 185.836 
max value   : 333.709

失败之处在于试图投影到地理格式:

dsm_test <- terra::project(dsm, "EPSG:4326", method="bilinear")

> dsm_test <- terra::project(dsm, "EPSG:4326", method="bilinear")
Error: [project] cannot get output boundaries
In addition: Warning messages:
1: In x@ptr$warp(SpatRaster$new(), y, method, mask, FALSE, opt) :
  GDAL Error 1: PROJ: vgridshift: could not find required grid(s).
2: In x@ptr$warp(SpatRaster$new(), y, method, mask, FALSE, opt) :
  GDAL Error 1: PROJ: pipeline: Pipeline: Bad step definition: proj=vgridshift (File not found or invalid)
3: In x@ptr$warp(SpatRaster$new(), y, method, mask, FALSE, opt) :
  GDAL Error 1: Too many points (961 out of 961) failed to transform, unable to compute output bounds.
  
 A similar topic here, but seems different. 
  https://stackoverflow.com/questions/72404897/what-is-causing-this-raster-reprojection-error
qvtsj1bj

qvtsj1bj1#

此问题并非由从EPSG:7532到EPSG:4326的重投影本身引起,而是与以下事实有关:通过rasterize_canopy()创建的SpatRaster对象带有垂直基准面,这显然会导致下游问题:

VERTCRS["NAVD88 height - Geoid18 (m)",
        VDATUM["North American Vertical Datum 1988"],
        CS[vertical,1],
            AXIS["up",up,
                LENGTHUNIT["meter",1]],
        GEOIDMODEL["GEOID18"],
        ID["EPSG",5703]]]

最快的解决方案是简单地覆盖EPSG:7532中的crs定义,并删除Z维中的引用,尽管这感觉不是100%正确。另一方面,我不确定terra如何处理垂直crs信息,以及是否有可能保留这些信息。

library(lidR)
library(terra)
#> terra 1.6.49

l1 = readLAS("USGS_LPC_WI_BrownRusk_2020_B20_02531702.laz")
#> Warning: There are 53206 points flagged 'withheld'.

dsm <- rasterize_canopy(l1, res = 1.0, pitfree(c(0,2,5,10,15), c(0, 1.5))) 

crs(dsm) <- "epsg:7532"

dsm_4326 <- project(dsm, "epsg:4326", method="bilinear")
dsm_4326
#> class       : SpatRaster 
#> dimensions  : 1235, 1727, 1  (nrow, ncol, nlyr)
#> resolution  : 1.093727e-05, 1.093727e-05  (x, y)
#> extent      : -88.0786, -88.05972, 44.49092, 44.50443  (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326) 
#> source(s)   : memory
#> name        :        Z 
#> min value   : 185.8360 
#> max value   : 295.1357

从我个人的Angular 来看,最好在SpatRaster摘要中列出两个crs(xy,z),reproject()能够单独处理z变换(或具有terra::transform()),例如,当您只想变换高度但仍将EPSG:7532作为xy参考系时。

coord. ref. xy: NAD83(2011) / WISCRS Brown (m) (EPSG:7532) 
coord. ref. z:  NAVD88 height - Geoid18 (m) (EPSG:5703)

相关问题