[Python] osmnx out of memory if run with...

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I found that

    ox.setting.overpass_settings=f"[out:json][timeout:{ox.settings.requests_timeout}][date:\"{date}\"]"


    easily create an out of memory error from overpass API. here a snap of my code.

    import osmnx as ox
    import shapely
    import datetime

    date=datetime.datetime.fromisoformat("2023-12-31T10:15:23.355030")
    poli="POLYGON ((12.492709372340677 41.916655635027965, 12.495766040251999 41.99143760629819, 12.76378053852936 41.984419025131984, 12.754692779733519 41.78305304410847, 12.487561402159495 41.79004473805951, 12.48453188956227 41.715248372182295, 12.21767031884794 41.72151888179064, 12.224974122071886 41.92295004575664, 12.492709372340677 41.916655635027965))"
    ox.settings.requests_timeout=200
    ox.settings.use_cache=False
    ox.settings.log_console = True
    ox.settings.overpass_settings=f"[out:json][timeout:{ox.settings.requests_timeout}][date:\"{date}\"]"
    geom=shapely.wkt.loads(poli)
    tags={"highway":"residential"}
    features = ox.features_from_polygon(
    geom,
    tags,
    )
    print(len(features))


    if line 10 is commented the code runs smoothly.

    is there an error in my code? Please help

    Continue reading...

Compartilhe esta Página