5

I am working with 2 adjacent 2014 LAS dataset provided in 2 projections: enter image description here

However, when I type espg(las) my returned answer is 0

If I type summary(las) my coord.Ref.: NA

enter image description here

I wish to re-project both of these to NAD83/UTM18 and process them together through LiDR. I am unclear if this is possible to do in LiDR? How best to proceed? I have 1000 1km tiles to deal with.

1
  • 1
    Please edit your question and remove screenshoot of text to include actual text.
    – JRR
    Aug 16, 2020 at 21:03

1 Answer 1

5

You can assign a CRS to your LAS object with epsg()<-

epsg(las) <- 12345

You can re-project with st_transform() but this function is suboptimal in its current implementation. It actually transforms the LAS into a MULTIPOINT, uses sf::st_transform() and updates back the LAS object. I recommend to use las2las from LAStools for this kind of LAS file processing tasks but for small dataset st_transform may be convenient.

library(lidR)
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las = readLAS(LASfile)
las
#> class        : LAS (v1.2 format 1)
#> memory       : 6.2 Mb 
#> extent       : 684766.4, 684993.3, 5017773, 5018007 (xmin, xmax, ymin, ymax)
#> coord. ref.  : NAD83 / UTM zone 17N  
#> area         : 53112.69 m²
#> points       : 81.6 thousand points
#> density      : 1.54 points/m²
las2 = st_transform(las, st_crs(26918))
las2
#> class        : LAS (v1.2 format 1)
#> memory       : 6.2 Mb 
#> extent       : 214261.7, 214504.9, 5021517, 5021767 (xmin, xmax, ymin, ymax)
#> coord. ref.  : NAD83 / UTM zone 17N 
#> area         : 53174.62 m²
#> points       : 81.6 thousand points
#> density      : 1.53 points/m²

Note - before lidR 3.0.4 the function is a little bit buggy. If you check las2 you will see it is no longer strictly compliant to the specifications. It was fixed in lidR 3.0.4.

las_check(las2)
6
  • Is it possible, that this does not work anymore? I just tried it and got an error like this: Error in (function (classes, fdef, mtable) : cannot find inherited method for function 'spTransform' for signature '"LAS", "CRS" (translated from German)
    – Zoe
    Aug 4, 2022 at 13:21
  • 1
    use st_transform. See my edited anwser
    – JRR
    Aug 4, 2022 at 13:32
  • Thank you very much! Works perfectly!
    – Zoe
    Aug 4, 2022 at 14:43
  • are there any updates on this, or is the "suboptimal" st_transform() still the way to go? las2las by LAStools doesn't know the EPSG codes I'm working with, therefore unfortunately I can't use it for the projection of my (rather large) dataset. So I'll go with retiling and st_transform() on each tile.
    – Honeybear
    Feb 28, 2023 at 12:20
  • actually, sf::st_transform results in an error for me: Error in UseMethod("st_transform"): not applicable method 'st_transform' applied to object of class "c('LAS', 'Spatial')".
    – Honeybear
    Feb 28, 2023 at 12:34

Your Answer

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

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