Edit LAS or LAZ file

1,321 views
Skip to first unread message

Ries B

unread,
Sep 22, 2015, 3:54:14 PM9/22/15
to LAStools - efficient tools for LiDAR processing
Hi,

I was wondering if it i possible to open a LAS file in some sort of edit mode, Seek to a point, read it, change it slightly and immediately write it back to the same file. I am trying to do this in combination with the LasZip DLL but I can not write when I open as reader and when I open a file in write mode it immediately clears the file contents.



Thanks!

Rich


carlisle haworth

unread,
Sep 22, 2015, 4:21:10 PM9/22/15
to LAStools - efficient tools for LiDAR processing
Rich,
I've done a lot of editing of las files over the last year. It depends on what you want to change about the point, but in general you edit las files using the lasview tool though you have to open all the points in the file, not just a sample which is the default. I typically run lasinfo on the file to get the number of points, and then type this number into lasview for the sample point parameter. There are a lot of very clever key combinations that help with editing, and the best resource I found on this topic was Martin's post from last year:

This process may have changed over the last year, and hopefully others can chime in if that is the case.

regards,
Carlisle

Martin Isenburg

unread,
Sep 23, 2015, 3:46:51 AM9/23/15
to LAStools - efficient command line tools for LIDAR processing
Hello Rich.

to to manual editing with LAStools the link by Carlisle is the best documentation there is right now:

http://rapidlasso.com/2014/03/02/tutorial-manual-lidar-editing/

But to rewrite a file *in place* via the LASzip DLL or the LASlib library is *not* possible. This is because the API treats LAS and LAZ file identically and rewriting a compressed LAZ file in-place is technically impossible. This is the reason we created LASlayers


LASlayers allow editing a LAS/LAZ file in-place without touching the file but by creating a "layer" that specifies which flags were turned on, which classifications have changes, or which points were deleted. However, the LASlayers concept is still in development and not part of the open source branch (yet?). As LASlayers may play a role in the new "native LAS 1.4 extension" of LASzip to allow over-writing the most commonly rewritten parts in a compressed LAZ file there may still be a few changes before LASlayers (aka the "LAY" file functionality) can be finalized.

Regards,

Martin @rapidlasso



Ries B

unread,
Sep 23, 2015, 7:55:42 AM9/23/15
to LAStools - efficient tools for LiDAR processing
Thank you Martin.
I understand your point, to bad the LASLayer are not finalized yet. Ok, so I have given up inline editing and just import or export LAS or LAZ files. Now I am writing an exporter that should plugin into my generic exporter scheme. But I again run into a problem, I do not know the number of points in advance nor do I know the bounding rectangle. Yet the writer call "laszip_set_header" forces me to know this in advance. Is this because the LAZ compression needs to know the bound for its compression?
 

Martin Isenburg

unread,
Sep 23, 2015, 12:04:18 PM9/23/15
to LAStools - efficient command line tools for LIDAR processing
Hello,

A few minutes I have updated the LASzip DLL to allow writing LAS and LAZ files (version 1.0 to 1.4) without a-priori knowledge of the bounding box or the point count.


I have added one new small code example (EXAMPLE_ELEVEN) to the laszipdllexample.cpp tutorial file that uses the DLL in various ways to show the sequence of DLL commands needed to get the DLL to update the header of the LAS / LAZ file once writing is complete.

Note that this means that you cannot create spatial indices on-the-fly but will have to do it in a separate call to lasindex because the spatial indexer needs a-priory bounding box information.

Regards,

Martin 

------------------------------------------------------------------------

>> laszipdllexample.exe lalala.las labba.las
LASzip DLL v2.4 r1 (build 150923)
running EXAMPLE_ELEVEN (writing points to LAS 1.4 without a-priori knowlegde of bounding box or point count (compatibility only for LAZ))
offset_to_point_data before adding  empty OGC WKT VLR is : 375
offset_to_point_data before adding funny VLR is          : 429
offset_to_point_data after adding VLRs                   : 483
writing file 'labba.las' uncompressed
successfully written 5 points
total time: 0 sec for writing uncompressed

>> lasinfo labba.las
lasinfo report for labba.las
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             4711
  global_encoding:            17
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.4
  system identifier:          'LASzip DLL example 7'
  generating software:        'LASzip DLL 2.4 r1 (150923)'
  file creation day/year:     30/2015
  header size:                375
  offset to point data:       483
  number var. length records: 2
  point data format:          6
  point data record length:   30
  number of point records:    0
  number of points by return: 0 0 0 0 0
  scale factor x y z:         0.01 0.01 0.01
  offset x y z:               0 0 0
  min x y z:                  630498.56 4834748.73 62.15
  max x y z:                  630499.95 4834749.66 63.68
  start of waveform data packet record: 0
  start of first extended variable length record: 0
  number of extended_variable length records: 0
  extended number of point records: 5
  extended number of points by return: 1 2 0 0 0 0 0 1 1 0 0 0 0 0 0
variable length header record 1 of 2:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            2112
  length after header  0
  description          'intentionally empty OGC WKT'
variable length header record 2 of 2:
  reserved             43707
  user ID              'funny'
  record ID            12345
  length after header  0
  description          'just a funny VLR'
reporting minimum and maximum for all LAS point record entries ...
  X            63049856   63049995
  Y           483474873  483474966
  Z                6215       6368
  intensity          20        110
  return_number       1          7
  number_of_returns   2          7
  edge_of_flight_line 0          0
  scan_direction_flag 0          0
  classification      0          5
  scan_angle_rank    21         23
  user_data           0          0
  point_source_ID     0          0
  gps_time 53413162.560400 53413162.580200
  extended_return_number          1      9
  extended_number_of_returns      2      9
  extended_classification         2     42
  extended_scan_angle          3500   3767
  extended_scanner_channel        1      1
number of first returns:        1
number of intermediate returns: 1
number of last returns:         3
number of single returns:       0
overview over extended number of returns of given pulse: 0 3 0 0 0 0 0 0 2 0 0 0 0 0 0
histogram of classification of points:
               2  never classified (0)
               2  ground (2)
               1  high vegetation (5)
 +-> flagged as extended overlap: 1
histogram of extended classification of points:
               1  extended classification (41)
               1  extended classification (42)

------------------------------------------------------------------------

>> laszipdllexample.exe lalala.las labba.laz
LASzip DLL v2.4 r1 (build 150923)
running EXAMPLE_ELEVEN (writing points to LAS 1.4 without a-priori knowlegde of bounding box or point count (compatibility only for LAZ))
offset_to_point_data before adding  empty OGC WKT VLR is : 375
offset_to_point_data before adding funny VLR is          : 429
offset_to_point_data after adding VLRs                   : 483
writing file 'labba.laz' compressed
successfully written 5 points
total time: 0 sec for writing compressed

>> lasinfo labba.laz
lasinfo report for labba.laz
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             4711
  global_encoding:            1
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.2
  system identifier:          'LASzip DLL example 7'
  generating software:        'LASzip DLL 2.4 r1 (150923)'
  file creation day/year:     30/2015
  header size:                227
  offset to point data:       1367
  number var. length records: 4
  point data format:          1
  point data record length:   33
  number of point records:    5
  number of points by return: 1 2 0 0 0
  scale factor x y z:         0.01 0.01 0.01
  offset x y z:               0 0 0
  min x y z:                  630498.56 4834748.73 62.15
  max x y z:                  630499.95 4834749.66 63.68
variable length header record 1 of 4:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            2112
  length after header  0
  description          'intentionally empty OGC WKT'
variable length header record 2 of 4:
  reserved             43707
  user ID              'funny'
  record ID            12345
  length after header  0
  description          'just a funny VLR'
variable length header record 3 of 4:
  reserved             43707
  user ID              'lascompatible'
  record ID            22204
  length after header  156
  description          'LASzip DLL 2.4 r1 (150923)'
variable length header record 4 of 4:
  reserved             43707
  user ID              'LASF_Spec'
  record ID            4
  length after header  768
  description          'LASzip DLL 2.4 r1 (150923)'
    Extra Byte Descriptions
      data type: 4 (short), name "LAS 1.4 scan angle", description: "additional attributes", scale: 0.006, offset: 0 (not set)
      data type: 1 (unsigned char), name "LAS 1.4 extended returns", description: "additional attributes", scale: 1 (not set), offset: 0 (not set)
      data type: 1 (unsigned char), name "LAS 1.4 classification", description: "additional attributes", scale: 1 (not set), offset: 0 (not set)
      data type: 1 (unsigned char), name "LAS 1.4 flags and channel", description: "additional attributes", scale: 1 (not set), offset: 0 (not set)
LASzip compression (version 2.4r1 c2 50000): POINT10 2 GPSTIME11 2 BYTE 2
reporting minimum and maximum for all LAS point record entries ...
  X            63049856   63049995
  Y           483474873  483474966
  Z                6215       6368
  intensity          20        110
  return_number       1          7
  number_of_returns   2          7
  edge_of_flight_line 0          0
  scan_direction_flag 0          0
  classification      0          5
  scan_angle_rank    21         22
  user_data           0          0
  point_source_ID     0          0
  gps_time 53413162.560400 53413162.580200
number of first returns:        1
number of intermediate returns: 1
number of last returns:         3
number of single returns:       0
WARNING: there is 1 point with return number 6
WARNING: there is 1 point with return number 7
overview over number of returns of given pulse: 0 3 0 0 0 0 2
histogram of classification of points:
               2  never classified (0)
               2  ground (2)
               1  high vegetation (5)


On Wed, Sep 23, 2015 at 1:54 PM, Ries B <rich...@gmail.com> wrote:
Thank you Martin.
I understand your point, to bad the LASLayer are not finalized yet. Ok, so I have given up inline editing and just import or export LAS or LAZ files. Now I am writing an exporter that should plugin into my generic exporter scheme. But I again run into a problem, I do not know the number of points in advance nor do I know the bounding rectangle. Yet the writer call "laszip_set_header" forces me to know this in advance. Is this because the LAZ compression needs to know the bound for its compression?
 

--
Reply all
Reply to author
Forward
0 new messages