OpenStreetMap

Your personal little tagwatch script

Posted by vibrog on 26 September 2008 in English (English)

curl -g "http://osmxapi.hypercube.telascience.org/api/0.5/*[osm:user=$username]" \
| grep '<tag ' | sed -E "s/<tag k='(.*(name|ref)|note|ele|layer|is_in)' v=.*\/>/<tag k=\'\1\' v='*'\/>/" \
| sort | uniq -c

Example output (shortened):


117 <tag k='bicycle' v='yes'/>
1075 <tag k='highway' v='footway'/>
489 <tag k='highway' v='track'/>
268 <tag k='highway' v='unclassified'/>
72 <tag k='landuse' v='farm'/>
284 <tag k='marked_trail' v='blue'/>
435 <tag k='name' v='*'/>
18 <tag k='natural' v='wood'/>
199 <tag k='route' v='ski'/>
118 <tag k='source' v='survey'/>
151 <tag k='tracktype' v='grade4'/>
9 <tag k='trail_visibility' v='intermediate'/>

Comment from Heinz on 26 September 2008 at 22:18

Hi,
Can you please give an example of the output? On my box sed doesn't have an -E option and complains.
Please explain what the script should do. Thanks
Heinz

Hide this comment

Comment from vibrog on 26 September 2008 at 23:36

-E is for extended regexp, e.g. used for the grouping, and inserting a group in the output using \1.

Hide this comment

Comment from Heinz on 27 September 2008 at 10:13

That explains it, thanks.
Using -r or --regexp-extended works now in my "GNU sed Version 4.1.5"
and shows interesting results.
Heinz

Hide this comment

Comment from vibrog on 27 September 2008 at 12:06

I'm glad you find it useful.
A further pipe through `sort -nr` will sort tags by frequency.

Hide this comment

Leave a comment

Parsed with Markdown

  • Headings

    # Heading
    ## Subheading

  • Unordered list

    * First item
    * Second item

  • Ordered list

    1. First item
    2. Second item

  • Link

    [Text](URL)
  • Image

    ![Alt text](URL)

Login to leave a comment