要約:PDALでLAS/LAZに変換するときはscale_x
, scale_y
, scale_z
を忘れず設定しましょう
言いたいことは上記のとおりです。
PDALを使ったファイル形式変換の設定漏れでヒヤッとしたため共有します。
点群データのファイル形式を変換する際にPDALを利用することが多いかと思いますが、
LAS/LAZ形式に変換する際にscaleの設定を忘れると、データによってはXYZ座標の精度が大きく悪化します。
具体例としては以下のコマンドで点群データをPDALでLAS形式に変換します。
pdal translate bunnyInt32.e57 bunnyInt32.las
その結果、変換後のデータがこのようにスカスカになってしまいました。
これはPDALのLAS変換で使用される、writers.lasの設定値scale_x
, scale_y
, scale_z
が適切に設定されていないことが原因です。(scale_x
, scale_y
, scale_z
のデフォルト値は0.01
)
https://pdal.io/en/stable/stages/writers.las.html
Scale to be divided from the X, Y and Z nominal values, respectively, after the offset has been applied. The special value auto can be specified, which causes the writer to select a scale to set the stored values of the dimensions to range from [0, 2147483647]. [Default: .01]
そのため、変換前の点の間隔が0.01
よりも細かい場合は点の位置が0.01
間隔に丸められ、上記のようなスカスカな点群データとなってしまいます。
(複数の点が同じ座標に丸められても重複分の点が削除されるわけでもないためファイルサイズ的にも単純に損)
この場合は、以下のようにwriters.las.scale_x,y,z
をより小さい値に設定すればOKです。
pdal translate --writers.las.scale_x=0.001 --writers.las.scale_y=0.001 --writers.las.scale_z=0.001 bunnyInt32.e57 bunnyInt32.las
ただ毎回設定するのが面倒くさいので、以下のようにパイプライン用のjsonファイルを用意しておき、
{
"pipeline": [
"input.e57",
{
"type": "writers.las",
"filename": "output.las",
"scale_x": 0.001,
"scale_y": 0.001,
"scale_z": 0.001
}
]
}
pdal pipeline
で呼び出すのが良いかもしれません。
pdal pipeline pipeline.json
いやまあPDALのチュートリアルにも記載されているので、ツールを利用する前にドキュメントを読めよという話ですが…
Remember to set offset_x, offset_y, scale_x, and scale_y values to something appropriate if your are storing decimal degree data in LAS files. The special value auto can be used for the offset values, but you should set an explicit value for the scale values to prevent overdriving the precision of the data and disrupting [Compression] with LASzip.
https://pdal.io/en/stable/tutorial/las.html