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.
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