https://github.com/maguro/pbf
OpenStreetMap PBF golang parser
https://github.com/maguro/pbf
golang openstreetmap openstreetmap-pbf openstreetmap-pbf-parser openstreetmap-protobuffer-format
Last synced: 29 days ago
JSON representation
OpenStreetMap PBF golang parser
- Host: GitHub
- URL: https://github.com/maguro/pbf
- Owner: maguro
- License: apache-2.0
- Created: 2017-09-18T23:13:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-09T23:10:07.000Z (over 2 years ago)
- Last Synced: 2024-07-31T20:51:47.596Z (9 months ago)
- Topics: golang, openstreetmap, openstreetmap-pbf, openstreetmap-pbf-parser, openstreetmap-protobuffer-format
- Language: Go
- Size: 48.5 MB
- Stars: 48
- Watchers: 5
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - pbf - OpenStreetMap PBF golang encoder/decoder. (Geographic / Search and Analytic Databases)
- awesome-go - pbf - OpenStreetMap PBF golang parser - ★ 9 (Geographic)
- awesome-go-extra - pbf - 09-18T23:13:18Z|2022-06-04T22:02:31Z| (Geographic / Advanced Console UIs)
README
# pbf
OpenStreetMap PBF golang encoder/decoder[](https://github.com/maguro/pbf/actions/workflows/ci.yml)
[](https://goreportcard.com/report/github.com/maguro/pbf)
[](http://godoc.org/github.com/maguro/pbf)
[](https://sonarcloud.io/summary/new_code?id=maguro_pbf)
[](https://opensource.org/licenses/Apache-2.0)A golang based OpenStreetMap PBF encoder/decoder with a handy command line utility, `pbf`.
## pbf Command Line Utility
The `pbf` CLI can be installed using the `go install` command:
$ go install m4o.io/pbf/cmd/pbf
### pbf info
The `pbf` CLI can be used to obtain summary and extended information about an
OpenStreetMap PBF file:$ pbf info -i testdata/greater-london.osm.pbf
BoundingBox: [-0.511482, 51.28554, 0.335437, 51.69344]
RequiredFeatures: OsmSchema-V0.6, DenseNodes
OptionalFeatures:
WritingProgram: Osmium (http://wiki.openstreetmap.org/wiki/Osmium)
Source:
OsmosisReplicationTimestamp: 2014-03-24T21:55:02Z
OsmosisReplicationSequenceNumber: 0
OsmosisReplicationBaseURL:JSON output can be obtained by adding the `-j` option:
$ pbf info -j -i testdata/greater-london.osm.pbf | jq
{
"BoundingBox": {
"Left": -0.511482,
"Right": 0.33543700000000004,
"Top": 51.69344,
"Bottom": 51.285540000000005
},
"RequiredFeatures": [
"OsmSchema-V0.6",
"DenseNodes"
],
"OptionalFeatures": null,
"WritingProgram": "Osmium (http://wiki.openstreetmap.org/wiki/Osmium)",
"Source": "",
"OsmosisReplicationTimestamp": "2014-03-24T14:55:02-07:00",
"OsmosisReplicationSequenceNumber": 0,
"OsmosisReplicationBaseURL": ""
}Here, [jq](https://stedolan.github.io/jq/) is used to pretty print the compact
JSON.Extended information about the OpenStreetMap PBF file can be obtained
by using the `-e` option. This causes the entire file to be scanned, which can
take a very long time; a progress bar is displayed on `stderr`.$ pbf info -e -i testdata/greater-london.osm.pbf
BoundingBox: [-0.511482, 51.28554, 0.335437, 51.69344]
RequiredFeatures: OsmSchema-V0.6, DenseNodes
OptionalFeatures:
WritingProgram: Osmium (http://wiki.openstreetmap.org/wiki/Osmium)
Source:
OsmosisReplicationTimestamp: 2014-03-24T21:55:02Z
OsmosisReplicationSequenceNumber: 0
OsmosisReplicationBaseURL:
NodeCount: 2,729,006
WayCount: 459,055
RelationCount: 12,833Finally, `pbf` can read an OpenStreetMap PBF file from `stdin`:
$ cat testdata/greater-london.osm.pbf | pbf info -e
In this case, a progress bar is not displayed since there is no way to know,
a priori, what the size of the PBF file is.