Classification (and/or other attributes) transfer from file A to file B

264 views
Skip to first unread message

Mathieu Peyréga

unread,
Aug 18, 2015, 12:44:05 AM8/18/15
to LAStools - efficient tools for LiDAR processing
Hello,

we would like to do the following (to say it quite clearly implement the
"Copy From Reference capability of the famous T.......n software)

We have almost the same file twice (same number of points timestamps in
same time reference, same echos, only the xyz and classifications may be
slightly different
between both because one trajectory computation was better than the
other and also flight band adjustement was better)
The classification is considered good in file A and the XYZ
displacements are small (or close to a global translation) so that it
should not change the classification on the final file

We would like to apply classification from file A to file B while
keeping the coordinates of points in file B (classification transfer)

Is that possible with lastools ? From the description above (and new
capability) being able to output some kind of "displacement maps" (with
or without mean offset removed) in X,Y,Z would be a nice additionnal
output for quality control as it helps spotting were the manual
classification checks should be done.

More generaly being able to copy some of point attributes from one file
to another which is only "including" the first one would be nice (i.e.
touch only the points with matching timestamps and echos) if
the timestamps do not strictly match one to one.

In our particular case, we have GPS standard time timestamps, so I guess
that timestamp and echos uniquely define each point. It may not be the
case in time of week reference time (flight line id could be added as an
additionnal point matching criteria)

Best regards,

Mathieu Peyréga

Martin Isenburg

unread,
Aug 18, 2015, 5:18:02 AM8/18/15
to LAStools - efficient command line tools for LIDAR processing
Hello,

the famous T.......n software? Tarnation software? Tearstain software? Thickskin software?

(-;

Here we go. 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 "better" LiDAR file with slightly different coordinates and no classifications with las2las:

D:\LAStools\bin>las2las -i ..\data\fusa.laz ^
                                    -set_classification 0 ^
                                    -translate_xyz 0.01 0.01 0.01 ^
                                    -o fusa_better.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_better.laz
checking '..\data\fusa.laz' against 'fusa_better.laz'
  different system_identifier: 'LAStools (c) by Martin Isenburg' 'LAStools (c) by rapidlasso GmbH'
  different generating_software: 'lasclassify (110920) unlicensed' 'las2las (version 150803)'
  different max_x: 277999.99 278000.04
  different min_x: 277750 277750.05
  different max_y: 6122499.99 6122500.04
  different min_y: 6122250 6122250.05
  different max_z: 64.35 64.4
  different min_z: 42.21 42.26
headers have 8 differences.
  x: 27799997 27800002
  y: 612234220 612234225
  z: 6435 6440
  classification: 5 0
point 1 of 277573 is different
  x: 27799997 27800002
  y: 612234253 612234258
  z: 6430 6435
  classification: 5 0
point 2 of 277573 is different
  x: 27799952 27799957
  y: 612233974 612233979
  z: 6309 6314
  classification: 1 0
point 3 of 277573 is different
  x: 27799955 27799960
  y: 612234005 612234010
  z: 6288 6293
  classification: 1 0
point 4 of 277573 is different
  x: 27799953 27799958
  y: 612234041 612234046
  z: 6300 6305
  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.808 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
  description           laslayers -i fusa_empty.laz -i ..\data\fusa.laz -olay

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

And voila ... lasview shows us it worked

D:\LAStools\bin>lasview -i fusa_better.laz
D:\LAStools\bin>lasview -i fusa_better.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_better.laz -ilay -o fusa_better_classified.laz

And make a final check.

D:\LAStools\bin>lasview fusa_better_classified.laz

Yipee ... (-:


Martin @rapidlasso

Mathieu Peyréga

unread,
Aug 18, 2015, 5:29:07 AM8/18/15
to LAStools - efficient tools for LiDAR processing
So simple when you see it... it look like some math theorems demonstrations you feel dumb when you see them.

What should be famous with lastools (beside of course efficiency and quality) is the quality of support and community !

Regards,

Mathieu
Reply all
Reply to author
Forward
0 new messages