9

I'd like to write an iPhone app which uses OSM data to map canals. The data is tagged in OSM as canals, but I'm not entirely sure how to download it. Libraries like route-me don't seem to provide a way to download the data. Ideally I'd like to give the user the option to download certain counties, then scrape certain OSM data tag types.

How would I go about this?

2
7

Now you can also use Overpass API to query and export OSM data by tags like "canal" (and also by area). It is more suitable for small to mid-size selections. There is a easy-to-use user interface called Overpass Turbo, where you can type Overpass API queries and immediately display the selection on map.

Below is an example query that return all ways and relations with tagged "canal":

[out:json][timeout:100];
(
  node["waterway"="canal"]({{bbox}});
  rel["waterway"="canal"]({{bbox}});
);

out body;
>;
out skel qt;
5

Using the Mapquest Open XAPI you can retrieve XML for specific tags within a Bounding Box.

using http://open.mapquestapi.com/xapi/api/0.6/way%5Bwaterway=canal%5D%5Bbbox=-77.09307755077849,38.86329811515983,-76.95574844922147,38.92342116108839%5D

(based on the OpenStreetMap setup)

http://open.mapquestapi.com/xapi/api/0.6/way%5Bwaterway=canal%5D%5Bbbox=-77.09307755077849,38.86329811515983,-76.95574844922147,38.92342116108839%5D

will give you [snippets of real output]

coordinates:

<osm version="0.6" generator="Osmosis SNAPSHOT-r26564"><bound box="38.86330,-77.09308,38.92342,-76.95575" origin="Osmosis SNAPSHOT-r26564"/><node id="358958293" version="2" timestamp="2011-11-22T12:30:05Z" uid="247807" user="asciiphil" changeset="9908359" lat="38.904195" lon="-77.0605756"/><node id="358958295" version="2" timestamp="2011-11-22T12:30:05Z" uid="247807" user="asciiphil" changeset="9908359" lat="38.9041242" lon="-77.0596134"/><node id="358958298" version="2" timestamp="2011-11-22T12:30:05Z" uid="247807" user="asciiphil" changeset="9908359" lat="38.9040396" lon="-77.0585653"/>

<way id="137952708" version="1" timestamp="2011-11-22T12:25:19Z" uid="247807" user="asciiphil" changeset="9908359"><nd ref="358958295"/><nd ref="1512668283"/><tag k="source" v="USGS Ortho"/><tag k="gnis:created" v="02/01/1991"/><tag k="gnis:county_id" v="001"/><tag k="name" v="Chesapeake and Ohio Canal"/><tag k="lock" v="yes"/><tag k="gnis:feature_id" v="530605"/><tag k="gnis:state_id" v="11"/><tag k="lock_ref" v="3"/><tag k="disused" v="yes"/><tag k="waterway" v="canal"/>

Note: The bigger the bounding box the bigger the file will be and will crash the browser at some point.

4

The XAPI is a good way of going about it. If you have some time to kill and a speedy computer, you can experiment with doing your own extracts from the full Planet (http://planet.openstreetmap.org).

The tool to use for that is called Osmosis (http://wiki.openstreetmap.org/wiki/Osmosis/Detailed_Usage), and you can use its tag filter feature to pull just the canals, or any other thing you want, from the very large complete planet.

Sample:

bzcat planet-latest.osm.bz2 | osmosis --rx - --log-progress --tf accept-ways waterway=canal  --tf reject-relations --used-node --wx - | bzip2 > just-canals.osm.bz2
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.