2

Building off of a previous question:

Clean way to convert from US feet to meters with lidR - LiDAR point cloud

I am working with the USGS LiDAR point cloud data and am still having this rescaling or whatever you want to call it using the:

  las$X = las$X * ft2m
  las$Y = las$Y * ft2m
  las$Z = las$Z * ft2m

Approach from above. I get the error:

Error: Trying to store values ranging in [3496056, 3497580] but storable range is [7852516.353, 12147483.647]

My Z and Y coordinates are no issue, it is only the X. What's up, because it is driving me insane. Only four of my tiles seem to have this problem.

1 Answer 1

2

You have this error because LAS format stores coordinates as integers with a scale and offset. I already provided a comprehensive answers here. In the question you mentioned it worked by chance actually.

The problem is that, using the original scale factors and offsets of the file, it is not possible to store the new coordinates as integer because the new numbers it generates are bigger than ±2^31 (integer overflow).

Because you did not share a file for which the error occurs I can't do the math but I can give you the main idea. You must update the header first so the scale factor and offset are compatible with the new range of coordinates after transormation. You can keep the same scale factor (0.01 I guess) to get an accuracy of 0.01 m instead of 0.01 ft (maybe 0.005 is better). And you can convert the offset to meters. I guess it will work but it might be advised to choose another value. You must do that for all the tiles not only the four. The problem is for all the tiles even if, luckily, you did not encounter integer overflow for most of them.

ft2m = 1200/3937

las@header@PHB[["X offset"]] <- floor(las@header@PHB[["X offset"]]*ft2m)
las@header@PHB[["Y offset"]] <- floor(las@header@PHB[["Y offset"]]*ft2m)

las$X = las$X * ft2m
las$Y = las$Y * ft2m

You must also delete the CRS

1
  • Thank you so much for clearing this up! I suspected different parts of this but could not put it all together! Mar 12, 2021 at 0:50

Your Answer

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

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