I am seeing strange write behavior with lidR. The outputs from lidR are compressed to fall on a single line. I vaguely recall discussing this with JR before, but cannot recall a solution.
#ok
las0=lidR::readLAS("c:\\temp\\tile1.las")
lidR::plot(las0)
#not ok
lidR::writeLAS(las0,"c:\\temp\\tile_lidR.las")
las1=lidR::readLAS("c:\\temp\\tile_lidR.las")
#> ERROR: 'end-of-file' after 10468 of 10474 points
#> Warning messages:
#> 1: There are 113 points flagged 'withheld'.
#> 2: There are 113 points flagged 'synthetic'.
lidR::plot(las1)
And here are the summaries if I look at the file meta info in R:
> summary(las0)
class : LAS (LASF v1.3)
point format : 2
memory : 872.4 Kb
extent :1007414, 1007736, 823583.8, 823586.9 (xmin, xmax, ymin, ymax)
coord. ref. : NA
area : 500.825 units²
points : 10.5 thoushand points
density : 20.91 points/units²
names : X Y Z Intensity ReturnNumber NumberOfReturns ScanDirectionFlag EdgeOfFlightline Classification Synthetic_flag Keypoint_flag Withheld_flag ScanAngleRank UserData PointSourceID R G B
File signature: LASF
File source ID: 0
Global encoding:
- GPS Time Type: GPS Week Time
- Synthetic Return Numbers: no
- Well Know Text: CRS is GeoTIFF
- Aggregate Model: false
Project ID - GUID: 00000000-0000-0000-0000-000000000000
Version: 1.3
System identifier: Trimble
Generating software: Inpho
File creation d/y: 254/2015
header size: 375
Offset to point data: 375
Num. var. length record: 0
Point data format: 2
Point data record length: 26
Num. of point records: 10474
Num. of points by return: 10474 0 0 0 0
Scale factor X Y Z: 0.001 0.001 0.001
Offset X Y Z: 1007436 823586 775
min X Y Z: 1007414 823583.8 722.348
max X Y Z: 1007736 823586.9 821.588
Variable length records: void
> summary(las1)
class : LAS (LASF v1.3)
point format : 2
memory : 871.9 Kb
extent :1007502, 1007829, 823586, 824962.3 (xmin, xmax, ymin, ymax)
coord. ref. : NA
area : 180387.3 units²
points : 10.5 thoushand points
density : 0.06 points/units²
names : X Y Z Intensity ReturnNumber NumberOfReturns ScanDirectionFlag EdgeOfFlightline Classification Synthetic_flag Keypoint_flag Withheld_flag ScanAngleRank UserData PointSourceID R G B
File signature: LASF
File source ID: 0
Global encoding:
- GPS Time Type: GPS Week Time
- Synthetic Return Numbers: no
- Well Know Text: CRS is GeoTIFF
- Aggregate Model: false
Project ID - GUID: 00000000-0000-0000-0000-000000000000
Version: 1.3
System identifier:
Generating software: rlas R package
File creation d/y: 0/2015
header size: 375
Offset to point data: 375
Num. var. length record: 0
Point data format: 2
Point data record length: 26
Num. of point records: 10468
Num. of points by return: 1209 1185 1327 1223 1385
Scale factor X Y Z: 0.001 0.001 0.001
Offset X Y Z: 1007436 823586 775
min X Y Z: 1007502 823586 -2146709
max X Y Z: 1007829 824962.3 2148193
Variable length records: void
The las file can be found here
@JR reminded me that the lastools documentation also addresses this case (even the number of bytes) explicitly. I just navigated to the correct directory and overwrote all of the header fields using the command below for the lasinfo tool. I decided to just hardcode changes to the las file headers so that I don't forget and run into this with the same files again.
Martin's code below is updated to use wildcard:
lasinfo -i *.las -set_header_size 235
His code also came with the warning:
CAREFUL! sets the header size field of the LAS header to 235 without checking whether this will corrupt the file.
tile_lidR.las
file that I write I get "ERROR: 'end-of-file' after 10468 of 10474 points" and more warnings, but it reads anyway. Are you also seeing these?