This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

export boundaries

1

I am trying to get the longitude/latitude points for the admin boundary for the entire US coast. Can I get this data from your site? If so, how?

asked 22 Sep '11, 17:11

ljd's gravatar image

ljd
16111
accept rate: 0%


One Answer:

1

My answer is valid for all countries:

First, you have to find the entity representing the admin boundary. Usually, country borders are identified by an OSM relation of type boundary=administrative with admin_level=2. One method to find it is to use an OSM editor and download an area where you know that the boundary is present and seek the relation id.
But you can also use the 'search' tool from the main page (called Nominatim). If you enter e.g "Washington", you get a list of place entities containing this word. But more interesting, you also find a link to the nominatim home page : http://nominatim.openstreetmap.org/. If you type "Washington" again there, you will find the same list of results and one of them is "Washington, Fairfax, District of Columbia, United States of America, North America (City) (details)". If you click on the "details" link, you will find the node id 424317935 and its URL in OSM site. Here, you can see that the node is part of the relation "United States of America (148838) (as label)" (at the bottom).

Next, you have different ways to retrieve the relation 148838 and all its members, the collection of ways and nodes representing the admin boundary. The problem is the size of this relation. It is normally possible to retrieve all information in one request to the OSM server but this will fail for such big relations. I know a python script which downloads all relation members one by one. But you can also use the editor JOSM and the command "Download object..." where you specify the Object type "node" and Object ID "424317935" with the option "Download referrers". Then, save the content with the menu "File" -> "Save As...". You have now an XML file containing all ways and nodes with their lat/lon coordinates. If you need a shapefile, you will have to use a script converting OSM data to this format.

Be aware that many countries have more than one relation identifying the boundary (e.g. with and without the territorial waters).

answered 22 Sep '11, 20:04

Pieren's gravatar image

Pieren
9.8k2083157
accept rate: 15%

Source code available on GitHub .