Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Re-saving LAS file removes meta-data (.las .laz) #515

Closed
dbworth opened this Issue Mar 3, 2017 · 5 comments

Comments

Projects
None yet
2 participants

dbworth commented Mar 3, 2017

Thanks for the great open-source tool!

Current Behavior

When I open a .las file in CloudCompare and then immediately re-save the cloud as a .las file, lots of the meta-data is removed with no warning.
For example, if the .las file was georeferenced with a datum (e.g. "this is my location in the world"), this is removed and this affects processing files for GIS applications.

Expected Behavior

The header and meta-data should be written back out again, the same.

Steps to Reproduce

To verify this you need a geo-tagged LiDAR cloud from the DEM section here: https://earthexplorer.usgs.gov/
I can upload a sample file somewhere if you like.

For the original file, use the lasinfo tool (http://lastools.org/download/LAStools.zip) to view the meta-data. Then load the .las file in CloudCompare and re-save it. Use lasinfo again to see the meta-data has been changed.

Below is included a full screen dump.

Context/Comments

I'm not sure what LAS library is being used. Perhaps at a minimum, CloudCompare should warn "stripping LAS meta-data".
A nice example is MeshLab that when you re-save a mesh file, it prompts you for Binary VS. ASCII, Color Vs. no-color, etc.

Your Environment

Windows 7 64-bit.
CloudCompare 2.8 beta

.

This is the meta-data of original file

>lasinfo PA_Statewide_S_2006-2008_003435.las

lasinfo (161016) report for PA_Statewide_S_2006-2008_003435.las
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:          'NIIRS10'
  generating software:        'LIDAR1 tiled'
  file creation day/year:     270/2008
  header size:                227
  offset to point data:       2103
  number var. length records: 5
  point data format:          1
  point data record length:   28
  number of point records:    3555744
  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:                  1360000.01 410000.01 799.74
  max x y z:                  1370000.00 420000.00 1231.85
variable length header record 1 of 5:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34735
  length after header  192
  description          'GeoTiff Projection Keys'
    GeoKeyDirectoryTag version 1.1.0 number of keys 23
      key 1024 tiff_tag_location 0 count 1 value_offset 1 - GTModelTypeGeoKey: M
odelTypeProjected
      key 2048 tiff_tag_location 0 count 1 value_offset 4269 - GeographicTypeGeo
Key: GCS_NAD83
      key 2049 tiff_tag_location 34737 count 24 value_offset 54 - GeogCitationGe
oKey: GCS_North_American_1983
      key 2050 tiff_tag_location 0 count 1 value_offset 6269 - GeogGeodeticDatum
GeoKey: Datum_North_American_Datum_1983
      key 2051 tiff_tag_location 0 count 1 value_offset 8901 - GeogPrimeMeridian
GeoKey: PM_Greenwich
      key 2054 tiff_tag_location 0 count 1 value_offset 9102 - GeogAngularUnitsG
eoKey: Angular_Degree
      key 2055 tiff_tag_location 34736 count 1 value_offset 11 - GeogAngularUnit
SizeGeoKey: 0.01745329252
      key 2056 tiff_tag_location 0 count 1 value_offset 7019 - GeogEllipsoidGeoK
ey: Ellipse_GRS_1980
      key 2057 tiff_tag_location 34736 count 1 value_offset 8 - GeogSemiMajorAxi
sGeoKey: 6378137
      key 2059 tiff_tag_location 34736 count 1 value_offset 9 - GeogInvFlattenin
gGeoKey: 298.2572221
      key 2061 tiff_tag_location 34736 count 1 value_offset 10 - GeogPrimeMeridi
anLongGeoKey: 0
      key 3072 tiff_tag_location 0 count 1 value_offset 32129 - ProjectedCSTypeG
eoKey: NAD83 / Pennsylvania South
      key 3073 tiff_tag_location 34737 count 54 value_offset 0 - PCSCitationGeoK
ey: NAD_1983_StatePlane_Pennsylvania_South_FIPS_3702_Feet
      key 3075 tiff_tag_location 0 count 1 value_offset 8 - ProjCoordTransGeoKey
: CT_LambertConfConic_2SP
      key 3076 tiff_tag_location 0 count 1 value_offset 9003 - ProjLinearUnitsGe
oKey: Linear_Foot_US_Survey
      key 3077 tiff_tag_location 34736 count 1 value_offset 7 - ProjLinearUnitSi
zeGeoKey: 0.3048006096
      key 3078 tiff_tag_location 34736 count 1 value_offset 3 - ProjStdParallel1
GeoKey: 39.93333333
      key 3079 tiff_tag_location 34736 count 1 value_offset 4 - ProjStdParallel2
GeoKey: 40.96666667
      key 3081 tiff_tag_location 34736 count 1 value_offset 6 - ProjNatOriginLat
GeoKey: 39.33333333
      key 3082 tiff_tag_location 34736 count 1 value_offset 0 - ProjFalseEasting
GeoKey: 1968500
      key 3083 tiff_tag_location 34736 count 1 value_offset 1 - ProjFalseNorthin
gGeoKey: 0
      key 3088 tiff_tag_location 34736 count 1 value_offset 2 - ProjCenterLongGe
oKey: -77.75
      key 3093 tiff_tag_location 34736 count 1 value_offset 5 - ProjScaleAtCente
rGeoKey: 0
variable length header record 2 of 5:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34736
  length after header  96
  description          'GeoTiff double parameters'
    GeoDoubleParamsTag (number of doubles 12)
      1.9685e+006 0 -77.75 39.9333 40.9667 0 39.3333 0.304801 6.37814e+006 298.2
57 0 0.0174533
variable length header record 3 of 5:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34737
  length after header  78
  description          'GeoTiff ASCII parameters'
    GeoAsciiParamsTag (number of characters 78)
      NAD_1983_StatePlane_Pennsylvania_South_FIPS_3702_Feet|GCS_North_American_1
983|
variable length header record 4 of 5:
  reserved             43707
  user ID              'NIIRS10'
  record ID            4
  length after header  10
  description          'NIIRS10 Timestamp'
variable length header record 5 of 5:
  reserved             43707
  user ID              'NIIRS10'
  record ID            1
  length after header  26
  description          'NIIRS10 Tile Index'
the header is followed by 1204 user-defined bytes
reporting minimum and maximum for all LAS point record entries ...
  X           136000001  137000000
  Y            41000001   42000000
  Z               79974     123185
  intensity           0        255
  return_number       1          2
  number_of_returns   1          2
  edge_of_flight_line 0          0
  scan_direction_flag 0          0
  classification      1         15
  scan_angle_rank     0          0
  user_data           0          0
  point_source_ID    52         55
  gps_time 0.000000 0.000000
number of first returns:        2994245
number of intermediate returns: 0
number of last returns:         2957224
number of single returns:       2395725
WARNING: for return 1 real number of points by return is 2994245 but header entr
y was not set.
WARNING: for return 2 real number of points by return is 561499 but header entry
 was not set.
overview over number of returns of given pulse: 2395725 1160019 0 0 0 0 0
histogram of classification of points:
         1075294  unclassified (1)
         1496896  ground (2)
          317693  keypoint (8)
             355  water (9)
          598520  overlap (12)
           66986  tower (15)

.

This is the meta-data of the file re-saved with CloudCompare


>lasinfo PA_Statewide_S_2006-2008_003435_resaved.las

lasinfo (161016) report for PA_Statewide_S_2006-2008_003435_resaved.las
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.2
  system identifier:          'libLAS'
  generating software:        'libLAS 1.8.0'
  file creation day/year:     61/2017
  header size:                227
  offset to point data:       227
  number var. length records: 0
  point data format:          3
  point data record length:   34
  number of point records:    3555744
  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:               1360000.0099999998 410000.009765625 799.7399902343
75
  min x y z:                  1360000.01 410000.01 799.74
  max x y z:                  1370000.00 420000.00 1231.85
reporting minimum and maximum for all LAS point record entries ...
  X                   0     999999
  Y                   0     999999
  Z                   0      43211
  intensity           0        255
  return_number       1          2
  number_of_returns   1          2
  edge_of_flight_line 0          0
  scan_direction_flag 0          0
  classification      1         15
  scan_angle_rank     0          0
  user_data           0          0
  point_source_ID    52         55
  gps_time 0.000000 0.000000
  Color R 0 0
        G 0 0
        B 0 0
number of first returns:        2994245
number of intermediate returns: 0
number of last returns:         2957224
number of single returns:       2395725
WARNING: for return 1 real number of points by return is 2994245 but header entr
y was not set.
WARNING: for return 2 real number of points by return is 561499 but header entry
 was not set.
overview over number of returns of given pulse: 2395725 1160019 0 0 0 0 0
histogram of classification of points:
         1075294  unclassified (1)
         1496896  ground (2)
          317693  keypoint (8)
             355  water (9)
          598520  overlap (12)
           66986  tower (15)
Owner

dgirardeau commented Mar 4, 2017

Indeed, CC doesn't handle LAS meta-data at all. We use libLAS (for now), but I don't know how easy to extract or push these pieces of information when loading and saving a file.

I'll see what I can do, otherwise I'll add a warning message as suggested.

dgirardeau self-assigned this Mar 4, 2017

Owner

dgirardeau commented Mar 5, 2017

I've updated the online 2.9 beta version: the 'Spatial Reference System' (SRS) of the LAS file is now saved as meta-data and exported (if available) when saving the cloud as a new file.

I'm just not sure that the SRS contains everything... Can you test it on your side and see if any important stuff is missing?

Owner

dgirardeau commented Mar 6, 2017

Note that I uploaded the wrong version yesterday ;). It's should now be ok.

dbworth commented Mar 8, 2017

Thanks for your quick response, that's great. It works nicely. :-)

Long answer:
I tried the 2.9 beta with Windows 64-bit.
I opened an aerial LiDAR tile in .las format in CloudCompare,
then did a small segment (crop) operation,
then re-saved as a .las file.

Then I opened the .las file in another program (e.g. QGIS) and it is shown correctly, and in the right location of the world.

Also I was able to merge (combine) two LiDAR tiles using CloudCompare, and then save them as one .las file with the correct geo-reference data.

.

How to merge LiDAR tiles with GeoTIFF data:

My guess is that this will only work if the tiles have the same datum/projection, are are simply offset from each other.

Drag the two .las files into CloudCompare, which loads them in their correct relative location next to each other:
01_open_lidar_tiles

Drag the cloud from one object into the other:
02_put_clouds_together

Select both clouds and use the merge tool:
03_merge_clouds

Re-save the merged cloud as a .las file:
04_final_cloud

Done!

.

Also, here is the meta-data that CloudCompare 2.9 beta writes out when saving a .las file.
It's not all the meta-data, but at least it includes the GeoTIFF tags, which contains the global location and projection information:

>lasinfo PA_Statewide_S_2006-2008_003435_resaved_new_Beta.las

lasinfo (161016) report for temp_resaved.las
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.2
  system identifier:          'libLAS'
  generating software:        'libLAS 1.8.0'
  file creation day/year:     65/2017
  header size:                227
  offset to point data:       755
  number var. length records: 3
  point data format:          3
  point data record length:   34
  number of point records:    3409902
  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:               1350000.0099999998 410000.009765625 709.3300170898
4375
  min x y z:                  1350000.01 410000.01 709.33
  max x y z:                  1360000.00 420000.00 1762.37
variable length header record 1 of 3:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34735
  length after header  192
  description          'GeoTiff Projection Keys'
    GeoKeyDirectoryTag version 1.1.0 number of keys 23
      key 1024 tiff_tag_location 0 count 1 value_offset 1 - GTModelTypeGeoKey: M
odelTypeProjected
      key 2048 tiff_tag_location 0 count 1 value_offset 4269 - GeographicTypeGeo
Key: GCS_NAD83
      key 2049 tiff_tag_location 34737 count 24 value_offset 54 - GeogCitationGe
oKey: GCS_North_American_1983
      key 2050 tiff_tag_location 0 count 1 value_offset 6269 - GeogGeodeticDatum
GeoKey: Datum_North_American_Datum_1983
      key 2051 tiff_tag_location 0 count 1 value_offset 8901 - GeogPrimeMeridian
GeoKey: PM_Greenwich
      key 2054 tiff_tag_location 0 count 1 value_offset 9102 - GeogAngularUnitsG
eoKey: Angular_Degree
      key 2055 tiff_tag_location 34736 count 1 value_offset 11 - GeogAngularUnit
SizeGeoKey: 0.01745329252
      key 2056 tiff_tag_location 0 count 1 value_offset 7019 - GeogEllipsoidGeoK
ey: Ellipse_GRS_1980
      key 2057 tiff_tag_location 34736 count 1 value_offset 8 - GeogSemiMajorAxi
sGeoKey: 6378137
      key 2059 tiff_tag_location 34736 count 1 value_offset 9 - GeogInvFlattenin
gGeoKey: 298.2572221
      key 2061 tiff_tag_location 34736 count 1 value_offset 10 - GeogPrimeMeridi
anLongGeoKey: 0
      key 3072 tiff_tag_location 0 count 1 value_offset 32129 - ProjectedCSTypeG
eoKey: NAD83 / Pennsylvania South
      key 3073 tiff_tag_location 34737 count 54 value_offset 0 - PCSCitationGeoK
ey: NAD_1983_StatePlane_Pennsylvania_South_FIPS_3702_Feet
      key 3075 tiff_tag_location 0 count 1 value_offset 8 - ProjCoordTransGeoKey
: CT_LambertConfConic_2SP
      key 3076 tiff_tag_location 0 count 1 value_offset 9003 - ProjLinearUnitsGe
oKey: Linear_Foot_US_Survey
      key 3077 tiff_tag_location 34736 count 1 value_offset 7 - ProjLinearUnitSi
zeGeoKey: 0.3048006096
      key 3078 tiff_tag_location 34736 count 1 value_offset 3 - ProjStdParallel1
GeoKey: 39.93333333
      key 3079 tiff_tag_location 34736 count 1 value_offset 4 - ProjStdParallel2
GeoKey: 40.96666667
      key 3081 tiff_tag_location 34736 count 1 value_offset 6 - ProjNatOriginLat
GeoKey: 39.33333333
      key 3082 tiff_tag_location 34736 count 1 value_offset 0 - ProjFalseEasting
GeoKey: 1968500
      key 3083 tiff_tag_location 34736 count 1 value_offset 1 - ProjFalseNorthin
gGeoKey: 0
      key 3088 tiff_tag_location 34736 count 1 value_offset 2 - ProjCenterLongGe
oKey: -77.75
      key 3093 tiff_tag_location 34736 count 1 value_offset 5 - ProjScaleAtCente
rGeoKey: 0
variable length header record 2 of 3:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34736
  length after header  96
  description          'GeoTiff double parameters'
    GeoDoubleParamsTag (number of doubles 12)
      1.9685e+006 0 -77.75 39.9333 40.9667 0 39.3333 0.304801 6.37814e+006 298.2
57 0 0.0174533
variable length header record 3 of 3:
  reserved             43707
  user ID              'LASF_Projection'
  record ID            34737
  length after header  78
  description          'GeoTiff ASCII parameters'
    GeoAsciiParamsTag (number of characters 78)
      NAD_1983_StatePlane_Pennsylvania_South_FIPS_3702_Feet|GCS_North_American_1
983|
reporting minimum and maximum for all LAS point record entries ...
  X                   0     999999
  Y                   0     999999
  Z                   0     105304
  intensity           0        255
  return_number       1          2
  number_of_returns   1          2
  edge_of_flight_line 0          0
  scan_direction_flag 0          0
  classification      1         15
  scan_angle_rank     0          0
  user_data           0          0
  point_source_ID    52         55
  gps_time 0.000000 0.000000
  Color R 0 0
        G 0 0
        B 0 0
number of first returns:        2973320
number of intermediate returns: 0
number of last returns:         2945605
number of single returns:       2509023
WARNING: for return 1 real number of points by return is 2973320 but header entr
y was not set.
WARNING: for return 2 real number of points by return is 436582 but header entry
 was not set.
overview over number of returns of given pulse: 2509023 900879 0 0 0 0 0
histogram of classification of points:
         1135712  unclassified (1)
         1411257  ground (2)
          336295  keypoint (8)
             372  water (9)
          464297  overlap (12)
           61969  tower (15)

I'm happy for this issue to be closed.

Owner

dgirardeau commented Mar 8, 2017

Great. Thanks for the feedback!

dgirardeau closed this Mar 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment