tilestache-seed.pyによるベクトルタイルの作成
引き続きvagrant-webmaps上でのベクトルタイル作成実験。
python-gdal追加導入
あとで不足が分かったことだが、次のようにしてライブラリを追加した。
$ sudo apt-get install python-gdal
その他、
$ sudo apt-get install gdal-bin
して、例えば ogrinfo を使えるようにしている。
最初の試行
TileStache API を参考にして、次のような設定ファイル shptiles/tilestache.cfg を書いた。
{ "cache": {"name": "Test"}, "layers": { "vector_test": { "provider": {"name": "vector", "driver": "shapefile", "parameters": {"file": "/vagrant/data/testdata/ne_110m_admin_0_countries2.shp"}, "properties": {"postal": "postal"} } } } }
これで、次のように実験して、それなりに動いたようであることを確認した。
vagrant@precise32:~/shptiles$ tilestache-seed.py -b 35 135 36 136 -c tilestache.cfg -l vector_test 10 1 of 12... vector_test/10/896/402.geojson (0KB) 2 of 12... vector_test/10/897/402.geojson (0KB) 3 of 12... vector_test/10/898/402.geojson (0KB) 4 of 12... vector_test/10/896/403.geojson (0KB) 5 of 12... vector_test/10/897/403.geojson (0KB) 6 of 12... vector_test/10/898/403.geojson (0KB) 7 of 12... vector_test/10/896/404.geojson (0KB) 8 of 12... vector_test/10/897/404.geojson (0KB) 9 of 12... vector_test/10/898/404.geojson (0KB) 10 of 12... vector_test/10/896/405.geojson (0KB) 11 of 12... vector_test/10/897/405.geojson (0KB) 12 of 12... vector_test/10/898/405.geojson (0KB)
実際に作成してみる
.cfg ファイルの cache 設定を Test から Disk に変更して、次のようにした。
{ "cache": { "name": "Disk", "path": "/vagrant", "dirs": "portable", "gzip": [] }, "layers": { "vector_test": { "provider": {"name": "vector", "driver": "shapefile", "parameters": {"file": "/vagrant/data/testdata/ne_110m_admin_0_countries2.shp"}, "properties": {"postal": "postal"} } } } }
これで次のようにして、GeoJSONタイルを作成した。
vagrant@precise32:~/shptiles$ tilestache-seed.py -b 35 135 36 136 -c tilestache.cfg -l vector_test 8 9 10 11 12 13 ... 910 of 913... vector_test/13/7187/3244.geojson (0KB) 911 of 913... vector_test/13/7188/3244.geojson (0KB) 912 of 913... vector_test/13/7189/3244.geojson (0KB) 913 of 913... vector_test/13/7190/3244.geojson (0KB) vagrant@precise32:~/shptiles$
これでホストOS側のvagrant-webmapsディレクトリのvector_testサブディレクトリに、geojsonタイルデータが保存されることになる。あとで内容を確認することにしたい。(とりあえず、QGISで一つのgeojsonタイルを開いてみて、ポリゴンが入っていることは確認できたところ。)