4

I'm trying to reproject a LAZ file from EPSG 2226 to EPSG 6418.

The reprojection works fine (I followed this: Can I re-project an LAS file in LidR) but I cannot store the information onto the LAS header and subsequently, as well as I save my LAS file (and get out of R environment), the CRS is lost.

Download this LAZ file

I used the code below:

library(lidR)
las_tmp <- readLAS("./USGS_LPC_CA_Sonoma_2013_SOCO_0054_108_LAS_2017.laz")
las_tmp_reproj <- spTransform(las_tmp, sp::CRS("+init=epsg:6418"))

#> Warning messages:
#> 1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
#>   Discarded datum NAD83_National_Spatial_Reference_System_2011 in CRS definition
#> 2: In sp::proj4string(x) : CRS object has comment, which is lost in output
#> 3: EPSG code not found: header not updated. Try to use the function epsg() manually to ensure CRS will be written in file. 
#> 4: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
#>   Discarded datum Unknown based on GRS80 ellipsoid in CRS definition

As said by warnings() number 3, the epsg code is not found and header not updated. I followed the tips and tried the following command:

epsg(las_tmp_reproj) <- as.integer(6418)

#> Warning message:
#> In showSRID(SRS_string, format = "PROJ", multiline = "NO") :
#>   Discarded datum NAD83_National_Spatial_Reference_System_2011 in CRS definition

Unfortunately, after this step, the access to the epsg information epsg(las_tmp_reproj) throws me the following error:

epsg(ctg_tmp_reproj)
#> Error in if (tags[[i]]$key == 3072) return(i) : 
#>   l'argument est de longueur nulle

Is it related with the datum itself? The error message is not really explicit and I'm pretty stuck

1
  • The message is not explicit because it is a bug. Your code is correct. I opened an issue here.
    – JRR
    Sep 29, 2020 at 19:38

1 Answer 1

4

You actually found a bug. I reported it as epsg(x) : Error in if (tags[[i]]$key == 3072) return(i): l'argument est de longueur nulle. This bug comes from the package rlas. It has been fixed in version 1.3.7. To fix your trouble before CRAN release you can install rlas from Github

remotes::install_github("Jean-Romain/rlas")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.