LoginSignup
8
8

OpenStreetMap データ(japan-latest.osm.pbf)から指定範囲切り出し

Last updated at Posted at 2018-02-24

こんにちは。
日本の OpenStreetMap データ(japan-latest.osm.pbf, 1GB以上)をダウンロードし、指定範囲で切り出しなどを行いました。以下の手順です。

ダウンロード

$ wget https://download.geofabrik.de/asia/japan-latest.osm.pbf
$ wget https://download.geofabrik.de/asia/japan.poly

データ最新化

osmupdate コマンドを使いました(osmfilter に含まれるコマンド)。

$ brew install osmfilter
$ osmupdate --hour --day -B=japan.poly -v japan-latest.osm.pbf japan-latest-updated.osm.pbf

extract 処理

osmium コマンド(の extract 処理)を使うと(osmium-tool に含まれるコマンド)、必要な範囲のデータを抽出処理できます:

$ brew install osmium-tool
$ osmium extract --polygon japan.poly -o japan-latest-updated-complete.osm.pbf japan-latest-updated.osm.pbf
$ osmium check-refs japan-latest-updated-complete.osm.pbf
Nodes in ways missing: 0
矩形範囲を指定しデータを切り出し

より小さい矩形範囲を指定して切り出しも可能です:

$ brew install osmium-tool
$ tokyo_bbox="139.500,35.494,140.000,35.900"
$ osmium extract --bbox $tokyo_bbox -o tokyo.osm.pbf japan-latest-updated.osm.pbf
$ osmium check-refs tokyo.osm.pbf
Nodes in ways missing: 0

データ読み取り

データ読み取りを試しました(参考:「Golang で OpenStreetMap ファイル(osm.pbf)の読み込み(osmpbf 利用)」)。

$ go run osmpbf_progressbar.go -ncpu 4 tokyo.osm.pbf 
54732 / 54732 [====================================================] 100.00 % 4s
Nodes: 5,492,671, Ways: 1,039,991, Relations: 4,422
8
8
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
8
8