I have a point cloud with extra attributes:
class : LAS (LASFˇ v1.4)
point format : 6
memory : 2 Gb
extent :7498400, 7499200, 5779500, 5780000 (xmin, xmax, ymin, ymax)
coord. ref. : NA
area : 399973.7 units² (convex hull)
points : 19517984 points
density : 48.8 points/units²
names : X Y Z gpstime Intensity ReturnNumber NumberOfReturns ScanDirectionFlag EdgeOfFlightline Classification ScannerChannel Synthetic_flag Keypoint_flag Withheld_flag Overlap_flag ScanAngle UserData PointSourceID Amplitude Reflectance Deviation
File signature: LASFˇ
File source ID: 4001
Project ID - GUID: df4425f5-d89d-437c-baa3-cd71726ed8c6
Version: 1.4
System identifier: LAStools (c) by rapidlasso GmbH
Generating software: lasheight (190321) commercial
File creation d/y: 267/2018
header size: 375
Offset to point data: 2238
Num. var. length record: 5
Point data format: 6
Point data record length: 36
Num. of point records: 19517984
Num. of points by return:
Scale factor X Y Z: 0.01 0.01 0.01
Offset X Y Z: 0 0 0
min X Y Z: 7498400 5779500 -1.17
max X Y Z: 7499200 5780000 25.94
Variable length records:
Variable length record 1 of 5
Description: GeoKeyDirectoryTag (mandatory)
Tags:
Key 1024 tiff_tag_location 0 count 1 value offset 1
Key 1025 tiff_tag_location 0 count 1 value offset 2
Key 1026 tiff_tag_location 34737 count 13 value offset 0
Key 2048 tiff_tag_location 0 count 1 value offset 32767
Key 2049 tiff_tag_location 34737 count 7 value offset 26
Key 2050 tiff_tag_location 0 count 1 value offset 32767
Key 2051 tiff_tag_location 0 count 1 value offset 32767
Key 2052 tiff_tag_location 0 count 1 value offset 9001
Key 2054 tiff_tag_location 0 count 1 value offset 9102
Key 2056 tiff_tag_location 0 count 1 value offset 32767
Key 2057 tiff_tag_location 34736 count 1 value offset 0
Key 2059 tiff_tag_location 34736 count 1 value offset 1
Key 2060 tiff_tag_location 0 count 1 value offset 9102
Key 2061 tiff_tag_location 34736 count 1 value offset 2
Key 3072 tiff_tag_location 0 count 1 value offset 32767
Key 3073 tiff_tag_location 34737 count 13 value offset 13
Key 3074 tiff_tag_location 0 count 1 value offset 32767
Key 3075 tiff_tag_location 0 count 1 value offset 1
Key 3076 tiff_tag_location 0 count 1 value offset 9001
Key 3080 tiff_tag_location 34736 count 1 value offset 4
Key 3081 tiff_tag_location 34736 count 1 value offset 3
Key 3082 tiff_tag_location 34736 count 1 value offset 5
Key 3083 tiff_tag_location 34736 count 1 value offset 6
Key 3092 tiff_tag_location 34736 count 1 value offset 7
Key 4099 tiff_tag_location 0 count 1 value offset 9001
Variable length record 2 of 5
Description: GeoDoubleParamsTag (optional)
data: 6378137 298.2572 0 0 21 7500000 0 0.999923
Variable length record 3 of 5
Description: GeoASCIIParamsTag (optional)
data: Poland2000s7|Poland2000s7|ETRS89|
Variable length record 4 of 5
Description: OGC COORDINATE SYSTEM WKT
Variable length record 5 of 5
Description: RIEGL Extra Bytes
Extra Bytes Description:
Amplitude: Echo signal amplitude [dB]
Reflectance: Echo signal reflectance [dB]
Deviation: Pulse shape deviation
When I check Classification attribute:
> max(las@data$Classification)
[1] 5
I have also a TIF raster with treeIDs. I am using following algorithm to assign treeIDs to point cloud:
las_tree = lasmergespatial(las, tif_crop, "treeID")
treeID = las_tree@data[["treeID"]]
treeID = as.numeric(treeID)
las_tree = lasaddextrabytes(las_tree, x=treeID, name="treeID", desc="ID of a tree")
Now, las_tree has summary:
class : LAS (LASFˇ v1.4)
point format : 6
memory : 2.2 Gb
extent :7498400, 7499200, 5779500, 5780000 (xmin, xmax, ymin, ymax)
coord. ref. : NA
area : 399973.7 units² (convex hull)
points : 19517984 points
density : 48.8 points/units²
names : X Y Z gpstime Intensity ReturnNumber NumberOfReturns ScanDirectionFlag EdgeOfFlightline Classification ScannerChannel Synthetic_flag Keypoint_flag Withheld_flag Overlap_flag ScanAngle UserData PointSourceID Amplitude Reflectance Deviation treeID
File signature: LASFˇ
File source ID: 4001
Project ID - GUID: df4425f5-d89d-437c-baa3-cd71726ed8c6
Version: 1.4
System identifier: LAStools (c) by rapidlasso GmbH
Generating software: lasheight (190321) commercial
File creation d/y: 267/2018
header size: 375
Offset to point data: 2238
Num. var. length record: 5
Point data format: 6
Point data record length: 36
Num. of point records: 19517984
Num. of points by return:
Scale factor X Y Z: 0.01 0.01 0.01
Offset X Y Z: 0 0 0
min X Y Z: 7498400 5779500 -1.17
max X Y Z: 7499200 5780000 25.94
Variable length records:
Variable length record 1 of 5
Description: GeoKeyDirectoryTag (mandatory)
Tags:
Key 1024 tiff_tag_location 0 count 1 value offset 1
Key 1025 tiff_tag_location 0 count 1 value offset 2
Key 1026 tiff_tag_location 34737 count 13 value offset 0
Key 2048 tiff_tag_location 0 count 1 value offset 32767
Key 2049 tiff_tag_location 34737 count 7 value offset 26
Key 2050 tiff_tag_location 0 count 1 value offset 32767
Key 2051 tiff_tag_location 0 count 1 value offset 32767
Key 2052 tiff_tag_location 0 count 1 value offset 9001
Key 2054 tiff_tag_location 0 count 1 value offset 9102
Key 2056 tiff_tag_location 0 count 1 value offset 32767
Key 2057 tiff_tag_location 34736 count 1 value offset 0
Key 2059 tiff_tag_location 34736 count 1 value offset 1
Key 2060 tiff_tag_location 0 count 1 value offset 9102
Key 2061 tiff_tag_location 34736 count 1 value offset 2
Key 3072 tiff_tag_location 0 count 1 value offset 32767
Key 3073 tiff_tag_location 34737 count 13 value offset 13
Key 3074 tiff_tag_location 0 count 1 value offset 32767
Key 3075 tiff_tag_location 0 count 1 value offset 1
Key 3076 tiff_tag_location 0 count 1 value offset 9001
Key 3080 tiff_tag_location 34736 count 1 value offset 4
Key 3081 tiff_tag_location 34736 count 1 value offset 3
Key 3082 tiff_tag_location 34736 count 1 value offset 5
Key 3083 tiff_tag_location 34736 count 1 value offset 6
Key 3092 tiff_tag_location 34736 count 1 value offset 7
Key 4099 tiff_tag_location 0 count 1 value offset 9001
Variable length record 2 of 5
Description: GeoDoubleParamsTag (optional)
data: 6378137 298.2572 0 0 21 7500000 0 0.999923
Variable length record 3 of 5
Description: GeoASCIIParamsTag (optional)
data: Poland2000s7|Poland2000s7|ETRS89|
Variable length record 4 of 5
Description: OGC COORDINATE SYSTEM WKT
Variable length record 5 of 5
Description: rlas extra bytes
Extra Bytes Description:
Amplitude: Echo signal amplitude [dB]
Reflectance: Echo signal reflectance [dB]
Deviation: Pulse shape deviation
treeID: ID of a tree
Checking Classification attribute again:
> max(las_tree@data$Classification)
[1] 5
When I write las_tree with writeLAS
:
writeLAS(las_tree, savedFilename)
and read it again with:
las_read <- readLAS(paste(path, savedFilename, sep="\\"))
seems like I lost Classification attribute values:
> max(las_read@data$Classification)
[1] 0
Summary of las_read:
class : LAS (LASFˇ v1.4)
point format : 6
memory : 2.2 Gb
extent :7498400, 7499200, 5779500, 5780000 (xmin, xmax, ymin, ymax)
coord. ref. : NA
area : 399973.7 units² (convex hull)
points : 19517984 points
density : 48.8 points/units²
names : X Y Z gpstime Intensity ReturnNumber NumberOfReturns ScanDirectionFlag EdgeOfFlightline Classification ScannerChannel Synthetic_flag Keypoint_flag Withheld_flag Overlap_flag ScanAngle UserData PointSourceID Amplitude Reflectance Deviation treeID
File signature: LASFˇ
File source ID: 4001
Project ID - GUID: df4425f5-d89d-437c-baa3-cd71726ed8c6
Version: 1.4
System identifier:
Generating software: rlas R package
File creation d/y: 0/2018
header size: 375
Offset to point data: 2034
Num. var. length record: 3
Point data format: 6
Point data record length: 44
Num. of point records: 19517984
Num. of points by return:
Scale factor X Y Z: 0.01 0.01 0.01
Offset X Y Z: 0 0 0
min X Y Z: 7498400 5779500 -1.17
max X Y Z: 7499200 5780000 25.94
Variable length records:
Variable length record 1 of 3
Description: by LAStools of rapidlasso GmbH
Tags:
Key 3072 tiff_tag_location 0 count 1 value offset 32767
Variable length record 2 of 3
Description: by LAStools of rapidlasso GmbH
Variable length record 3 of 3
Description: by LAStools of rapidlasso GmbH
Extra Bytes Description:
Amplitude: Echo signal amplitude [dB]
Reflectance: Echo signal reflectance [dB]
Deviation: Pulse shape deviation
treeID: ID of a tree
Here's the full processing:
las = readLAS(filename_path, filter = "-keep_class 2 3 4 5")
tif_crop = raster::crop(tif, raster::extent(las)*1.1)
las_tree = lasmergespatial(las, tif_crop, "treeID")
treeID = las_tree@data[["treeID"]]
treeID = as.numeric(treeID)
las_tree = lasaddextrabytes(las_tree, x=treeID, name="treeID", desc="ID of a tree")
writeLAS(las_tree, savedFilename)
las_read <- readLAS(savedFilename)
Is that a lidR
(rlas
or liblas
) error or I am doing something wrong?
las_tree
is the good one?treeID
is missing into the header but it is present intolas_read
. I tried to reproduce your error without success. Are you sure you have an up-to-date version ofrlas
? LAS 1.4 is supported for not a long timerlas
supports more properly LAS 1.4 PRF 6 since v1.3.0 (Release date: 2019-02-03)Classification
lost