8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

必要な範囲のデータを抽出する場合

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?