Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem downloading Relation of type "MultiPolygon" #1028

Closed
3 tasks done
nonZero opened this issue Jul 2, 2023 · 1 comment
Closed
3 tasks done

Problem downloading Relation of type "MultiPolygon" #1028

nonZero opened this issue Jul 2, 2023 · 1 comment
Labels

Comments

@nonZero
Copy link

nonZero commented Jul 2, 2023

Contributing guidelines

  • I understand the contributing guidelines

Documentation

  • My problem is not addressed by the documentation or examples

Existing issues

  • My problem does not appear in an existing issue

What operating system and Python version are you using?

Arch Linux

What OSMnx version are you using?

1.5.0

Environment packages and versions

.

How did you install OSMnx?

Pip

Problem description

While trunig to fetch:
https://www.openstreetmap.org/relation/6195356
This code:

ox.geocoder.geocode_to_gdf("R6195356", by_osmid=True)

Raises:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[102], line 1
----> 1 ox.geocoder.geocode_to_gdf("R6195356", by_osmid=True)

File ~/.virtualenvs/p311/lib/python3.11/site-packages/osmnx/geocoder.py:123, in geocode_to_gdf(query, which_result, by_osmid, buffer_dist)
    121 gdf = gpd.GeoDataFrame()
    122 for q, wr in zip(query, which_result):
--> 123     gdf = pd.concat([gdf, _geocode_query_to_gdf(q, wr, by_osmid)])
    125 # reset GeoDataFrame index and set its CRS
    126 gdf = gdf.reset_index(drop=True)

File ~/.virtualenvs/p311/lib/python3.11/site-packages/osmnx/geocoder.py:172, in _geocode_query_to_gdf(query, which_result, by_osmid)
    169 # choose the right result from the JSON response
    170 if not results:
    171     # if no results were returned, raise error
--> 172     raise ValueError(f"Nominatim geocoder returned 0 results for query {query!r}")
    174 elif by_osmid:
    175     # if searching by OSM ID, always take the first (ie, only) result
    176     result = results[0]

ValueError: Nominatim geocoder returned 0 results for query 'R6195356'

This overpass turbo does not return anything:

[out:json][timeout:25];
rel(6195356);
out;

But this does:

[out:json][timeout:25];
rel(6195356);
(._;>;);
out;

Complete minimal reproducible example

ox.geocoder.geocode_to_gdf("R6195356", by_osmid=True)
@nonZero nonZero added the bug label Jul 2, 2023
@gboeing
Copy link
Owner

gboeing commented Jul 3, 2023

If you turn on ox.settings.log_console = True you can see exactly what server requests OSMnx is making. In your case, it's requesting https://nominatim.openstreetmap.org/lookup?format=json&polygon_geojson=1&osm_ids=R6195356 If you click the link, you can see that it indeed returns no results from Nominatim. So OSMnx is handling it correctly... this relation doesn't exist in Nominatim.

However, as you note this relation does exist on OpenStreetMap, so you may want to request a fix upstream---either at Nominatim or OpenStreetMap, depending on where exactly the data discontinuity is occurring.

For an example of a relation that is working/available, see https://nominatim.openstreetmap.org/lookup?format=json&polygon_geojson=1&osm_ids=R165475

@gboeing gboeing closed this as completed Jul 3, 2023
@gboeing gboeing added notabug and removed bug labels Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants