3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

複数の GeoJSON ファイルをマージ

Last updated at Posted at 2019-02-07

こんにちは。
複数の GeoJSON ファイルのデータをマージ(合体、連結)させて一つのファイルを作りました(jq コマンドを利用、対象ファイル例は *geo.json)。

$ jq '.features[]' *geo.json | jq -s '{"type":"FeatureCollection", "features":.}' > merged_geo.json
  • また条件抽出も加えてみました(この例は properties.name != "" )。
$ jq '.features[]' *geo.json | jq -s -c 'map(select(.properties.name != ""))[] ' | jq -s '{"type":"FeatureCollection", "features":.}' > merged_geo.json 

GeoJSONL(cat コマンド利用)

なお Newline-delimited GeoJSON (GeoJSONL) ファイル1ならばcatコマンドを用いてマージできます(対象ファイル例は *geo.jsonl)。

$ cat *geo.jsonl > merged_geo.jsonl
  • 上記と同様に条件抽出も加えてみました(この例は properties.name != "" )。
$ cat *geo.jsonl | jq -s -c 'map(select(.properties.name != ""))[] ' > merged_geo.jsonl

GeoJSONL + gzip 圧縮

gzip 圧縮された GeoJSONL ファイルも、cat コマンドでマージできます。

$ cat *geo.jsonl.gz > merged_geo.jsonl.gz

他のフォーマットデータ

ogrmerge.py がマージに使えます。

$ ogrmerge.py -f FlatGeobuf -o merged.fgb *.fgb
  1. 参考:「GIS データ(ストリーム対応型)をLeaflet地図上に表示

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?