Bash/Script to know your favorite tags

From OpenStreetMap Wiki
Jump to navigation Jump to search

If you want to know which the tags of the features you frequently edit, you can run the following Linux bash script as a start. It will tell the frequency of key=tag pairs in all your edit history:


  #!/bin/bash
  # source: https://wiki.openstreetmap.org/wiki/Cheat_sheet
  # To use this: change the $osm_user strings in this file by an OSM user name (hard coded) or change the following line:
  osm_user=Mayeul
  # Might not work with strange characters in name ( !i! ?)
  wget -q -O - https://api.openstreetmap.org/api/0.6/changesets?display_name=$osm_user | sed -e 's_.*changeset id="\([0-9]\+\)".*_\1_' | grep -v "<" > my_changesets.txt
  echo "Processing changeset:"
  while read changeset_id
  do
  echo $changeset_id
  wget  -q -O - https://www.openstreetmap.org/api/0.6/changeset/$changeset_id/download | grep "<tag k" | sed -e 's/ \+<tag k="//g' | sed  -e 's/" v="/=/' | sed -e 's_"/>__' >> tmp_$osm_user.txt
  done < my_changesets.txt
  sort tmp_$osm_user.txt | uniq -c | sort -b -n -r > favorite_tags_$osm_user.txt