Classification copy between 2 las datasets

592 views
Skip to first unread message

Shawn Ryan

unread,
Nov 25, 2015, 4:10:28 AM11/25/15
to LAStools - efficient tools for LiDAR processing
Hi All,

I have been supplied 2 datasets, one in ellipsoid height and one in orthometric height. I have updated the classification on one these datasets and I wanted the other to have the exact same classification. Is there anyway to copy the classification from one dataset to the other (data is all tiled) where the only difference is the z value (except the classification of course).

Regards,
Shawn

Terje Mathisen

unread,
Nov 25, 2015, 5:22:40 AM11/25/15
to last...@googlegroups.com
Many ways, more or less difficult depending upon how your data is laid out:

If the points are stored in identical order then you should be able to
simply use las2txt to export all fields except for classification from
one file and the class parameter from other, then merge them and convert
back to laz/las.

I bet I could do this for all tiles with a ~20-line perl program. :-)

Terje

--
- <Terje.M...@tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Martin Isenburg

unread,
Nov 25, 2015, 6:15:17 AM11/25/15
to LAStools - efficient command line tools for LIDAR processing
Hello,

This was already answered in this thread here:

http://groups.google.com/d/topic/lastools/qxAqkWeTljk/discussion

We can do this with LASlayers if both files have the same number of points and in the same order. A little example. First I create my "other" LiDAR file with different z coordinates (normalized) and no classifications with lasheight and las2las:

D:\LAStools\bin>lasheight -i ..\data\fusa.laz ^
                                          -replace_z ^
                                          -o fusa_norm.laz

D:\LAStools\bin>las2las -i fusa_norm.laz ^
                                    -set_classification 0 ^
                                    -o fusa_other.laz

Then I make sure that they are as different as I want them to be with lasdiff:

D:\LAStools\bin>lasdiff -i ..\data\fusa.laz  -i fusa_other.laz
checking '..\data\fusa.laz' against 'fusa_other.laz'
  different system_identifier: 'LAStools (c) by Martin Isenburg' 'LAStools (c) by rapidlasso GmbH'
  different generating_software: 'lasclassify (110920) unlicensed' 'las2las (version 151111)'
  different max_z: 64.35 19.72
  different min_z: 42.21 -1.76
headers have 4 differences.
  z: 6435 1446
  classification: 5 0
point 1 of 277573 is different
  z: 6430 1441
  classification: 5 0
point 2 of 277573 is different
  z: 6309 1316
  classification: 1 0
point 3 of 277573 is different
  z: 6288 1294
  classification: 1 0
point 4 of 277573 is different
  z: 6300 1306
  classification: 1 0
point 5 of 277573 is different
already 5 points are different ... shutting up.
277573 points are different.
both have 277573 points. took 0.672 secs.

Now I create my LAY file with the "classification layer" in two steps. First I create a helper LAZ file whose only difference is the empty classification layer:

D:\LAStools\bin>las2las -i ..\data\fusa.laz ^
                                    -set_classification 0 ^
                                    -o fusa_empty.laz

And then I use the LASlayers functionality to create the difference LAY file between the two files which will be only the classifications:

D:\LAStools\bin>laslayers -i fusa_empty.laz -i ..\data\fusa.laz -olay

A quick sanity check with lasview and laslayers confirms that the LAY file contains exactly the classifications.

D:\LAStools\bin>lasview -i fusa_empty.lay
D:\LAStools\bin>lasview -i fusa_empty.laz -ilay
D:\LAStools\bin>laslayers -i fusa_empty.laz
LASlayer 1 of 1
  start_position           276
  size                   15367
  type                       1 (replace)
  fields                   256 (classification)
  compression                2 (pointwise)
  modification_mask         48 (system_identifier generating_software)
  ignore_mask                0
  header_size               44
  modification size         64
  ignore size                0
  description size          53

Now some trickery: We copy the LAY file so it can be used with the other file that has the better aligned coordinates:

D:\LAStools\bin>copy fusa_empty.lay fusa_other.lay

And voila ... lasview shows us it worked

D:\LAStools\bin>lasview -i fusa_other.laz
D:\LAStools\bin>lasview -i fusa_other.laz -ilay

So now we flatten the LAY file into the better LAZ file in a final run with laslayers:

D:\LAStools\bin>laslayers -i fusa_other.laz -ilay -o fusa_other_classified.laz

And make a final check.

D:\LAStools\bin>lasview -i fusa_other_classified.laz

Should have worked ... (-:

More about LASlayers here:

http://rapidlasso.com/LASlayers
http://lastools.org/download/laslayers_README.txt
http://groups.google.com/forum/#!searchin/lastools/laslayers%7Csort:date

Martin @rapidlasso

Evon Silvia

unread,
Dec 2, 2015, 5:06:37 PM12/2/15
to last...@googlegroups.com
I've wondered about this for a while, too. In Martin's example the only difference between the two files is the classification, so that's the only property that gets overwritten, but the original question had two differences - elevation and class. Using the suggested workflow would overwrite the class (as desired) AND elevation (not desired), wouldn't it?

If so, is there a way to select/delete particular layers from the LAY file so that only the desired layers get copied? That is, is there a way to delete all but the classification layer from the LAY so that it's the only layer that gets "flattened" into the LAZ file?

Evon

Martin Isenburg

unread,
Dec 18, 2015, 11:53:26 AM12/18/15
to LAStools - efficient command line tools for LIDAR processing
Hello,

Evon, please check my workflow again. The difference LAY 'target.lay' file is created from the target LAZ file alone. It is created as the difference between a second modified copy of the target file 'modified.laz' (in which the classifications of the target file were zeroed) and the target file 'target.laz' itself. Only after the resulting LAY file was copied or moved to a file with the same name as the source file such as 'source.lay' in this case it is applied to the source file 'source.laz' to create the final file 'final.laz'.

However, the option to delete layers in the LAY file also exists. This needs to be done with great care as some layers (e.g. deletion layers) depend on others. But here is the same example again with deletion this time. Again a little example. First I create my "source" LiDAR file with different z coordinates (normalized) and no classifications with lasheight and las2las:

D:\LAStools\bin>lasheight -i ..\data\fusa.laz ^
                                          -replace_z ^
                                          -o fusa_temp.laz

D:\LAStools\bin>las2las -i fusa_temp.laz ^
                                    -set_classification 0 ^
                                    -o fusa_source.laz

Now I want to copy the classifications from the original file '..\data\fusa.laz' to the modified source file 'fusa_source.laz' but without changing anything else in my source file 'fusa_source.laz'. So I use the LASlayers functionality to create the difference LAY file that can go from the source file 'fusa_source.laz' to the file with the target classifications (here: ..\data\fusa.laz). Note that the two also have different z elevations.

D:\LAStools\bin>laslayers -i fusa_source.laz -i ..\data\fusa.laz -olay
WARNING: do not expect LAY files to work across different versions
         of LAStools because the development of LASlayers is still
         not completed. this is just an awesome prototype as proof
         of concept. we continue to gather community input ... (-;
headers are different
  different system_identifier: 'LAStools (c) by rapidlasso GmbH' 'LAStools (c) by Martin Isenburg'
  different generating_software: 'las2las (version 151130)' 'lasclassify (110920) unlicensed'
  different max_z: 19.72 64.35
  different min_z: -1.76 42.21
headers have 4 differences.
  z: 1446 6435
  classification: 0 5
point 1 of 277573 is different
  z: 1441 6430
  classification: 0 5
point 2 of 277573 is different
  z: 1316 6309
  classification: 0 1
point 3 of 277573 is different
  z: 1294 6288
  classification: 0 1
point 4 of 277573 is different
  z: 1306 6300
  classification: 0 1
point 5 of 277573 is different
more than 5 points are different ... shutting up.

Then we check the resulting LAY file with

D:\LAStools\bin>laslayers -i fusa_source.laz
WARNING: do not expect LAY files to work across different versions
         of LAStools because the development of LASlayers is still
         not completed. this is just an awesome prototype as proof
         of concept. we continue to gather community input ... (-;
LASlayer 1 of 2
  start_position           276
  size                   15368
  type                       1 (replace)
  fields                   256 (classification)
  compression                2 (pointwise)
  modification_mask         48 (system_identifier generating_software)
  ignore_mask                0
  header_size               44
  modification size         64
  ignore size                0
  description size          54
  description           laslayers -i fusa_source.laz -i ..\data\fusa.laz -olay
LASlayer 2 of 2
  start_position         15644
  size                     259
  type                       2 (diff)
  fields                     4 (Z)
  compression                2 (pointwise)
  modification_mask    4194304 (max_z min_z)
  ignore_mask                0
  header_size               44
  modification size         16
  ignore size                0
  description size          54
  description           laslayers -i fusa_source.laz -i ..\data\fusa.laz -olay

Then we delete the second layer that contains the pointwise Z differences with

D:\LAStools\bin>laslayers -i fusa_source.laz -del 2
WARNING: do not expect LAY files to work across different versions
         of LAStools because the development of LASlayers is still
         not completed. this is just an awesome prototype as proof
         of concept. we continue to gather community input ... (-;

Then we check that this has actually worked with

D:\LAStools\bin>laslayers -i fusa_source.laz
WARNING: do not expect LAY files to work across different versions
         of LAStools because the development of LASlayers is still
         not completed. this is just an awesome prototype as proof
         of concept. we continue to gather community input ... (-;
LASlayer 1 of 1
  start_position           276
  size                   15368
  type                       1 (replace)
  fields                   256 (classification)
  compression                2 (pointwise)
  modification_mask         48 (system_identifier generating_software)
  ignore_mask                0
  header_size               44
  modification size         64
  ignore size                0
  description size          54
  description           laslayers -i fusa_source.laz -i ..\data\fusa.laz -olay

Then we apply the LAY file that now only contains the classification change:

D:\LAStools\bin>laslayers -i fusa_source.laz -ilay -o fusa_target.laz
WARNING: do not expect LAY files to work across different versions
         of LAStools because the development of LASlayers is still
         not completed. this is just an awesome prototype as proof
         of concept. we continue to gather community input ... (-;

And now we have the result in the file 'fusa_target.laz'. The classifications from the file '..\data\fusa.laz' were copied to the file 'fusa_source.laz' while the normalized Z coordinates were kept intact:

D:\LAStools\bin>lasinfo fusa_target.laz
lasinfo report for fusa_target.laz
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             0
  global_encoding:            0
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.1
  system identifier:          'LAStools (c) by Martin Isenburg'
  generating software:        'lasclassify (110920) unlicensed'
  file creation day/year:     40/2010
  header size:                227
  offset to point data:       321
  number var. length records: 1
  point data format:          1
  point data record length:   28
  number of point records:    277573
  number of points by return: 263413 13879 281 0 0
  scale factor x y z:         0.01 0.01 0.01
  offset x y z:               0 0 0
  min x y z:                  277750.00 6122250.00 -1.76
  max x y z:                  277999.99 6122499.99 19.72
variable length header record 1 of 1:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34735
  length after header  40
  description          'by LAStools of Martin Isenburg'
    GeoKeyDirectoryTag version 1.1.0 number of keys 4
      key 1024 tiff_tag_location 0 count 1 value_offset 1 - GTModelTypeGeoKey: ModelTypeProjected
      key 3072 tiff_tag_location 0 count 1 value_offset 32754 - ProjectedCSTypeGeoKey: UTM 54 southern hemisphere
      key 3076 tiff_tag_location 0 count 1 value_offset 9001 - ProjLinearUnitsGeoKey: Linear_Meter
      key 4099 tiff_tag_location 0 count 1 value_offset 9001 - VerticalUnitsGeoKey: Linear_Meter
LASzip compression (version 2.4r1 c2 50000): POINT10 2 GPSTIME11 2
reporting minimum and maximum for all LAS point record entries ...
  X            27775000   27799999
  Y           612225000  612249999
  Z                -176       1972
  intensity          10      62293
  return_number       1          3
  number_of_returns   1          3
  edge_of_flight_line 0          0
  scan_direction_flag 0          0
  classification      1          6
  scan_angle_rank    79        103
  user_data           0        197
  point_source_ID     1          1
  gps_time 5880.963028 5886.739738
number of first returns:        263413
number of intermediate returns: 283
number of last returns:         263370
number of single returns:       249493
overview over number of returns of given pulse: 249493 27232 848 0 0 0 0
histogram of classification of points:
           17553  unclassified (1)
          180868  ground (2)
           37030  high vegetation (5)
           42122  building (6)

Regards,

Martin @rapidlasso

On Wed, Dec 2, 2015 at 11:05 PM, Evon Silvia <esi...@quantumspatial.com> wrote:
I've wondered about this for a while, too. In Martin's example the only difference between the two files is the classification, so that's the only property that gets overwritten, but the original question had two differences - elevation and class. Using the suggested workflow would overwrite the class (as desired) AND elevation (not desired), wouldn't it?

If so, is there a way to select/delete particular layers from the LAY file so that only the desired layers get copied? That is, is there a way to delete all but the classification layer from the LAY so that it's the only layer that gets "flattened" into the LAZ file?

Evon
On Wed, Nov 25, 2015 at 3:14 AM, Martin Isenburg <martin....@gmail.com> wrote:
Hello,

This was already answered in this thread here:

http://groups.google.com/d/topic/lastools/qxAqkWeTljk/discussion

We can do this with LASlayers if both files have the same number of points and in the same order. A little example. First I create my "other" LiDAR file with different z coordinates (normalized) and no classifications with lasheight and las2las:

D:\LAStools\bin>lasheight -i ..\data\fusa.laz ^
                                          -replace_z ^
                                          -o fusa_temp.laz

damrau

unread,
Nov 11, 2016, 8:01:50 AM11/11/16
to LAStools - efficient tools for LiDAR processing
Hi Martin,

I saw this discussion in the user forum. But it don't fit the expectations. I have no guarantee that the numbers of points are identically. But for sure I can identify identically points via time stamp AND Echo.

 

Background:

Sometimes the precise adjustment and the classification are done in different places and from different companies. So it can happen, that some points are deleted in classification task.

 

The direction of copy is not important. We can bring the classification results to the adjusted las files or we can bring the coordinates of the adjusted las files to the classified data set.

 

Basically it works with TS "Copy from reference" but only for point clouds up to 20 Mio Points. I have some files they are up to 70 Mio Points.

Martin Isenburg

unread,
Nov 14, 2016, 5:31:47 PM11/14/16
to LAStools - efficient command line tools for LIDAR processing
Hello Aicke,

thanks for the suggestion. A new tool has been added to the just released LAStools version (161114) called 'lascopy' that does exactly what you need it to do.

http://lastools.org/download/lascopy_README.txt

Here a little example using the venerable 'fusa.laz' how to copy the classifications from one version of this file to another one assuming that all the points keep their GPS time stamps and their return numbers intact (which are used to establish the matching):

lassort -i ..\data\fusa.laz ^
            -set_classification 0 ^
            -drop_z_above 50 ^
            -o fusa_dropped_unclassified_sorted.laz

lasview -i fusa_dropped_unclassified_sorted.laz

lascopy -v -i ..\data\fusa.laz ^
             -i fusa_dropped_unclassified_sorted.laz ^
             -o fusa_reclassified1.laz
reading attributes of 277573 points from source file '..\data\fusa.laz' ...
preparing attributes of 277573 points from source file '..\data\fusa.laz' ...
copying attributes to 209320 points of target file 'fusa_dropped_unclassified_sorted.laz' ...
done with 'fusa_reclassified1.laz'. copied 209320 point attributes. total time 0.755 sec.

las2las -i ..\data\fusa.laz ^
            -set_classification 9 ^
            -o fusa_reclassified_water.laz

lasview -i fusa_reclassified_water.laz

lascopy -v -i fusa_reclassified1.laz ^
             -i fusa_reclassified_water.laz ^
             -o fusa_reclassified2.laz
reading attributes of 209320 points from source file 'fusa_reclassified1.laz' ...
preparing attributes of 209320 points from source file 'fusa_reclassified1.laz' ...
copying attributes to 277573 points of target file 'fusa_reclassified_water.laz' ...
done with 'fusa_reclassified2.laz'. copied 216794 point attributes. total time 0.9 sec.

lasview -i fusa_reclassified2.laz

lascopy -v -i fusa_reclassified1.laz ^
             -i fusa_reclassified_water.laz ^
             -zero ^
             -o fusa_reclassified3.laz
reading attributes of 209320 points from source file 'fusa_reclassified1.laz' ...
preparing attributes of 209320 points from source file 'fusa_reclassified1.laz' ...
copying attributes to 277573 points of target file 'fusa_reclassified_water.laz' ...
done with 'fusa_reclassified3.laz'. copied 216794 point attributes. total time 0.99 sec.

lasview -i fusa_reclassified3.laz

================================

Other changes in version 161114 are:

14 November 2016 -- blast2dem: output *.prj files for ASC/BIL/FLT/XYZ
14 November 2016 -- NEW: lascopy copies classifications from source to target based on GPS time + return number
14 November 2016 -- blast2dem: grids can be output as compressed LAZ points
14 November 2016 -- blast2dem, blast2iso: support for entire set of CRS like the remaining LAStools
13 November 2016 -- all LAStools: early FALSE when setting output directory via '-odir __' will not succeed  
9 November 2016 -- all LAStools: support CRS via "user defined" AlbersEqualArea projection in GeoTIFF tags
8 November 2016 -- lascanopy, lasgrid, las2dem fix memory bug introduced with PRJ support in 160721
7 November 2016 -- lasclip: fix issue when option '-donut' is used and polygons have repeated vertices


--
lascopy_1_fusa_dropped_unclassified_sorted.jpg
lascopy_2_fusa_reclassified1.jpg
lascopy_3_fusa_reclassified_water.jpg
lascopy_4_fusa_reclassified2.jpg
lascopy_5_fusa_reclassified3.jpg

Evon Silvia

unread,
Nov 14, 2016, 5:44:44 PM11/14/16
to last...@googlegroups.com
Great work, Martin. This significantly simplifies the LAY workflow.

One note - lascopy breaks down for multichannel data like ALS80s in which you can validly have two points with identical return numbers and timestamps but different channels. It would make this more robust to also index based on channel. Of course this only works for LAS 1.4 files, but I like incentivizing moving to the new format.

Evon

Aicke Damrau

unread,
Nov 15, 2016, 4:24:20 AM11/15/16
to last...@googlegroups.com

Hi Martin,

 

that's great thank you. Does it work also as blast, with extreme big Las files?

 

Mit freundlichen Grüßen

 

Aicke Damrau

 

Tel.: +49 391 50 95 95 80

Fax: +49 391 50 95 95 899

Mobil: +49 160 3653 111

 

Webshop Geodaten online: https://geoshop.geofly.eu

cid:image003.png@01D22BA6.AC8B1FD0

 

GeoFly GmbH

Ottersleber Chaussee 91

39120 Magdeburg

Business Airport

image001.png

Martin Isenburg

unread,
Nov 15, 2016, 12:51:06 PM11/15/16
to LAStools - efficient command line tools for LIDAR processing

Hello,

Currently the new lascopy tool should handle to just below 200 million points. If that is not enough I can easily add a huge_xxxx.bat scripts to the example_batch_script folder that will work similarly to the already existing batch script for sorting huge files by first creating a number of temporary files split by GPS time (and of course by scanner channel for LAS 1.4, thanks for the fore-sight, Evon).

Martin @rapidlasso

Martin Isenburg

unread,
Nov 25, 2016, 10:50:33 PM11/25/16
to LAStools - efficient command line tools for LIDAR processing
Hello,

ADVISORY: I just found a small bug in the initial release of lascopy that - for the old (and most common) point types 1, 3, 4 and 5 does not handle multiple returns correctly. In the first release all returns of the target file are given the classification of the first return from the source file if the GPS time stamp matches.

This has been fixed now and will soon me released as a new version (tomorrow?). The fixed version of lascopy can now also copy intensities and elevations.

Sorry about that folks,

Regards,

Martin @rapidlasso
Reply all
Reply to author
Forward
0 new messages