Working with lasfilter class

342 views
Skip to first unread message

Tomás Cabezudo

unread,
Feb 2, 2021, 5:54:33 AM2/2/21
to LAStools - efficient tools for LiDAR processing
I am working with this class to speed up the reading of large volumes of lidar data and read only the code that interests me. Analyzing the source code, I see that it does not work well if the codes are above 31. That is, it only uses 5-bit coding.

Is it a bug or something intentional?

Best regards.

Martin Isenburg

unread,
Feb 2, 2021, 2:01:18 PM2/2/21
to LAStools - efficient command line tools for LIDAR processing
Hello,

could you elaborate on what your input is (maybe provide a lasinfo
report) and what the exact command line is that you are using?

http://rapidlasso.com/lasinfo

Martin
> --
> Download LAStools at
> http://lastools.org
> http://rapidlasso.com
> Be social with LAStools at
> http://facebook.com/LAStools
> http://twitter.com/LAStools
> http://linkedin.com/groups/LAStools-4408378
> Manage your settings at
> http://groups.google.com/group/lastools/subscribe
> ---
> You received this message because you are subscribed to the Google Groups "LAStools - efficient tools for LiDAR processing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lastools+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lastools/216de3bd-b03d-47e5-9f52-f6876c65879dn%40googlegroups.com.

Tomás Cabezudo

unread,
Feb 3, 2021, 4:14:53 AM2/3/21
to LAStools - efficient tools for LiDAR processing
Hello Martin.

I'm not really using command line programs.
I make custom programs in c/c ++, based on laslib source code, for lidar data processing.
We usually work with lidar files that use codes below 32. Exceptionally there are projects in which we need to work with pulses with codes above 32.
By setting a filter within the program (for example for code 99), I am actually extracting code 3.

I am using the LASFilter.parse function for this

Reviewing the source code, I see that an effective limit is set.
I also see that some binaries operations is used to create a mask of values only valid in the range 0-31

        do
         {
            if (sscanf (argv [i], "% u", & classification)! = 1)
            {
               fprintf (stderr, "ERROR: '% s' needs at least 1 argument: classification but '% s' is no valid classification \ n", argv [i_in], argv [i]);
               return FALSE;
            }

            if (classification> 31)  
            {
              fprintf (stderr, "ERROR: '% s' needs arguments between 0 and 31 but '% u' is out of range \ n", argv [i_in], classification);
              return FALSE;
            }
            keep_classification_mask |= (1u << classification);
            *argv[i]='\0';
             i+=1;
         } while ((i < argc) && ('0' <= *argv[i]) && (*argv[i] <= '9'));
        
Obviously, a binary shift of 99 on a 1u value doesn't make sense, and mask .

In practice it is as if we were working with the last 5 bits of the code used in the mask.

Best regards.

Martin Isenburg

unread,
Feb 3, 2021, 7:52:21 AM2/3/21
to LAStools - efficient command line tools for LIDAR processing
Hello,

currently the filter for classifications higher than 31 (which implies
the use of the new point types 6 or higher) is done with another
filter called

-keep_extended_classification 42
-drop_extended_classification 42

or

-keep_extended_class 67
-drop_extended_class 67

Here is the code:

https://github.com/LAStools/LAStools/blob/master/LASlib/src/lasfilter.cpp#L1844
https://github.com/LAStools/LAStools/blob/master/LASlib/src/lasfilter.cpp#L3041

Regards,

Martin
> To view this discussion on the web visit https://groups.google.com/d/msgid/lastools/c32a851e-bf30-4329-8f80-dbfad04ba8acn%40googlegroups.com.

Tomás Cabezudo

unread,
Feb 3, 2021, 7:58:07 AM2/3/21
to LAStools - efficient tools for LiDAR processing
Thanks Martin!!



Regards. 

Tomás Cabezudo

unread,
Feb 4, 2021, 5:44:29 AM2/4/21
to LAStools - efficient tools for LiDAR processing
Hi again, Martin.

Unfortunately, -keep_extended_classification option don't work either.

I have a .laz file (1.4 version) for testing purposes with some points in 99 class.

I'm using next command:

 las2las -i example_1_4.laz -keep_extended_class 99 -o 99.laz

Output file 99.laz is inmediately deleted because is empty..

GUI las2las don't contemplate using of -keep_extended_class..

I can't attach you test file. I can't post the message if I include the file (about 18 MB).

Best regards.

las2las GUI.JPG

Martin Isenburg

unread,
Feb 4, 2021, 6:02:50 AM2/4/21
to LAStools - efficient command line tools for LIDAR processing
Hello,

please send me a link to your file stored in the cloud (or at least a
lasinfo report) so I can have a look:

http://rapidlasso.com/lasinfo

Regards,

Martin
> --
> Download LAStools at
> http://lastools.org
> http://rapidlasso.com
> Be social with LAStools at
> http://facebook.com/LAStools
> http://twitter.com/LAStools
> http://linkedin.com/groups/LAStools-4408378
> Manage your settings at
> http://groups.google.com/group/lastools/subscribe
> ---
> You received this message because you are subscribed to the Google Groups "LAStools - efficient tools for LiDAR processing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lastools+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lastools/13b063b8-bbc8-4b0e-bb4e-d93da7ff961fn%40googlegroups.com.

Tomás Cabezudo

unread,
Feb 4, 2021, 6:55:08 AM2/4/21
to LAStools - efficient tools for LiDAR processing
Hi Martin.

I attach you a lasinfo report for whole laz file, and a link to file..


Best regards.

info.txt

Martin Isenburg

unread,
Feb 4, 2021, 7:02:48 AM2/4/21
to LAStools - efficient command line tools for LIDAR processing
Hello,

that's an easy one. Although your file uses LAS version 1.4 the point
type that is stored is point type 1.

[...]
version major.minor: 1.4
[...]
point data format: 1
[...]

This point type only supports numbers from 0 to 31 for the
classification code that is stored with the five lower order bits of
one byte. The three higher order bits of the same byte are the three
flags synthetic, keypoint and withheld. You can see in the report how
your "higher than 31" numbers for classifications have activated these
flags.

+-> flagged as synthetic: 3283
+---> 380 of those are never classified (0)
+---> 2903 of those are low vegetation (3)
+-> flagged as keypoints: 2891
+---> 947 of those are low vegetation (3)
+---> 1944 of those are road surface (11)
+-> flagged as withheld: 42595
+---> 42595 of those are keypoint (8)

There is a way to go from point type 1 to point type 3 and reinterpret
these flags instead as classifications above 31. Is that something you
would want to do?

Regards,

Martin
> --
> Download LAStools at
> http://lastools.org
> http://rapidlasso.com
> Be social with LAStools at
> http://facebook.com/LAStools
> http://twitter.com/LAStools
> http://linkedin.com/groups/LAStools-4408378
> Manage your settings at
> http://groups.google.com/group/lastools/subscribe
> ---
> You received this message because you are subscribed to the Google Groups "LAStools - efficient tools for LiDAR processing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lastools+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lastools/d3c624bc-e673-4248-b76b-18a5d17381d0n%40googlegroups.com.

Tomás Cabezudo

unread,
Feb 4, 2021, 7:51:54 AM2/4/21
to LAStools - efficient tools for LiDAR processing
There is a way to go from point type 1 to point type 3 and reinterpret
these flags instead as classifications above 31. Is that something you
would want to do? 
 


Yes, that's rigth..

Regards..

Martin Isenburg

unread,
Feb 4, 2021, 8:35:28 AM2/4/21
to LAStools - efficient command line tools for LIDAR processing
Hello,

Here is your workflow. More ideas here:

https://groups.google.com/g/lastools/search?q=move_ancient_to_extended_classification

las2las -i Example_1_4.laz -set_point_type 6 -odix _pt6 -olaz

lasinfo -i Example_1_4_pt6.laz

las2las -i Example_1_4_pt6.laz
-move_ancient_to_extended_classification -odix _recovered -olaz

lasinfo -i Example_1_4_pt6_recovered.laz

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

lasinfo (210128) report for 'Example_1_4_pt6.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.4
system identifier: 'LAStools (c) by rapidlasso GmbH'
generating software: 'las2las (version 210128)'
file creation day/year: 31/2021
header size: 375
offset to point data: 743
number var. length records: 3
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: 467200.00 4805200.00 0.08
max x y z: 467399.99 4805399.99 136.35
start of waveform data packet record: 0
start of first extended variable length record: 17246112
number of extended_variable length records: 1
extended number of point records: 3347097
extended number of points by return: 2306116 697130 257436 70146
14005 2047 217 0 0 0 0 0 0 0 0
variable length header record 1 of 3:
reserved 43707
user ID 'LASF_Projection'
record ID 34735
length after header 120
description 'Georeferencing Information'
GeoKeyDirectoryTag version 1.1.0 number of keys 14
key 1024 tiff_tag_location 0 count 1 value_offset 1 -
GTModelTypeGeoKey: ModelTypeProjected
key 1026 tiff_tag_location 34737 count 14 value_offset 0 -
GTCitationGeoKey: GCS_ETRS_1989
key 2048 tiff_tag_location 0 count 1 value_offset 4258 -
GeographicTypeGeoKey: look-up for 4258 not implemented
key 2054 tiff_tag_location 0 count 1 value_offset 9102 -
GeogAngularUnitsGeoKey: Angular_Degree
key 2056 tiff_tag_location 0 count 1 value_offset 7019 -
GeogEllipsoidGeoKey: Ellipse_GRS_1980
key 2057 tiff_tag_location 34736 count 1 value_offset 0 -
GeogSemiMajorAxisGeoKey: 6378137
key 2058 tiff_tag_location 34736 count 1 value_offset 1 -
GeogSemiMinorAxisGeoKey: 6356752.314
key 2059 tiff_tag_location 34736 count 1 value_offset 2 -
GeogInvFlatteningGeoKey: 298.2572221
key 3072 tiff_tag_location 0 count 1 value_offset 3042 -
ProjectedCSTypeGeoKey: ETRS89 / UTM zone 30N (N-E)
key 3073 tiff_tag_location 34737 count 24 value_offset 14 -
PCSCitationGeoKey: ETRS89_UTM_zone_30N_N_E
key 3076 tiff_tag_location 0 count 1 value_offset 9001 -
ProjLinearUnitsGeoKey: Linear_Meter
key 4096 tiff_tag_location 0 count 1 value_offset 5030 -
VerticalCSTypeGeoKey: VertCS_WGS_84_ellipsoid
key 4097 tiff_tag_location 34737 count 24 value_offset 38 -
VerticalCitationGeoKey: VertCS_WGS_84_ellipsoid
key 4099 tiff_tag_location 0 count 1 value_offset 9001 -
VerticalUnitsGeoKey: Linear_Meter
variable length header record 2 of 3:
reserved 43707
user ID 'LASF_Projection'
record ID 34736
length after header 24
description 'Double Param Array'
GeoDoubleParamsTag (number of doubles 3)
6.37814e+006 6.35675e+006 298.257
variable length header record 3 of 3:
reserved 43707
user ID 'LASF_Projection'
record ID 34737
length after header 62
description 'GeoAsciiParamsTag'
GeoAsciiParamsTag (number of characters 62)
GCS_ETRS_1989|ETRS89_UTM_zone_30N_N_E|VertCS_WGS_84_ellipsoid|
extended variable length header record 1 of 1:
reserved 43707
user ID 'LASF_Projection'
record ID 2112
length after header 394
description 'WKT'
OGC COORDINATE SYSTEM WKT:
PROJCS["ETRS89_UTM_zone_30N_N_E",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Trans
verse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
LASzip compression (version 3.4r3 c3 50000): POINT14 3
reporting minimum and maximum for all LAS point record entries ...
X 46720000 46739999
Y 480520000 480539999
Z 8 13635
intensity 0 3859
return_number 1 7
number_of_returns 1 7
edge_of_flight_line 0 0
scan_direction_flag 0 1
classification 0 31
scan_angle_rank 0 7
user_data 0 0
point_source_ID 0 14
gps_time 0.000000 394596.075587
extended_return_number 1 7
extended_number_of_returns 1 7
extended_classification 0 31
extended_scan_angle 0 1167
extended_scanner_channel 0 0
number of first returns: 2306116
number of intermediate returns: 354134
number of last returns: 2281210
number of single returns: 1594363
overview over extended number of returns of given pulse: 1594363
875266 569238 232136 62880 11626 1588 0 0 0 0 0 0 0 0
histogram of classification of points:
380 never classified (0)
1120671 unclassified (1)
304011 ground (2)
1851987 low vegetation (3)
9587 medium vegetation (4)
1401 noise (7)
47226 keypoint (8)
6656 rail (10)
1944 road surface (11)
2097 overlap (12)
1032 Reserved for ASPRS Definition (28)
2 Reserved for ASPRS Definition (30)
103 Reserved for ASPRS Definition (31)
+-> flagged as synthetic: 3283
+---> 380 of those are never classified (0)
+---> 2903 of those are low vegetation (3)
+-> flagged as keypoints: 2891
+---> 947 of those are low vegetation (3)
+---> 1944 of those are road surface (11)
+-> flagged as withheld: 42595
+---> 42595 of those are keypoint (8)

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

lasinfo (210128) report for 'Example_1_4_pt6_recovered.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.4
system identifier: 'LAStools (c) by rapidlasso GmbH'
generating software: 'las2las (version 210128)'
file creation day/year: 31/2021
header size: 375
offset to point data: 743
number var. length records: 3
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: 467200.00 4805200.00 0.08
max x y z: 467399.99 4805399.99 136.35
start of waveform data packet record: 0
start of first extended variable length record: 17233915
number of extended_variable length records: 1
extended number of point records: 3347097
extended number of points by return: 2306116 697130 257436 70146
14005 2047 217 0 0 0 0 0 0 0 0
variable length header record 1 of 3:
reserved 43707
user ID 'LASF_Projection'
record ID 34735
length after header 120
description 'Georeferencing Information'
GeoKeyDirectoryTag version 1.1.0 number of keys 14
key 1024 tiff_tag_location 0 count 1 value_offset 1 -
GTModelTypeGeoKey: ModelTypeProjected
key 1026 tiff_tag_location 34737 count 14 value_offset 0 -
GTCitationGeoKey: GCS_ETRS_1989
key 2048 tiff_tag_location 0 count 1 value_offset 4258 -
GeographicTypeGeoKey: look-up for 4258 not implemented
key 2054 tiff_tag_location 0 count 1 value_offset 9102 -
GeogAngularUnitsGeoKey: Angular_Degree
key 2056 tiff_tag_location 0 count 1 value_offset 7019 -
GeogEllipsoidGeoKey: Ellipse_GRS_1980
key 2057 tiff_tag_location 34736 count 1 value_offset 0 -
GeogSemiMajorAxisGeoKey: 6378137
key 2058 tiff_tag_location 34736 count 1 value_offset 1 -
GeogSemiMinorAxisGeoKey: 6356752.314
key 2059 tiff_tag_location 34736 count 1 value_offset 2 -
GeogInvFlatteningGeoKey: 298.2572221
key 3072 tiff_tag_location 0 count 1 value_offset 3042 -
ProjectedCSTypeGeoKey: ETRS89 / UTM zone 30N (N-E)
key 3073 tiff_tag_location 34737 count 24 value_offset 14 -
PCSCitationGeoKey: ETRS89_UTM_zone_30N_N_E
key 3076 tiff_tag_location 0 count 1 value_offset 9001 -
ProjLinearUnitsGeoKey: Linear_Meter
key 4096 tiff_tag_location 0 count 1 value_offset 5030 -
VerticalCSTypeGeoKey: VertCS_WGS_84_ellipsoid
key 4097 tiff_tag_location 34737 count 24 value_offset 38 -
VerticalCitationGeoKey: VertCS_WGS_84_ellipsoid
key 4099 tiff_tag_location 0 count 1 value_offset 9001 -
VerticalUnitsGeoKey: Linear_Meter
variable length header record 2 of 3:
reserved 43707
user ID 'LASF_Projection'
record ID 34736
length after header 24
description 'Double Param Array'
GeoDoubleParamsTag (number of doubles 3)
6.37814e+006 6.35675e+006 298.257
variable length header record 3 of 3:
reserved 43707
user ID 'LASF_Projection'
record ID 34737
length after header 62
description 'GeoAsciiParamsTag'
GeoAsciiParamsTag (number of characters 62)
GCS_ETRS_1989|ETRS89_UTM_zone_30N_N_E|VertCS_WGS_84_ellipsoid|
extended variable length header record 1 of 1:
reserved 43707
user ID 'LASF_Projection'
record ID 2112
length after header 394
description 'WKT'
OGC COORDINATE SYSTEM WKT:
PROJCS["ETRS89_UTM_zone_30N_N_E",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Trans
verse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
LASzip compression (version 3.4r3 c3 50000): POINT14 3
reporting minimum and maximum for all LAS point record entries ...
X 46720000 46739999
Y 480520000 480539999
Z 8 13635
intensity 0 3859
return_number 1 7
number_of_returns 1 7
edge_of_flight_line 0 0
scan_direction_flag 0 1
classification 0 31
scan_angle_rank 0 7
user_data 0 0
point_source_ID 0 14
gps_time 0.000000 394596.075587
extended_return_number 1 7
extended_number_of_returns 1 7
extended_classification 1 136
extended_scan_angle 0 1167
extended_scanner_channel 0 0
number of first returns: 2306116
number of intermediate returns: 354134
number of last returns: 2281210
number of single returns: 1594363
overview over extended number of returns of given pulse: 1594363
875266 569238 232136 62880 11626 1588 0 0 0 0 0 0 0 0
histogram of classification of points:
1120671 unclassified (1)
304011 ground (2)
1849084 low vegetation (3)
9587 medium vegetation (4)
1401 noise (7)
4631 keypoint (8)
6656 rail (10)
2097 overlap (12)
1032 Reserved for ASPRS Definition (28)
2 Reserved for ASPRS Definition (30)
103 Reserved for ASPRS Definition (31)
histogram of extended classification of points:
380 extended classification (32)
1956 extended classification (35)
1944 extended classification (75)
947 extended classification (99)
42595 extended classification (136)
Reply all
Reply to author
Forward
0 new messages