こんにちは。
日本の 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
必要な範囲のデータを抽出する場合
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
pbfデータ読み取り例
上記データの読み取り例です(参考:「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