I am working on a personal project that requires OpenStreetMap boundary information, specifically the relations data for administrative area boundaries worldwide. I attempted to download data from GeoFabrik, but the files are too large (100GB+) and require extensive manual post-processing. I also tried osm-boundaries, but it is not free and lacks batch downloads. Since I only need the relations data for administrative boundaries(for land only, waters not included), which I believe should be significantly smaller in size, I was wondering if someone could provide this data in a post-processed, easy-to-use format if the size of this dataset is manageable.
According to this page OSM-Boudaries is free for active contributors.
You can use https://overpass-turbo.eu annd search for boundary=administrative. Adding admin_level=1 or 2 or … 10 to the search selects country, state, county, city, … level data
Please clarify: Do you need all of the admin_levels? That would be about 2 million polygons.
I think one relatively easy way to get all the boundaries is to use GeoDesk.
- Download a planet file
- Convert into a GeoDesk database file:
gol build planet.gol planet.osm.pbf
- Query for any
boundary=administrative
and export to a file:gol query --format=geojsonl planet.gol "a[boundary=administrative]" > osm_administrative_boundaries.geojsonl
This requires about 250 GB of disk space and 1 to a few hours of processing, depending on your hardware, though.
Note that your “land only, not water” request also means you cannot use the relations as-is, you will have to intersect them with the landmass polygons. This can be done e.g. in PostGIS (after using osm2pgsql
to import the OSM data - with a suitably filtered import configuration this should require less than 50 GB disk space).
Edit: Here’s a query to the “postpass” server that gives you a ~780 MB GeoJSON with all adminlevel 2 boundaries (i.e. country boundaries):
curl -ocountries.geojson \
-g http://postpass.geofabrik.de/api/0.2/interpreter \
--data-urlencode "data=
SELECT *
FROM postpass_polygon
WHERE tags?'boundary'
AND tags->>'boundary'='administrative'
AND tags->>'admin_level'='2'"
This takes 3 or 4 minutes. But as I said above, it will give you the plain OSM relation polygons, not intersected with landmass.
The basic tier is always free. The “Explorer” tier is free for everyone during the beta now, which includes territorial land polygons.