5

I have data from Lidar in .xyz format.

I read that it could be beneficial to convert it to .las. So that one can use e.g. laspy -library.

For example (code copied from an example):

import laspy
import numpy as np

hdr = laspy.header.Header()

outfile = laspy.file.File("output.las", mode="w", header=hdr)
allx = np.array([1.000, 2.000, 3.000, 3.000]) # Four Points
ally = np.array([0.000, 0.000, 0.000, 3.000])
allz = np.array([10.000, 10.000, 11.000, 11.000])

xmin = np.floor(np.min(allx))
ymin = np.floor(np.min(ally))
zmin = np.floor(np.min(allz))

outfile.header.offset = [xmin,ymin,zmin] # how to know what this should be?
outfile.header.scale = [0.001,0.001,0.001] # how to know what this should be?

outfile.x = allx
outfile.y = ally
outfile.z = allz

outfile.close()

However, I don't have access to any "header data" or metadata.

How can I know what to specify offset and scale as?

0

1 Answer 1

4

The scale factor states for the accuracy of your data. 0.001 is a millimeter precision. It means that if your coordinate is 0.123456 it will be clamped to 0.123. Depending on your data source 0.01 or 0.001 are good.

offset aims to do not get integer overflow. Let say you want to store 123456789.123. In a LAS file you will actually store an integer: 123456789123 that will be converted at read time into 123456789.123 using the scale factor. But 123456789123 is much bigger than what can be stored into an integer on 32 bits. This is why there is an offset. The file actually stores e.g. 6789123, converted to 6789.123 and this value is offseted with 123450000 to get 123456789.123. So xmin, ymax, zmin are valid options but we usually prefer to round these values to the closest integral meter/kilometer

2
  • Yes and offset is obviously the offset that the cloud has from "sea level" or "Z=0".
    – mavavilj
    Commented Jan 10, 2020 at 14:20
  • Answer edited to explain offset
    – JRR
    Commented Jan 10, 2020 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.