[Python] Does geopandas overestimate distances?

Discussão em 'Python' iniciado por Stack, Julho 4, 2025.

  1. Stack

    Stack Membro Participativo

    I was recently doing some statistics based on openstreetmaps. When I used overpass to export the German Autobahnen and geopandas to calculate their length, I found that the lengths do not match the official figures.

    The total length calculated should be roughly the double of the length given by the German ministry of infrastructure (BMVI), since both directions of the highways are mapped separately. The overpass query already excludes connecting ramps, exits, (...).

    Comparing the longest dozen of them, most were obviously overestimated, because the figures were 50/60% higher than the official ones. (See image)

    [​IMG]

    Whats the reason for that difference?

    Overpass-code:

    [out:json][timeout:100];
    {{geocodeArea:Deutschland}}->.searchArea;
    way["highway"="motorway"]["ref"="A 7"](area.searchArea);
    out body;
    >;
    out skel qt;


    Code (python)

    import geopandas as gpd
    import pandas as pd

    autobahn = "A7"
    columns = ["ref", "length_m"]

    df_total = pd.DataFrame(columns=columns)

    gdf = gpd.read_file(f"https://fliessbaden.de/wp-content/uploads/A7.geojson")
    gdf = gdf.to_crs(epsg=3857)

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

    total_m = gdf['length_m'].sum()
    total_km = total_m / 1000
    print(autobahn + ": " + str(round(total_km, 2)) + " km")

    Continue reading...

Compartilhe esta Página