How to Identify Administrative Areas Along a Route

API or service
Routing API
Task
Route waypoints → countries, regions, and crossing positions
Examples
URL
Difficulty
Beginner
Time
5 min

Identify administrative areas along a route

You have an origin and destination and need to know which countries, states, or regions the calculated road route crosses. The Routing API can add administrative areas and crossing indexes to the route response with details=admin_areas.

Use this detail for a route summary or to locate boundary changes along its geometry. The examples use a single driving leg so its crossings can be matched directly to the returned route line.

Task flow: two route waypoints → Routing API with details=admin_areas → area list and boundary crossings.

Request administrative area crossings

Provide two waypoints in latitude,longitude order, separated by |. Set mode=drive and add details=admin_areas. The default GeoJSON response includes route geometry; each point in features[0].geometry.coordinates[0] uses [longitude, latitude] order.

This route starts in Dresden, Germany, and ends in Málaga, Spain. It has one leg and crosses Germany, France, and Spain:

https://api.geoapify.com/v1/routing?waypoints=51.0493286,13.7381437|36.7213028,-4.4216366&mode=drive&details=admin_areas&apiKey=YOUR_API_KEY

Reduced response: All 13 administrative areas and 12 crossings are shown. Route geometry, steps, and unrelated properties are omitted.

{
  "features": [
    {
      "properties": {
        "country_code": ["de", "fr", "es"],
        "admin_areas": [
          {"country_code": "de", "country_text": "Deutschland", "state_code": "sn", "state_text": "Sachsen"},
          {"country_code": "de", "country_text": "Deutschland", "state_code": "by", "state_text": "Bayern"},
          {"country_code": "de", "country_text": "Deutschland", "state_code": "bw", "state_text": "Baden-Württemberg"},
          {"country_code": "fr", "country_text": "France", "state_code": "ges", "state_text": "Grand Est"},
          {"country_code": "fr", "country_text": "France", "state_code": "bfc", "state_text": "Bourgogne-Franche-Comté"},
          {"country_code": "fr", "country_text": "France", "state_code": "ara", "state_text": "Auvergne-Rhône-Alpes"},
          {"country_code": "fr", "country_text": "France", "state_code": "pac", "state_text": "Provence-Alpes-Côte d'Azur"},
          {"country_code": "fr", "country_text": "France", "state_code": "occ", "state_text": "Occitanie"},
          {"country_code": "es", "country_text": "España", "state_code": "ct", "state_text": "Catalunya"},
          {"country_code": "es", "country_text": "España", "state_code": "vc", "state_text": "Comunitat Valenciana"},
          {"country_code": "es", "country_text": "España", "state_code": "cm", "state_text": "Castilla-La Mancha"},
          {"country_code": "es", "country_text": "España", "state_code": "mc", "state_text": "Región de Murcia"},
          {"country_code": "es", "country_text": "España", "state_code": "an", "state_text": "Andalucía"}
        ],
        "admin_area_crossings": [
          {"from_admin_index": 0, "to_admin_index": 1, "begin_shape_index": 2425, "end_shape_index": 2427},
          {"from_admin_index": 1, "to_admin_index": 2, "begin_shape_index": 5336, "end_shape_index": 5344},
          {"from_admin_index": 2, "to_admin_index": 3, "begin_shape_index": 8892, "end_shape_index": 8897},
          {"from_admin_index": 3, "to_admin_index": 4, "begin_shape_index": 9259, "end_shape_index": 9293},
          {"from_admin_index": 4, "to_admin_index": 5, "begin_shape_index": 14526, "end_shape_index": 14548},
          {"from_admin_index": 5, "to_admin_index": 6, "begin_shape_index": 18474, "end_shape_index": 18496},
          {"from_admin_index": 6, "to_admin_index": 7, "begin_shape_index": 18926, "end_shape_index": 18927},
          {"from_admin_index": 7, "to_admin_index": 8, "begin_shape_index": 22008, "end_shape_index": 22010},
          {"from_admin_index": 8, "to_admin_index": 9, "begin_shape_index": 27089, "end_shape_index": 27092},
          {"from_admin_index": 9, "to_admin_index": 10, "begin_shape_index": 29648, "end_shape_index": 29649},
          {"from_admin_index": 10, "to_admin_index": 11, "begin_shape_index": 29777, "end_shape_index": 29803},
          {"from_admin_index": 11, "to_admin_index": 12, "begin_shape_index": 31833, "end_shape_index": 31834}
        ]
      }
    }
  ]
}

The first two crossings change German states. The third changes from Baden-Württemberg, Germany, to Grand Est, France. The values above come from the same single-leg route used in the Routing backend's administrative-area contract test.

Read areas and crossing positions

For a single-leg GeoJSON route, read features[0].properties.admin_areas as the indexed list of countries and states or regions. country_code and state_code are lower case; country_text and state_text provide display names when available. The feature's country_code array gives the distinct countries on the route without the state-level detail.

Each admin_area_crossings item points from one entry in admin_areas to another. begin_shape_index and end_shape_index refer to positions in features[0].geometry.coordinates[0], the route's first line. Use the coordinates at those positions to locate the transition on a map. Route step admin_area arrays identify the areas touched by a step; a step covering a boundary can contain more than one index.

For a route that stays within one administrative area, the crossing list is empty. For example, this short route within Dresden requests the same detail:

https://api.geoapify.com/v1/routing?waypoints=51.0493286,13.7381437|51.042327,13.736214&mode=drive&details=admin_areas&apiKey=YOUR_API_KEY

Reduced response:

{
  "features": [
    {
      "properties": {
        "country_code": ["de"],
        "admin_areas": [
          {"country_code": "de", "country_text": "Deutschland", "state_code": "sn", "state_text": "Sachsen"}
        ],
        "admin_area_crossings": []
      }
    }
  ]
}

For routes with multiple legs, the feature-level admin_areas list combines areas from the legs, but its admin_area_crossings list is empty. Request one leg when you need crossing positions across the complete route.