8

enter image description here

I'm trying to extract the Jordanian country border from an OpenStreetMap. When I click the download link for the file, the following page opens:

enter image description here

How do I save these XML tags as an XML- or OSM file which I can convert into a shapefile, so that I can use it in QGIS?

2
  • 1
    Its already in XML, and QGIS can use OSM already. Have you already looked at Natural Earth as a source of country borders? Have you looked at the Overpass API?
    – BradHards
    Commented Jan 29, 2015 at 6:49
  • There is this tool now: osm-boundaries.com
    – four-eyes
    Commented Oct 13, 2022 at 17:58

4 Answers 4

5

If you want to convert it to a Shapefile just download the xml (for example right-mouse-click on the download link and choose something like "save target as..." instead of opening it in the browser. then in Qgis choose "add vectorlayer" or use drag and drop to add your xml layer to your Qgis project. then save layer as shapefile. If you are just looking for the borders and it does not have to be OSM you could also have a look at http://gadm.org

5

There is a service that allows you to retrieve any administrative border from OpenStreetMap in a number of formats. https://osm.wno-edv-service.de/boundaries/

4
  • thank you, your answer is very useful, I really appreciate what you are doing Commented Feb 1, 2015 at 7:00
  • 1
    This link is now dead, sadly.
    – Bing
    Commented Jan 4, 2017 at 18:04
  • The application says, it's available here now: wambachers-osm.website/boundaries
    – ulrich
    Commented Dec 1, 2017 at 10:18
  • 2
    I used that service, but it's down :-( Will add another comment more lower
    – Jachym
    Commented Jun 12, 2020 at 6:24
5

The most simple query I came with using Overpass turbo https://overpass-turbo.eu/ is

[out:json];
relation["boundary"="administrative"]["admin_level"="4"]["name"="Bayern"];
out geom;

With list of administrative levels for each country from List of the levels for each country: https://wiki.openstreetmap.org/wiki/Tag:boundary=administrative

Result can be downloaded as GeoJSON.

1
2

If you wish to retrieve the OSM Raw XML, that is how Overpass API query would look like:

http://www.overpass-api.de/api/interpreter?data=[bbox];(way[admin_level="2"];way[border_type="nation"];);(._;>;);out body qt;&bbox=112.5,31.9521,123.75,40.9798

Please replace that &bbox=112.5,31.9521,123.75,40.9798 with coordinates of the region of your interest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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