[OSM-newbies] using the Overpass API
MERIGHI Marcus
mcmer-osm-newbies at tor.at
Mon May 20 17:50:03 UTC 2013
andrew.salzberg at gmail.com (Andrew Salzberg), 2013.05.17 (Fri) 19:27 (CEST):
> just trying out the overpass API - very happily able to build scripts here
> in overpass turbo that run great (http://overpass-turbo.eu/) but wanted to
> take the next step and a) write a script in text file and b) send a request
> via bash so that ultimately I can write a script to loop this for a few
> cases.
>
> I'm basically an API newb (not just an OSM API newb) so I'm able to do
> things like write a GET request but I'm not sure what the actual address I
> should be putting in my request to overpass is? Try as I might I can't find
> it in here: http://wiki.openstreetmap.org/wiki/Overpass_API I have working
> .txt file with an <osm_script> in it that I'd like to send via bash to
> overpass... if that makes sense.
> any help much appreciated.
my script below and attached, not used for about two years:
bye, marcus
#!/bin/sh -e
# 14.0498277 48.3033928 14.6455346 48.5420446
# lon-min lat-min lon-max lat-max
# top/max left/max bottom/min right/min
# lon=laenge, lat=breite
lonmin="${1}"
latmin="${2}"
lonmax="${3}"
latmax="${4}"
#
# get data of larger areas from:
#
# http://wiki.openstreetmap.org/wiki/Overpass_API
# http://overpass.osm.rambler.ru/ (production)
# http://www.overpass-api.de/ (testing)
#
# our query will be:
#
# union means: put all query results in to one result set
# <union>
# we do a even more comprehensive search than recommended in
# http://wiki.openstreetmap.org/wiki/Overpass_API#The_map_query
# because simplifyway does not like missing nodes/ways.
#
# first get all nodes for the bbox
# <bbox-query s="51.249" n="51.251" w="7.148" e="7.152"/>
# get all relations from nodes; keep default variable "_" populated
# with bbox query by putting result into "rels"
# <recurse type="node-relation" into="rels"/>
# get all ways from nodes, fill default variable "_" with result
# <recurse type="node-way"/>
# get all relations for just discovered ways; keep result of node-way by
# putting new results into var "waysrels"
# <recurse type="way-relation" into="waysrels"/>
# finally get all nodes for these ways, accessing default variable "_" which
# was filled by way-relation above
# <recurse type="way-node"/>
# </union>
# we want the result with all data (user, version, timestamp, ...) so we can
# open it in JOSM and others
# <print mode="meta"/>
#
# The attributes n and s are used for the latitudes of the
# bounding box, w and e for the longitudes. See more details
# about bbox below.
# s the southern limit (bottom lat)
# n the northern limit (top lat)
# w the western limit (usually lower lon)
# e the eastern limit (usually higher lon)
#
# possible values of recurse:
# relation-relation, relation-backwards, relation-way,
# relation-node, way-node, way-relation,node-relation, node-way
#
# create the url to query
url="http://overpass.osm.rambler.ru/cgi"
url="${url}/interpreter"
url="${url}?data="
url="${url}%3Cunion%3E"
url="${url}%3Cbbox-query%20s=%22${latmin}%22%20n=%22${latmax}%22%20w=%22${lonmin}%22%20e=%22${lonmax}%22/%3E"
url="${url}%3Crecurse%20type=%22node-relation%22%20into=%22rels%22/%3E"
url="${url}%3Crecurse%20type=%22node-way%22/%3E"
url="${url}%3Crecurse%20type=%22way-relation%22%20into=%22waysrels%22/%3E"
url="${url}%3Crecurse%20type=%22way-node%22/%3E"
url="${url}%3C/union%3E"
url="${url}%3Cprint%20mode=%22meta%22/%3E"
# now get the stuff and print it to stdout
lynx -dump "${url}"
#
# does not work, ways/nodes missing
# lynx -dump "http://www.overpass-api.de/api/xapi?*[bbox=${bboxstr}][@meta]" \
# print "getting osm data from http://www.overpass-api.de/api/xapi?*[bbox=${bboxstr}][@meta]"
# print "getting osm data from http://api1.osm.absolight.net/api/0.6/map?bbox=${bboxstr}"
> !DSPAM:519668b88291234514069!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: geo-osm-get.sh
Type: application/x-sh
Size: 2871 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/newbies/attachments/20130520/6e0a7f52/attachment.sh>
More information about the newbies
mailing list