r-lidar / rlas

R package to read and write las and laz files used to store LiDAR data
https://cran.r-project.org/package=rlas
GNU General Public License v3.0
34 stars 14 forks source link

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

Closed Jean-Romain closed 3 years ago

Jean-Romain commented 3 years ago
library(lidR)
las_tmp <- readLAS("~/Téléchargements/USGS_LPC_CA_Sonoma_2013_SOCO_0054_108_LAS_2017.laz", filter = "-keep_random_fraction 0.01")
epsg(las_tmp)
#> [1] 2226
las_tmp_reproj <- spTransform(las_tmp, sp::CRS("+init=epsg:6418"))
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO"): Discarded
#> datum NAD83_National_Spatial_Reference_System_2011 in CRS definition
#> Warning in sp::proj4string(x): CRS object has comment, which is lost in output
#> Warning: EPSG code not found: header not updated. Try to provide the ESPG code
#> instead of a CRS
epsg(las_tmp_reproj) = 6148
#> Warning in showSRID(SRS_string, format = "PROJ", multiline = "NO"): Discarded
#> datum European_Terrestrial_Reference_System_1989 in CRS definition
epsg(las_tmp_reproj)
#> Error in if (tags[[i]]$key == 3072) return(i): l'argument est de longueur nulle

Created on 2020-09-29 by the reprex package (v0.3.0)

Jean-Romain commented 3 years ago

Minimal reproducible example

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
header <- rlas::read.lasheader(LASfile)
header$`Variable Length Records`$GeoKeyDirectoryTag$tags[[2]] <- NULL
header <- rlas::header_set_epsg(header, 6148) #> 3 NULL introduced