Question Details

No question body available.

Tags

python pandas geopandas overpass-api

Answers (2)

July 4, 2025 Score: 7 Rep: 1,728 Quality: Medium Completeness: 80%

You are projecting the data to EPSG:3857, which is a global Mercator projection. Mercator projects the globe to a flat map, retaining angles (useful for marine navigation), but distorting areas and distances more and more the farther they are from the equator. Hence, distances not being correct is to be expected.

The images below illustrate the distortions. The first illustration shows that a distance distortion of +60% is to be expected at ~50° north...

If you want to calculate distances in Europe, you can par example use the equidistant ESRI:102031 projection, which seerms consistent with what you are seeing.

EDIT: I added some more possible projections to the script as well as they were suggested by other users...

import geopandas as gpd
import pandas as pd

autobahn = "A7" columns = ["ref", "lengthm"] expecteddistance = 1924 print(f"{autobahn}, expected distance: {expecteddistance} km")

dftotal = pd.DataFrame(columns=columns)

gdf = gpd.readfile(f"https://fliessbaden.de/wp-content/uploads/A7.geojson")

for crs in ["ESRI:102031", "EPSG:25833", "EPSG:32632", "EPSG:4839"]: gdf = gdf.tocrs(crs)

gdf["lengthm"] = gdf.geometry.length

totalm = gdf['lengthm'].sum() totalkm = totalm / 1000 print(f"{autobahn}, {crs} ({gdf.crs.name}): {str(round(totalkm, 2))} km")

Output:

A7, expected distance: 1924 km
A7, ESRI:102031 (EuropeEquidistantConic): 1929.86 km
A7, EPSG:25833 (ETRS89 / UTM zone 33N): 1938.05 km
A7, EPSG:32632 (WGS 84 / UTM zone 32N): 1935.2 km
A7, EPSG:4839 (ETRS89 / LCC Germany (N-E)): 1935.31 km

Illustration 1: distance distortions on a Mercator map

enter image description here Source

Illustration 2: size distortions on a Mercator map

The "small" sizes are the actual sizes on the globe, the incorrect "large" ones are due to the distortions of the Mercater projection.

By Jakub Nowosad - Own work, CC BY-SA 4.0

July 4, 2025 Score: 1 Rep: 11,742 Quality: Low Completeness: 40%

Just convert your Mercator coordinate system to a Lambert Projection.

import geopandas as gpd

gdf = gpd.readfile(f"https://fliessbaden.de/wp-content/uploads/A7.geojson")

gdf2 = gdf.to
crs("4839")

gdf2.length.sum() / 1000 # 1935.3071447893633