[Python] Overpass : null geometry for center of ways

Discussão em 'Python' iniciado por Stack, Março 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to extract some ways of OpenStreetMap by using Overpass on a specific tag. The trick is to replace the LineString geometries by a Point center. To doing that, the request I used was :

    area[name="Strasbourg"]->.targetArea;
    (
    way["type:FR:FINESS"](area.targetArea);
    );
    out center;


    It worked fine and I can get info and geometry by exporting the GeoJSON from Overpass-turbo and open it in a software like QGIS :

    [​IMG]

    I tried to adapt this in a Python script in order to automatize the process :

    import overpass
    import pandas as pd
    import geopandas as gpd

    api = overpass.API()
    r = api.get(f"""
    area[name="Strasbourg"]->.targetArea;
    (
    way["type:FR:FINESS"](area.targetArea);
    );
    out center;
    """)
    df = pd.json_normalize(r["features"])


    But in the first df's columns, I've got for geometry LineString and null coordinates, unlike the Overpass-turbo manual export :

    [​IMG]

    What did I miss ? I tried to update the end of request with something like :

    out geom;
    out center;


    Without any success.

    Continue reading...

Compartilhe esta Página