Distance between Spanish municipalities
Pick two municipalities in Spain to see how far apart they are in a straight line and, with one tap, by road, with both drawn on the map.
Straight-line distance
Pick two municipalities to see the distance.
Driving distance
Loading the map…
Distance is measured between the main towns of the two municipalities (their seats), in a straight line on the WGS84 ellipsoid.
How to use it
Type the name of the first municipality and pick it from the list, then do the same for the second. All 8,132 municipalities in Spain are there. Accents are optional, and where a place has two official names, one in Spanish and one in Catalan, Galician or Basque, either one works (Alacant or Alicante, Donostia or San Sebastián). When several share a name, each one shows its province underneath.
The straight-line distance appears right away, in kilometers, the unit used in Spain; switch to miles with one tap and the tool remembers your choice. Tap “Get the driving distance” to add the road distance, an approximate driving time and the route on the map. The link keeps both municipalities, so you can share it.
What a Spanish municipality is
Spain divides almost all of its land into municipalities (municipios), each run by its own town council, the ayuntamiento. There are 8,132 of them, from Madrid, with more than three million people, to mountain villages with a few dozen. Unlike in the US, there’s no unincorporated land: open countryside, forests and beaches all belong to some municipality. Only a few commons are shared by several at once, such as the Bardenas Reales in Navarre.
Each municipality has a main town, its seat, which almost always gives the municipality its name, and it may include smaller villages and hamlets as well. Municipalities are grouped into 50 provinces, plus the autonomous cities of Ceuta and Melilla, and provinces into 17 autonomous communities, Spain’s regions.
Madrid to Toledo
In a straight line, Madrid and Toledo are 68.6 km (42.6 miles) apart, measured from the main town of each: Toledo lies southwest of Madrid. The road distance is always longer, because roads bend around hills, rivers and towns.
The two Spanish municipalities farthest from each other are Portbou (Girona) and El Pinar de El Hierro (Santa Cruz de Tenerife): 2,514 km as the crow flies, from the French border on the Mediterranean to the westernmost of the Canary Islands.
Where it measures from
A municipality is an area, not a point, so the tool measures between the main towns: the point of each municipality’s seat in the official gazetteer of Spain’s National Geographic Institute (IGN). In a large municipality, an outlying village can be quite a bit closer or farther than its seat.
Straight-line distances are calculated on the WGS84 ellipsoid, the Earth model GPS uses, to the millimeter. Driving routes come from OpenStreetMap through the FOSSGIS OSRM service and include ferries where needed, for example to the Balearic or Canary Islands, so the distance then includes the crossing by sea.
INE codes and the municipal register
Each municipality shows its INE code, the five-digit number Spain’s National Statistics Institute gives it. The first two digits are the province (28 is Madrid, 08 Barcelona, 41 Seville), so the code tells you where a place is even when two towns share a name, and it’s the key to join this list with any official dataset.
The population is the official figure from the padrón, the municipal register every resident has to sign up to, as of January 1, 2025. The INE publishes it every year, and it’s the number used for everything from council funding to how many councillors each town elects.
Why municipalities and not postal codes
Spain has five-digit postal codes too, but their boundaries are managed by Correos, the national postal service, and aren’t published as open data. Without those boundaries there’s no reliable way to measure between two postal codes. Municipalities, with their official IGN boundaries and INE codes, are the open alternative. To find the postal code of an address, use the Spain postal code lookup.
Distances between some well-known municipalities
| From | To | Straight line |
|---|---|---|
| Madrid | Toledo | 69 km (43 mi) |
| Barcelona | Girona | 86 km (53 mi) |
| Sevilla | Cádiz | 99 km (61 mi) |
| Bilbao | Donostia/San Sebastián | 76 km (47 mi) |
| València | Alacant/Alicante | 125 km (78 mi) |
| Santiago de Compostela | A Coruña | 56 km (35 mi) |
| Zaragoza | Huesca | 66 km (41 mi) |
| Palma | Eivissa | 128 km (79 mi) |
| Las Palmas de Gran Canaria | Santa Cruz de Tenerife | 90 km (56 mi) |
Frequently asked questions
Is it a straight-line or a driving distance?
Both: the straight-line distance appears right away, and the driving distance when you tap “Get the driving distance”, with an approximate driving time.
Which point of each municipality does it use?
The main town, the seat of the municipality, which is almost always the town it’s named after. Its point comes from the IGN’s official gazetteer.
Can I see it in miles?
Yes. It starts in kilometers, the unit used in Spain, and the km/mi switch changes every distance on the page. Your choice is remembered on the other Mapsfera tools.
Does it work for the Balearic and Canary Islands?
Yes. The straight line always works; the road route uses ferries where there are any, and tells you when there’s no way to drive between the two.
Why can’t I find a village I know?
Because the list is of municipalities, not of every village. Look for the municipality it belongs to, or use the distance between two points to measure from an exact spot.
Can I measure between Spanish postal codes?
No: Spanish postal code boundaries aren’t open data. For the US, where the Census Bureau publishes ZIP code areas, there’s the distance between ZIP codes tool.
How long does the drive take?
The time comes from OSRM using OpenStreetMap speed limits, without traffic or stops, so treat it as a rough guide.
Related tools
All toolsSources
- Official population figures from the municipal register, January 1, 2025 · INE (Spain’s National Statistics Institute). Mapsfera with data from the INE website: www.ine.es (updated December 11, 2025)
- Gazetteer of municipalities and municipal boundaries · Instituto Geográfico Nacional, Spain (CC BY 4.0 ign.es)
- Driving routes · FOSSGIS OSRM, with data © OpenStreetMap contributors
- Base map · OpenFreeMap, with OpenStreetMap data