Documentation

Introduction

OpenStreetMap is an amazing source getting free map data from. One of the things that's great is that it has administrative boundaries for most of the world. Borders for countries, states, counties, municipalities and so forth that is.

This site aims to provide you a service for extracting such data as GeoJSON, which can then either be used as is, converted into other formats, or imported into another database. The data we provide is data based on OpenStreetMap.org's tag boundary=administrative.

Browsing the data

At the Map page you will find a browsing tree to the left and a map to the right. With these you can preview and select the data, and then later on download it.

The tree is based on the administrative levels of the boundaries. Boundaries fitting inside another boundaries is placed as a child to the outer one, and that's how the tree is built. Each level in the tree is sorted on the administrative level and then on the name.

You can either select a whole country, or expand it and look for specific areas in the world. Any select or de-select in the tree will update the map, showing the data that you just selected. Each administrative level has its own color on the polygons shown. The map automatically centers on the first selected polygon, after that you have to pan and zoom the map yourself.

The data tree supports right clicking by the mouse. From there you get access to additional smooth functions, for example selecting all children, or a specific administrative level.

Multiple databases

There is also a database selector below the map. This shows the different data-sets we have imported. By changing the selector you change which database the web fetches its information from. The Download form will respect this selector as well. Note that changing the selector will clear all selections in the tree, and the map.

The first item is called Latest and will always point to the latest, enabled, and fully imported database.

If the database says that it's Partially ready it means that all data has been imported, but all the postprocessing isn't complete yet. The data has been imported using SRID 4326, and is downloadable in this format. All other SRIDs needs postprocessing and may or not be ready. Also the land-only polygons may not be ready.

It takes over three weeks to postprocess all the data needed. Creating a land-only polygon for Chile alone requires ~21 days. If you try to download data that isn't ready yet your download job will return an error saying that it's postponed. Meanwhile the needed data has received a higher priority in the background processing queue. We can not predict the time it will take to make it ready though. It can be anything from minutes up to weeks.

What's imported?

The import from OpenStreetMap used to be based on these rules:

  • boundary=administrative and neither name or admin_level is null
  • boundary=region and name (or name:en) matches Antarctic
  • boundary=disputed
  • boundary=historic (databases newer than 2021-01-04)
  • boundary=census (databases newer than 2021-01-04)
  • boundary=area (databases newer than 2021-01-04)
  • boundary=political (databases newer than 2021-01-04)
  • boundary=ceremonial (databases newer than 2021-02-01)
  • boundary=traditional (databases newer than 2021-02-01)
  • Relation 2185386 (United States Minor Outlying Islands)

Database 2021-03-08 was imported using these rules:

  • boundary, name and admin_level is set, or
  • boundary=region and name is Antarctica (in various variants), or
  • boundary=traditional or census, even though for example admin_level isn't set, or
  • Relation 2185386 (United States Minor Outlying Islands)

Databases with dates 2021-03-15 or later are using these rules:

  • boundary and name is set, or
  • Relation 2185386 (United States Minor Outlying Islands)

We are open to suggestions for importing other data as well. Please provide us with links to the relations at OpenStreetMap.org and some description to what it is. For example we know that there are ~12,500 polygons which have boundary=administrative but a null value for either admin level or the name. We have not looked into these, but our guess is that it will mostly create chaos if importing them all. We are guessing that most is trash data.

In some cases, including the above actually used rules, it might be better to fix the OpenStreetMap data though.

An import of a new database requires approximately 3 weeks for processing the data. It varies quite a lot between the different versions of Planet.osm. We haven't investigated why, but it's likely that there at times are invalid data that's causing a lot of issues for PostgreSQL/PostGIS.

Projection

OpenStreetMap originally stores its data in SRID 4326. That's also what we use when we import the data. This means that we do not have any loss in quality and don't need to do any unnecessary transformation. In our end SRID 3857 would have required a lot less resources though.

Downloading the data

To be able to download any data you must authenticate. You need an OpenStreetMap account for this. The authentication is done using oAuth.

Downloads can either be based upon the selection made in the tree, or a single selected country in the Download form. Added to this there are multiple filters and options available to help you streamline the data you download. For example you can specify the minimum and maximum administrative levels that you are interested in. This can significantly reduce the size of the downloaded file.

Boundaries in the OpenStreetMap data often extends into the sea, far beyond the coast line. By selecting the option Land only you will download polygons we have prepared to follow the coast line instead, these are often a lot more complex and might use a lot of resources.

If you wish you can select one of the Simplify levels in the select box with the same name. If so, the data downloaded will use less vertices and therefore be less complex. The down-side is that it's also less accurate. Generally it's not recommended to use values above 1.

OpenStreetMap has a lot of different tags for each polygon in their data-set. Normally we don't include them all in the downloaded data since most just wants the polygon data itself, buy checking the Include All tags option you can change this behaviour. The most common tags are names with different translations. You can preview a polygons tags by right clicking it in the tree, selecting Info and then Show all tags.

Download times might be fairly long, depending on how complex the data is that you have requested. While it should work fine to download it via your web browser we generally suggest that you use the CLI tool Curl to download it. The Download form provides a download url, a full Curl command line, and a Download button.

Downloaded data is by default in gzipped GeoJson format, but other formats are available as well. After unzipping it you can view the data in QGIS for example, or import it into PostGIS.

We strongly suggest that you check the returned http code, anything but 200 should be considered some form of error.

Any map data downloaded follows the License of OpenStreetMap.

Continents

We would love to have support for Continents but that's not something that exists (as boundaries) in OpenStreetMap data. It's not always obvious where the border between them would be either.

Support, ideas, thoughts and feature requests

Please use the Feedback button on the right side for questions and ideas. It helps us keep track of them, and potential answers will also be available for others. Also feel free to vote for suggestions by others that you like, this will help us prioritize tasks. But also be aware of this being a side-project which doesn't have any dedicated human resources. There will be periods where we pretty much doesn't touch it, therefore response times may be longer than wished for.