PDAL / python

PDAL's Python Support
Other
116 stars 34 forks source link

pdal.Writer.copc: no effect of offset_x="auto" #122

Closed CharlesGaydon closed 2 years ago

CharlesGaydon commented 2 years ago

I have an issue with the pdal.Writer.copc options offset_{x|y|z}, which have no effect when set to "auto".

Anaconda env:

name: copc_4_lidar
channels:
  - conda-forge
  - anaconda
dependencies:
  - python==3.9.*
  - pip
  # --------- geo --------- #
  - conda-forge:pdal==2.4.*
  - conda-forge:python-pdal==3.*.*

Versions are

# mamba list | grep pdal
pdal                      2.4.2                he35911a_2    conda-forge
pdal-plugins              1.2.0                    pypi_0    pypi
python-pdal               3.1.2            py39he19b95c_3    conda-forge

Minimal working example

import pdal

las_path = "data/730000_6360000.subset.prototype_format202.tiny.las"
las_path_out = las_path.replace("data/", "outputs/").replace(".las", ".copc.laz")
p = pdal.Reader.las(
    filename=las_path,
    nosrs=True,
    override_srs="EPSG:2154",
) | pdal.Writer.copc(
    las_path_out,
    offset_x="auto",  # no effect
    offset_y="auto",  # no effect
    forward="all",
)

p.execute()

p = pdal.Pipeline() | pdal.Reader.copc(las_path_out)
p.execute()
points = p.arrays[0]
print(points["X"].min())  # high value, not 0

I can provide the tiny data subset provided a suitable channel (it is only 24kb).

(BTW: I am highly happy that COPC is supported by PDAL!)

CharlesGaydon commented 2 years ago

I disguised a LAS as a text file for github. Simply remove the .txt extension.

730000_6360000.subset.prototype_format202.tiny.las.txt

hobu commented 2 years ago

I can't replicate this

pdal translate ../ign-auto-scale.las foo.copc.laz --writers.copc.scale_x="auto" --writers.copc.forward="all"
    "minx": 730604.98,
    "miny": 6359619.74,
    "minz": 466.67,
    "offset_x": 730607.845,
    "offset_y": 6359620,
    "offset_z": 466.67,
hobu commented 2 years ago

print(points["X"].min()) # high value, not 0

Maybe there is some confusion on what auto does for scale. It is computing the minimum value in the set, which in this case is 730604.98. The default value is 0, and isn't what you want in most cases. I do not think there is a bug here.

CharlesGaydon commented 2 years ago

Ok, indeed there was some misunderstanding on my side. I though auto would first compute the minimum value and then substract it from the positions. Thank you.