OpenStreetMap logo OpenStreetMap

Hiking relations in wiki table

Posted by Cascafico on 10 December 2018 in Italian (Italiano).

Intro

When adding several hiking routes, sometime it comes handy having updated tables in wiki format to be easily added in specific wiki pages.

Recipe

  • overpass query on area name
  • some awk insertions
  • pyhon script csv2wiki

overpass-query

This overpass query will generate a csv file(ie: stregna.csv) with local network hiking paths. Example output:

@id,name,ref,network
2071931,,747,lwn
6934010,Sentiero Italia - Tappa A14,SI,lwn
7112799,Sentiero Hum,,lwn

This awk will add OSM link to each relation:
$ awk -F “,” ‘FNR == 1 {print $0} FNR > 1 { print “[https://openstreetmap.org/relation/”$1” “$1”],”$2”,”$3”,”$4 }’ stregna.csv > stregna.txt

actual wiki formatting

Python script will generate the actual wiki text:
$ python csv2wiki stregna.txt > stregna.wiki

summarizing script

This script performs the steps above (here you can customize query with whatever relation tags). Just provide an OSM area name.

Discussion

Comment from ikonor on 10 December 2018 at 17:24

Thanks for sharing.

I always thought that it would be nice to replace those routes wiki tables with dynamically generated ones in HTML/JavaScript.

There was an attempt to add a table tab to Overpass Turbo, but unfortunately didn’t complete.

Or a dedicated web page that can list relations of a given type for a specific area, e.g. using DataTables or similar, and maybe show a map next to it. Completion percentage could be calculated from the distance tag and the actual length of the way members.

Comment from qwerty22 on 11 December 2018 at 22:55

Thanks for sharing. It is very useful for me.

Log in to leave a comment