Getting keys and unique values associated with a key from pbf #188
Replies: 5 comments 16 replies
-
Interesting blog post on OSM hstore values (there is not much out there and they are strange): https://www.blueskiesabove.us/entry/querying-converting-osm-pbf/ |
Beta Was this translation helpful? Give feedback.
-
Hi Robin! First of all, thank you very much for the suggestion and the link on hstore values. I think that your suggestion can be summarised as follows:
Is that right? |
Beta Was this translation helpful? Give feedback.
-
Reproducible example: Test ogr queriesecho "Hello Bash!";
pwd;
ls | head;
wget https://github.com/ropensci/osmextract/raw/master/inst/its-example.osm.pbf
ogrinfo its-example.osm.pbf
ogrinfo its-example.osm.pbf lines > lines.txt
head lines.txt
ogrinfo \
-dialect sqlite -sql "SELECT highway, COUNT(*) from lines" \
its-example.osm.pbf
ogrinfo \
-dialect sqlite -sql "SELECT highway, COUNT(*) from lines" \
its-example.osm.pbf
ogrinfo \
-dialect sqlite -sql "SELECT DISTINCT hstore_get_value(other_tags, 'bicycle') AS bicycle, hstore_get_value(other_tags, 'foot') AS foot FROM lines" \
its-example.osm.pbf
ogrinfo \
-sql "SELECT DISTINCT hstore_get_value(other_tags, 'bicycle') AS bicycle, hstore_get_value(other_tags, 'foot') AS foot FROM lines" \
its-example.osm.pbf > out.txt
# ogrinfo \
# -sql "SELECT DISTINCT hstore_get_value(other_tags, 'bicycle') AS bicycle FROM lines" \
# its-example.osm.pbf > out.txt
# cat out.txt
ogrinfo \
-sql "SELECT hstore_get_value(other_tags, 'bicycle') AS bicycle FROM lines" \
its-example.osm.pbf > out.txt
|
Beta Was this translation helpful? Give feedback.
-
And this seems to fail, not sure why, so basically, not easy:
|
Beta Was this translation helpful? Give feedback.
-
https://gis.stackexchange.com/questions/393540/how-to-extract-unique-values-from-pbf-file-with-gdal |
Beta Was this translation helpful? Give feedback.
-
Sometimes it's useful to see what keys are available and the range of values associated with a particular key are from the .pbf directly. Use case: finding out the type of
railway
tags in the UK OSM data.Reprex demonstrating broadly the desired outcome with the Isle of Wight and demonstrating that queries on pbf files can work - just cannot figure out the query needed to find the unique keys without reading in the whole file.
Created on 2021-04-05 by the reprex package (v2.0.0)
Not 100% that querying directly from the .pbf is possible but imagine it is and it could be a quick way of getting a handle on large datasets before committing to vectortranslating them with a range of
extra_tags
which can take a long time.Beta Was this translation helpful? Give feedback.
All reactions