LoginSignup
2
2

More than 1 year has passed since last update.

LASデータ操作のスイスアーミーナイフ「LAStools」をMacOSで利用したい

Last updated at Posted at 2022-06-23

LASデータをガチャガチャやる上で、スイスアーミーナイフ、まぁようはなんでもできるで、とまで言われている「LAStools」。
基本的には有料のツールでライセンスを取得する必要があるのですが、一部のツールは無料で利用できます。
ですが、MacOSで利用しようとすると、インストール方法が不明瞭だなーと思ったので、インストールまでのメモ書きです。
(もしかしたらちゃんとしたインストール方法があるかもしれません。その際は教えていただけると泣いて喜びます。)

利用するOS

今回は以下のようなマシンで試していきます。
インテル版macOS Montereyです。
なのでM1などのチップだとうまく動作するかは分かりません…

  • バージョン
❯ sw_vers
ProductName:    macOS
ProductVersion: 12.4
BuildVersion:   21F79
  • スペック
❯ system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro16,1
      Processor Name: 8-Core Intel Core i9
      Processor Speed: 2.3 GHz
      Number of Processors: 1
      Total Number of Cores: 8
      L2 Cache (per Core): 256 KB
      L3 Cache: 16 MB
      Hyper-Threading Technology: Enabled
      Memory: 32 GB
...

インストール

早速インストールしてみましょう。

こちらのページにダウンロードボタンがあるので、クリックしてzipをダウンロードします。
https://rapidlasso.de/customers/

image.png

zipのダウンロードが終わったら基本はgithubのLAStoolsページに従ってmakeしていきますが、ちょっと工程が異なります。

LAStools.zipの解凍後、すでにPATHが通っているディレクトリの下に移動させておきましょう。通っているPATHはこのように調べることができます。

% $PATH
...
/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
...

macを長く利用していればいろんなところにパスを通しているかと思いますが、デフォルトで通っていそうなのはこの辺りでしょうか。
今回は/usr/local/binに入れてみることにします。
その後、makeします

unzip LAStools.zip
cp -r LAStools/ /usr/local/bin/LAStools/
cd /usr/local/bin/LAStools/ 
make

ログがズラーっと出てきたのち、エラーが出てきて停止してしまいました…

% make
...
g++  -c -O3 -Wall -Wno-deprecated -Wno-strict-aliasing -Wno-write-strings -Wno-unused-result -DNDEBUG   -I../LASzip/src -I../LASlib/inc  lasindex.cpp -o lasindex.o
lasindex.cpp:146:25: error: character too large for enclosing character literal type
      if (argv[i][0] == '�') argv[i][0] = '-';
                        ^
1 error generated.
make[1]: *** [lasindex.o] Error 1
make: *** [all] Error 2

全然ダメじゃん…って思ったんですが、よくよく見てみるとLAStools/binの中に一部のツールは実行ファイルが作成されているような気がしますね。

% ls -lrt bin 
...
-rwxr-xr-x  1 xxxx  staff  1511728  6 24 06:37 laszip*
-rwxr-xr-x  1 xxxx  staff  1607680  6 24 06:37 lasinfo*
-rwxr-xr-x  1 xxxx  staff  1509480  6 24 06:37 lasprecision*
-rwxr-xr-x  1 xxxx  staff  1345344  6 24 06:37 las2txt*
-rwxr-xr-x  1 xxxx  staff  1509328  6 24 06:37 txt2las*
-rwxr-xr-x  1 xxxx  staff  1525936  6 24 06:37 las2las*
-rwxr-xr-x  1 xxxx  staff  1361824  6 24 06:37 lasdiff*
-rwxr-xr-x  1 xxxx  staff  1492944  6 24 06:37 lasmerge*

これはgithubに記載のOpen source toolsの項目とほぼ一致しています。
lasindexが存在しないのと、lasdiffが作成されてしまっているところが気になりますが、そもそもlasdiffはgithubのページに名前が載っていないので、ドキュメントの更新が遅れているのかな?と思います。

  • las2las extracts last returns, clips, subsamples, translates, etc ...
  • las2txt turns LAS into human-readable and easy-to-parse ASCII
  • lasindex creates a spatial index LAX file for fast spatial queries
  • lasinfo prints out a quick overview of the contents of a LAS file
  • lasmerge merges several LAS or LAZ files into a single LAS or LAZ file
  • lasprecision analyses the actual precision of the LIDAR points
  • laszip powerful, lossless LiDAR compressor that turns large LAS files into much smaller LAZ files hat are only 7 - 20 percent of the original file size
  • txt2las converts LIDAR data from ASCII text to binary LAS format

ただ、このままだと実行のたびにLAStoolsのフォルダに格納されているバイナリファイルを指定しないといけないので、pathの通っているディレクトリに移動しちゃいましょう。

PATHを通す

zshrcbashrcを修正します。
お使いのshellは以下の方法で調べることができます。

$ echo "$SHELL"
/bin/zsh

<利用しているshell>rcを編集し、更新しましょう。

echo 'export PATH=/usr/local/bin/LAStools/bin:$PATH' >> ~/.zshrc
source ~/.zshrc

PATHが通りましたね。

% $PATH
/usr/local/bin/LAStools/bin:...

これで準備完了です!

ツールを使ってみる

VIRTUAL SHIZUOKA 静岡県 富士山南東部・伊豆東部 点群データなどで適当なlasデータをダウンロードして…

以下のコマンドでサクッとlasをlazに圧縮できます!

laszip -i 08OF1348.las -o 08OF1348.laz

ファイルサイズを確認すると345Mから77Mまで圧縮できましたね!すごい!

❯ ll                                    
total 872552
-rw-r--r--  1 xxxx  staff    77M  6 24 06:48 08OF1348.laz
-rw-rw-r--@ 1 xxxx  staff   345M  3 18  2020 08OF1348.las

メタ情報の確認もしてみましょう。

% lasinfo 08OF1348.las
lasinfo (220613) report for '08OF1348.las'
reporting all LAS header entries:
  file signature:             'LASF'
  file source ID:             0
  global_encoding:            1
  project ID GUID data 1-4:   00000000-0000-0000-0000-000000000000
  version major.minor:        1.2
  system identifier:          'Aero Asahi Corp.,'
  generating software:        'LAS Tool'
  file creation day/year:     65/2020
  header size:                227
  offset to point data:       229
  number var. length records: 0
  point data format:          3
  point data record length:   34
  number of point records:    10647410
  number of points by return: 5951724 2357532 1336198 670565 331391
  scale factor x y z:         0.001 0.001 0.001
  offset x y z:               -0 -0 -0
  min x y z:                  55199.840 -124500.130 58.430
  max x y z:                  55600.070 -124199.790 103.600
the header is followed by 2 user-defined bytes
reporting minimum and maximum for all LAS point record entries ...
  X            55199840   55600070
  Y          -124500130 -124199790
  Z               58430     103600
  intensity         444      65535
  return_number       1          5
  number_of_returns   1          5
  edge_of_flight_line 0          0
  scan_direction_flag 0          1
  classification      1          2
  scan_angle_rank   -14         14
  user_data           1          1
  point_source_ID    28         83
  gps_time 259119985.930357 260069306.731555
  Color R 7168 65280
        G 11776 65280
        B 256 65280
WARNING: there is coordinate resolution fluff (x10) in Z
number of first returns:        5951724
number of intermediate returns: 2258126
number of last returns:         6041380
number of single returns:       3603820
overview over number of returns of given pulse: 3603820 2035805 1995189 1680537 1332059 0 0
histogram of classification of points:
         7131131  unclassified (1)
         3516279  ground (2)

ん〜見やすい。

これでLAStoolsのオープンなツールが利用できるようになりました!
みなさんも活用してみてください!

2
2
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
2
2