LoginSignup
1
3

More than 5 years have passed since last update.

Python GdalでGeoTiff画像を結合 or 分割する

Posted at

自分用メモ。
Gdalについては、自分はWindows環境なので、おなじみのUnofficial Windows Binariesから拾ってきてインストールしました。

結合

コマンドプロンプトで例えば以下を実行。

gdal_merge -o output.tif input1.tif input2.tif input3.tif input4.tif

-oオプションは出力ファイル。その後は結合に用いる画像を渡すのだが、ワイルドカードが使用不可だそう。
そんな時のために、--optfileオプションを用いて画像のリストファイルを渡すことができる。

例えば、dir /b /s *.tif > list.txtなどしてリストファイルを作成し、

gdal_merge -o output.tif --optfile list.txt

とすればよい。
重なっている部分は、先に指定した画像が下になる。

分割

例えば以下を実行。

gdal_retile -ps 5000 4000 -targetDir target source.tif

-psは分割単位(横ピクセル、縦ピクセル)。-targetDirは出力先フォルダで、指定が必須とのこと。source.tifが分割元画像となる。

その他

他のオプション等については、オフィシャルページを参照。
http://www.gdal.org/gdal_merge.html
http://www.gdal.org/gdal_retile.html

以下のホームページを参考にさせていただきました。
http://mf-atelier.sakura.ne.jp/mf-atelier/modules/tips/tec/gdal-ogr_tips.html
http://d.hatena.ne.jp/Yusuke_S/20090427/p1
http://d.hatena.ne.jp/miv/20131029/1383005805

1
3
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
1
3