====== Ramer-Douglas-Peucker アルゴリズムで簡略化&GeoJSON形式で出力 ====== Ramer-Douglas-Peucker アルゴリズムで簡略化を行いつつ、GeoJSON形式で出力する方法。\\ # 20%まで簡略化し、GeoJSON形式で出力 $ mapshaper shape/A32-16_12.shp encoding=sjis -simplify dp 20% -o format=geojson output/geo_dp20.json # 50%まで簡略化し、GeoJSON形式で出力 $ mapshaper shape/A32-16_12.shp encoding=sjis -simplify dp 50% -o format=geojson output/geo_dp50.json # 簡略化を行わず、GeoJSON形式で出力 $ mapshaper shape/A32-16_12.shp encoding=sjis -o format=geojson output/geo_100.json # サイズを確認 $ ls -lhSr output/ 合計 16M -rw-r--r-- 1 test test 2.0M mm dd HH:ii:ss geo_dp20.json -rw-r--r-- 1 test test 4.7M mm dd HH:ii:ss geo_dp50.json -rw-r--r-- 1 test test 9.1M mm dd HH:ii:ss geo_100.json # 元のシェープファイルのサイズを確認 ls -lh shape/ 合計 3.8M -rw----r-- 1 test test 45K mm dd HH:ii:ss A32-16_12.dbf -rw----r-- 1 test test 3.8M mm dd HH:ii:ss A32-16_12.shp -rw----r-- 1 test test 2.4K mm dd HH:ii:ss A32-16_12.shx # ちなみに、上記コマンドでは「encoding=sjis」でシェープファイルの文字エンコードを指定しています # エンコードを指定せずに実行すると以下のようなエラーが出ます $ mapshaper shape/A32-16_12.shp -o format=geojson output/geo_100.json [o] Error: Unable to auto-detect the text encoding of the DBF file. To avoid corrupted text, re-import using the "encoding=" option. To see a list of supported encodings, run the "encodings" command. Run mapshaper -h to view help # 指定できるエンコードの種類は以下のコマンドで確認できます $ mapshaper -encodings