0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PDALでLAS/LAZに変換する場合はscaleを設定しましょう

Posted at

要約:PDALでLAS/LAZに変換するときはscale_x, scale_y, scale_zを忘れず設定しましょう

言いたいことは上記のとおりです。
PDALを使ったファイル形式変換の設定漏れでヒヤッとしたため共有します。


点群データのファイル形式を変換する際にPDALを利用することが多いかと思いますが、
LAS/LAZ形式に変換する際にscaleの設定を忘れると、データによってはXYZ座標の精度が大きく悪化します。

具体例としては以下のコマンドで点群データをPDALでLAS形式に変換します。

pdal translate bunnyInt32.e57 bunnyInt32.las

その結果、変換後のデータがこのようにスカスカになってしまいました。
image.png

これは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

image.png

ただ毎回設定するのが面倒くさいので、以下のようにパイプライン用の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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?