Leaf: Administrative Units Dataset: OpenStreetMap — boundary=administrative

OSM carries administrative boundary relations globally, tagged with admin_level=*. The numeric level indicates hierarchical tier but the meaning varies by country.

Global admin_level conventions (varies by country):

admin_levelCommon use
2National boundary
4State / region / province
6County / department
7–8Municipality / district
9–10Sub-municipal (ward, parish)

Per-country mappings: https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative

import osmnx as ox
ox.settings.cache_folder = ".cache/"
 
# Geocode a named area to its boundary polygon
gdf = ox.geocode_to_gdf("Copenhagen Municipality, Denmark")
 
# Get all municipalities in a country
municipalities = ox.features_from_place(
    "Denmark",
    tags={"boundary": "administrative", "admin_level": "7"}
)

Overpass (fallback)

[out:json][timeout:120];
(
  relation["boundary"="administrative"]["admin_level"="7"]["ISO3166-1"="DK"];
);
out body; >; out skel qt;

Key OSM tags

TagMeaning
boundary=administrativeAdministrative boundary relation
admin_level=*Hierarchy level (country-specific meaning)
name=*Official name
name:en=*English name
ISO3166-1=*ISO country code (level 2)
ISO3166-2=*ISO sub-national code
ref=*Official code reference