LAS header bounding box incompatible with point coordinates can cause issues

88 views
Skip to first unread message

Martin Isenburg

unread,
Oct 14, 2017, 7:32:18 AM10/14/17
to LAStools - efficient command line tools for LIDAR processing
Hello,

I've had an interesting bug report about an in-explainable crash of lasthin when running a simple

lasthin.exe -i 20170526_0925_12504_0_188448_2016.laz -step 0.4 -odix _t -olaz 

That was a tricky one. It was because the LAZ file had two points that are just a fraction of a scale factor unit outside of the bounding box. In this file the double-floating-point bounding box is stored with more decimal digit precision than the data and is slightly smaller than the actual data that only has just two decimal digits (centimeter). Only after rounding to two digits it properly encloses the data.

lasreader->header.min_x 2572038.4765800
lasreader->header.max_x 2572963.4301116
lasreader->header.min_y 1175234.0437131
lasreader->header.max_y 1176918.4151989

Because this is not easily detected, I am adding a new set of WARNING outputs to the next version of lasinfo that will make this more clear. In the future you can expect this to appear in a lasinfo report of such a file so the source of the crash (lasthin relies on correct bounding box information in this case) can be tracked down more easily:

WARNING: full resolution of min_x not compatible with x_offset and x_scale_factor: 2572038.47658
WARNING: full resolution of min_y not compatible with y_offset and y_scale_factor: 1175234.0437131
WARNING: full resolution of max_x not compatible with x_offset and x_scale_factor: 2572963.4301116
WARNING: full resolution of max_y not compatible with y_offset and y_scale_factor: 1176918.4151989

In this particular case the file could be easily fixed *in-place* with:

E:\LAStools\bin>lasinfo -i 20170526_0925_12504_0_188448_2016.laz -repair_bb

Some more complex cases (because of bad header offsets with many more decimal digits than the coordinates) may need fixing like that

E:\LAStools\bin>las2las -i 20170526_0925_12504_0_188448_2016.laz -auto_reoffset -odix _fixed -olaz

Below the corresponing lasinfo reports in case you are interested in the details.

Regards.

Martin @rapidlasso

++++++++++++++++++++++++++++++++++++++++++++
+++  ORIGINAL FILE
++++++++++++++++++++++++++++++++++++++++++++

E:\LAStools\bin>lasinfo -i 20170526_0925_12504_0_188448_2016.laz
lasinfo (171011) report for 20170526_0925_12504_0_188448_2016.laz
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             0
  global_encoding:            1
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.2
  system identifier:          'Semi-Global Matching'
  generating software:        'XPro SGM'
  file creation day/year:     244/2017
  header size:                227
  offset to point data:       477
  number var. length records: 3
  point data format:          1
  point data record length:   28
  number of point records:    140843518
  number of points by return: 140843518 0 0 0 0
  scale factor x y z:         0.01 0.01 0.01
  offset x y z:               2572963 1175259 752
  min x y z:                  2572038.48 1175234.04 677.00
  max x y z:                  2572963.43 1176918.42 753.84
variable length header record 1 of 3:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34735
  length after header  32
  description          'GeoTIFF GeoKeyDirectoryTag'
    GeoKeyDirectoryTag version 1.1.0 number of keys 3
      key 1025 tiff_tag_location 0 count 1 value_offset 1 - GTRasterTypeGeoKey: RasterPixelIsArea
      key 4097 tiff_tag_location 34737 count 17 value_offset 0 - VerticalCitationGeoKey: CHGeo2004 Bessel
      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            34737
  length after header  18
  description          'GeoTIFF GeoAsciiParamsTag'
    GeoAsciiParamsTag (number of characters 18)
      CHGeo2004 Bessel|
variable length header record 3 of 3:
  reserved             43707
  user ID              'liblas'
  record ID            2112
  length after header  38
  description          'OGR variant of OpenGIS WKT SRS'
LASzip compression (version 2.1r0 c2 50000): POINT10 2 GPSTIME11 2
reporting minimum and maximum for all LAS point record entries ...
  X              -92452         43
  Y               -2496     165942
  Z               -7500        184
  intensity        1192      35751
  return_number       1          1
  number_of_returns   1          1
  edge_of_flight_line 0          0
  scan_direction_flag 1          1
  classification      0          0
  scan_angle_rank   -18          0
  user_data           0          0
  point_source_ID     0          0
  gps_time 179826124.437066 179826132.645889
WARNING: 2 points outside of header bounding box
number of first returns:        140843518
number of intermediate returns: 0
number of last returns:         140843518
number of single returns:       140843518
overview over number of returns of given pulse: 140843518 0 0 0 0 0 0
histogram of classification of points:
       140843518  never classified (0)
real max y larger than header max y by 0.004801
real min y smaller than header min y by 0.003713

++++++++++++++++++++++++++++++++++++++++++++
+++  ORIGINAL FILE (with report of outside points)
++++++++++++++++++++++++++++++++++++++++++++

E:\LAStools\bin>lasinfo -i 20170526_0925_12504_0_188448_2016.laz -report_outside
lasinfo (171011) report for 20170526_0925_12504_0_188448_2016.laz
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             0
  global_encoding:            1
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.2
  system identifier:          'Semi-Global Matching'
  generating software:        'XPro SGM'
  file creation day/year:     244/2017
  header size:                227
  offset to point data:       477
  number var. length records: 3
  point data format:          1
  point data record length:   28
  number of point records:    140843518
  number of points by return: 140843518 0 0 0 0
  scale factor x y z:         0.01 0.01 0.01
  offset x y z:               2572963 1175259 752
  min x y z:                  2572038.48 1175234.04 677.00
  max x y z:                  2572963.43 1176918.42 753.84
variable length header record 1 of 3:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34735
  length after header  32
  description          'GeoTIFF GeoKeyDirectoryTag'
    GeoKeyDirectoryTag version 1.1.0 number of keys 3
      key 1025 tiff_tag_location 0 count 1 value_offset 1 - GTRasterTypeGeoKey: RasterPixelIsArea
      key 4097 tiff_tag_location 34737 count 17 value_offset 0 - VerticalCitationGeoKey: CHGeo2004 Bessel
      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            34737
  length after header  18
  description          'GeoTIFF GeoAsciiParamsTag'
    GeoAsciiParamsTag (number of characters 18)
      CHGeo2004 Bessel|
variable length header record 3 of 3:
  reserved             43707
  user ID              'liblas'
  record ID            2112
  length after header  38
  description          'OGR variant of OpenGIS WKT SRS'
LASzip compression (version 2.1r0 c2 50000): POINT10 2 GPSTIME11 2
reporting minimum and maximum for all LAS point record entries ...
43581478 t 1.79826e+008 x 2.57271e+006 y 1.17692e+006 z 705.46 i 4792 (1 of 1) d 1 e 0 c 0 s -18 0 p 0
59427019 t 1.79826e+008 x 2.57249e+006 y 1.17523e+006 z 677.68 i 4704 (1 of 1) d 1 e 0 c 0 s -18 0 p 0
  X              -92452         43
  Y               -2496     165942
  Z               -7500        184
  intensity        1192      35751
  return_number       1          1
  number_of_returns   1          1
  edge_of_flight_line 0          0
  scan_direction_flag 1          1
  classification      0          0
  scan_angle_rank   -18          0
  user_data           0          0
  point_source_ID     0          0
  gps_time 179826124.437066 179826132.645889
WARNING: 2 points outside of header bounding box
number of first returns:        140843518
number of intermediate returns: 0
number of last returns:         140843518
number of single returns:       140843518
overview over number of returns of given pulse: 140843518 0 0 0 0 0 0
histogram of classification of points:
       140843518  never classified (0)
real max y larger than header max y by 0.004801
real min y smaller than header min y by 0.003713

++++++++++++++++++++++++++++++++++++++++++++
+++  BOUNDING-BOX-REPAIRED FILE (with lasinfo)
++++++++++++++++++++++++++++++++++++++++++++

E:\LAStools\bin>lasinfo -i 20170526_0925_12504_0_188448_2016.laz
lasinfo (171011) report for 20170526_0925_12504_0_188448_2016.laz
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             0
  global_encoding:            1
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.2
  system identifier:          'Semi-Global Matching'
  generating software:        'XPro SGM'
  file creation day/year:     244/2017
  header size:                227
  offset to point data:       477
  number var. length records: 3
  point data format:          1
  point data record length:   28
  number of point records:    140843518
  number of points by return: 140843518 0 0 0 0
  scale factor x y z:         0.01 0.01 0.01
  offset x y z:               2572963 1175259 752
  min x y z:                  2572038.48 1175234.04 677.00
  max x y z:                  2572963.43 1176918.42 753.84
variable length header record 1 of 3:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34735
  length after header  32
  description          'GeoTIFF GeoKeyDirectoryTag'
    GeoKeyDirectoryTag version 1.1.0 number of keys 3
      key 1025 tiff_tag_location 0 count 1 value_offset 1 - GTRasterTypeGeoKey: RasterPixelIsArea
      key 4097 tiff_tag_location 34737 count 17 value_offset 0 - VerticalCitationGeoKey: CHGeo2004 Bessel
      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            34737
  length after header  18
  description          'GeoTIFF GeoAsciiParamsTag'
    GeoAsciiParamsTag (number of characters 18)
      CHGeo2004 Bessel|
variable length header record 3 of 3:
  reserved             43707
  user ID              'liblas'
  record ID            2112
  length after header  38
  description          'OGR variant of OpenGIS WKT SRS'
LASzip compression (version 2.1r0 c2 50000): POINT10 2 GPSTIME11 2
reporting minimum and maximum for all LAS point record entries ...
  X              -92452         43
  Y               -2496     165942
  Z               -7500        184
  intensity        1192      35751
  return_number       1          1
  number_of_returns   1          1
  edge_of_flight_line 0          0
  scan_direction_flag 1          1
  classification      0          0
  scan_angle_rank   -18          0
  user_data           0          0
  point_source_ID     0          0
  gps_time 179826124.437066 179826132.645889
number of first returns:        140843518
number of intermediate returns: 0
number of last returns:         140843518
number of single returns:       140843518
overview over number of returns of given pulse: 140843518 0 0 0 0 0 0
histogram of classification of points:
       140843518  never classified (0)

++++++++++++++++++++++++++++++++++++++++++++
+++  AUTO-REOFFSET FILE (with las2las)
++++++++++++++++++++++++++++++++++++++++++++

lasinfo -i 20170526_0925_12504_0_188448_2016_fixed.laz
lasinfo (171011) report for 20170526_0925_12504_0_188448_2016_fixed.laz
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             0
  global_encoding:            1
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.2
  system identifier:          'LAStools (c) by rapidlasso GmbH'
  generating software:        'las2las (version 171011)'
  file creation day/year:     244/2017
  header size:                227
  offset to point data:       477
  number var. length records: 3
  point data format:          1
  point data record length:   28
  number of point records:    140843518
  number of points by return: 140843518 0 0 0 0
  scale factor x y z:         0.01 0.01 0.01
  offset x y z:               2500000 1100000 0
  min x y z:                  2572038.48 1175234.04 677.00
  max x y z:                  2572963.43 1176918.42 753.84
variable length header record 1 of 3:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34735
  length after header  32
  description          'GeoTIFF GeoKeyDirectoryTag'
    GeoKeyDirectoryTag version 1.1.0 number of keys 3
      key 1025 tiff_tag_location 0 count 1 value_offset 1 - GTRasterTypeGeoKey: RasterPixelIsArea
      key 4097 tiff_tag_location 34737 count 17 value_offset 0 - VerticalCitationGeoKey: CHGeo2004 Bessel
      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            34737
  length after header  18
  description          'GeoTIFF GeoAsciiParamsTag'
    GeoAsciiParamsTag (number of characters 18)
      CHGeo2004 Bessel|
variable length header record 3 of 3:
  reserved             43707
  user ID              'liblas'
  record ID            2112
  length after header  38
  description          'OGR variant of OpenGIS WKT SRS'
LASzip compression (version 3.1r0 c2 50000): POINT10 2 GPSTIME11 2
reporting minimum and maximum for all LAS point record entries ...
  X             7203848    7296343
  Y             7523404    7691842
  Z               67700      75384
  intensity        1192      35751
  return_number       1          1
  number_of_returns   1          1
  edge_of_flight_line 0          0
  scan_direction_flag 1          1
  classification      0          0
  scan_angle_rank   -18          0
  user_data           0          0
  point_source_ID     0          0
  gps_time 179826124.437066 179826132.645889
number of first returns:        140843518
number of intermediate returns: 0
number of last returns:         140843518
number of single returns:       140843518
overview over number of returns of given pulse: 140843518 0 0 0 0 0 0
histogram of classification of points:
       140843518  never classified (0)
Reply all
Reply to author
Forward
0 new messages