Correctly reading GPS_time from LiDAR .las file using laspy (python)

210 views Asked by At

I am trying to read in some .las LiDAR data into python and to correctly access the GPS_time attribute.

path = r"\\xxxx\las_data.las"
las_data = laspy.read(path)

To access the gps time I use:

timestamp = las_data.gps_time

The return array is numbers like:

array([3.43864063e+08, 3.43864063e+08, 3.43864063e+08, ...,
       3.41800751e+08, 3.41800751e+08, 3.41800751e+08])

However the actual GPS_time (inspected in GIS) should be:

array([1343864063, 1343864063, 1343864063, ...,
       1341800751, 1341800751, 1341800751])

Basically it has dropped the first digit when reading the data.

I have manually added the missing order of magnitude, converting 3.43864063e+08 to 1343864063 using code such as:

tss = [int(_)  + int(1000000000) for _ in timestamps_scientific]

tss looks like:

[1343864063,
 1343864063,
 1343864063,
 1343864063,
 1343864063,
...
]

Which is correct.

However I am looking for a more efficient process which correctly reads the GPS_time from the start which will avoid possible manipulation errors.

1

There are 1 answers

0
Tim Roberts On

You need to read the standard. That's exactly how GPS time is encoded in these files. They call it "adjusted standard GPS time", and it is "satellite GPS time" minus 1 times 10^9.

Check page 6 of https://www.asprs.org/wp-content/uploads/2010/12/LAS_1_4_r13.pdf .

So, just do the addition you're doing.