OpenStreetMap

Quick and dirty OSM statistics with bash and jq

Posted by pangoSE on 10 January 2020 in English. Last updated on 11 January 2020.

This is the script I came up with to make some stats on the huts and shelters of Sweden. The data was fetched via overpass-turbo.

download the geojson from Overpass Turbo -> export or save as from JOSM.

example query: access!=private and (tourism=alpine_hut or tourism=wilderness_hut or (amenity=shelter and shelter_type!=public_transport)) in sweden

you can run this query from inside JOSM - see the JOSM wiki.

The script is here: https://gist.github.com/pangoSE/5294e835c9bead773e8036603a90b898

This was the output for Sweden:

$ ./stats.sh vin-190110.geojson 
Numbers of each type:
Shelters - total: 2629
Shelters - Lean to (sv. vindskydd): 793
Shelters - Basic hut (sv. stuga utan uppvärmning): 129
Shelters - Weather shelter (sv. väderskydd endast lämpad för kort uppehåll vid dåligt väder): 355
Shelters - Picnic shelter (sv. liten byggnad med tak, eldstad och skorsten i mitten): 251
Shelters - Unknown type: 1692
Wilderness huts: 43
Alpine huts: 82

Lean_to shelters details:
- has description tag: 29 - 3%
- has fireplace=yes: 305 - 38%
- has floor=wood: 7 - 0%
- has image: 18 - 2%
- has snowmobile=yes: 28 - 3%
- has water_source tag: 4 - 0%
- has wood_provided=yes: 3 - 0%

Basic huts details:
- has description tag: 16 - 12%
- has fireplace=yes: 52 - 40%
- has image: 1 - 0%
- has snowmobile=yes: 18 - 13%
- has water_source tag: 0 - 0%
- has wood_provided=yes: 0 - 0%

Wilderness huts details:
- has description tag: 18 - 41%
- has fireplace=yes: 41 - 95%
- has image: 5 - 11%
- has snowmobile=yes: 18 - 41%
- has water_source tag: 0 - 0%
- has wood_provided=yes: 0 - 0%

Alpine huts details:
- has description tag: 12 - 14%
- has fireplace=yes: 4 - 4%
- has image: 5 - 6%
- has snowmobile=yes: 19 - 23%
- has water_source tag: 2 - 2%
- has wood_provided=yes: 5 - 6%

Discussion

Comment from mmd on 11 January 2020 at 21:12

You can probably generate the same output with a single Overpass query without any external shell script. Check out https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example#Wiki_table_generator_.28since_0.7.54.29 for some ideas.

Comment from pangoSE on 12 January 2020 at 13:34

thanks for the tip!

Comment from pangoSE on 12 January 2020 at 13:36

@mmd can it also calculate the percentages?

Log in to leave a comment