データ変換のためだけにQGIS使うのが辛いのでCLIをよく使います
なるべくOSの環境を変えないで済むよう(いつもの通り)コンテナにします
今回は shp2json, dbf2json です
それぞれ shpファイル、dbfファイルをGeoJSONに変換するコマンドです
この辺でさらっと紹介されてます
podman build https://gist.github.com/kemasoft-gist/bc28dce9906bf230b5757f03a22b2b91/raw -t kemasoft/shapefile
参考:Dockerfile
参考にさせて頂いたページ
alias shp2json='podman run --rm -i -v .:/mnt kemasoft/shapefile shp2json'
alias dbf2json='podman run --rm -i -v .:/mnt kemasoft/shapefile dbf2json'
国土地理院のデータを使う時は --encoding Shift_JIS を忘れないようにしましょう
$ ls *.dbf
20200401-行政区画.dbf 20200401-行政区画界線.dbf 20200401-行政区画代表点.dbf 20200401-町字の代表点.dbf 20200401-町字界線.dbf
$ shp2json --encoding Shift-JIS 20200401-行政区画代表点.shp | jq . | head -n20
{
"type": "FeatureCollection",
"bbox": [
138.632616034,
35.75000175,
139.998345505,
36.331040108
],
"features": [
{
"type": "Feature",
"properties": {
"id": "K6_5013013062_1",
"fid": "50130-13062-i-1029",
"整備データ": 20171204,
"整備デーA": 0,
"整備完了日": "20200307",
"orgGILvl": "25000",
"orgMDId": null,
"表示区分": "非表示",
$ ls *.dbf
20200401-行政区画.dbf 20200401-行政区画界線.dbf 20200401-行政区画代表点.dbf 20200401-町字の代表点.dbf 20200401-町字界線.dbf
$ dbf2json --encoding Shift-JIS 20200401-行政区画代表点.dbf | jq . | head -n20
[
{
"id": "K6_5013013062_1",
"fid": "50130-13062-i-1029",
"整備データ": 20171204,
"整備デーA": 0,
"整備完了日": "20200307",
"orgGILvl": "25000",
"orgMDId": null,
"表示区分": "非表示",
"種別": "郡市・東京都の区",
"名称": "伊勢崎市",
"行政コード": "10204"
},
{
"id": "K6_5013613050_1",
"fid": "50136-13050-i-2033",
"整備データ": 20191223,
"整備デーA": 0,
"整備完了日": "20200307",