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

ValueError: OSM did not return any polygonal geometries for query #82

Open
kamilkosek opened this issue Feb 25, 2022 · 1 comment
Open

Comments

@kamilkosek
Copy link

Hi all,
I just wanted to plot my 'hood' and some adjacent districts, so i basically took the example from the notebook and ran it.

from shapely.ops import unary_union
from shapely.affinity import *
from shapely.geometry import *
from descartes import PolygonPatch
from matplotlib import pyplot as plt
import matplotlib.font_manager as fm
import osmnx as ox
from prettymaps import *
import sys
from datetime import datetime
import re

sys.path.append('../')
fig, ax = plt.subplots(figsize = (15, 12), constrained_layout = True)
fig.patch.set_facecolor('#F9F8F8')

places = {
    'Wiesenau, Hannover, Deutschland': ['#49392C', '#77625C', '#B2B1CF', '#E1F2FE', '#98D2EB'],
    'Brink-Hafen, Hannover, Deutschland': ['#EEE4E1', '#E7D8C9', '#E6BEAE'],
    'Vinnhorst, Hannover, Deutschland': ['#BA2D0B', '#D5F2E3', '#73BA9B', '#F79D5C'],
}

for i, (place, palette) in enumerate(places.items()):
    plot(
        place,
        ax = ax,
        layers = {
            'perimeter': {},
            'streets': {
                'width': {
                    'trunk': 6,
                    'primary': 6,
                    'secondary': 5,
                    'tertiary': 4,
                    'residential': 3.5,
                    'pedestrian': 3,
                    'footway': 3,
                    'path': 3,
                }
            },
            'building': {'tags': {'building': True, 'leisure': ['track', 'pitch']}, 'union': False},
            'water': {'tags': {'natural': ['water', 'bay']}},
            'park': {'tags': {'leisure': 'park'}},
            'forest': {'tags': {'landuse': 'forest'}},
            'garden': {'tags': {'leisure': 'garden'}},
        },
        drawing_kwargs = {
            'perimeter': {'fill': False, 'lw': 0, 'zorder': 0},
            'park': {'fc': '#AABD8C', 'ec': '#87996b', 'lw': 1, 'zorder': 1},
            'forest': {'fc': '#78A58D', 'ec': '#658a76', 'lw': 1, 'zorder': 1},
            'garden': {'fc': '#a9d1a9', 'ec': '#8ab58a', 'lw': 1, 'zorder': 1},
            'water': {'fc': '#92D5F2', 'ec': '#6da8c2', 'lw': 1, 'zorder': 2},
            'streets': {'fc': '#F1E6D0', 'ec': '#2F3737', 'lw': 1.5, 'zorder': 3},
            'building': {'palette': palette, 'ec': '#2F3737', 'lw': 1, 'zorder': 4},
        },

        osm_credit = {'x': -.55, 'y': -.25, 'color': '#2F3737'} if i == 0 else None
    )

ax.autoscale()

#plt.savefig('../prints/bomfim-farroupilha-cidadebaixa.png')
#plt.savefig('../prints/bomfim-farroupilha-cidadebaixa.svg')

but it failed with the error message

Traceback (most recent call last):
  File "error.py", line 24, in <module>
    plot(
  File "/home/kamil/.local/lib/python3.8/site-packages/prettymaps/draw.py", line 226, in plot
    else get_perimeter(query, by_osmid=query_mode == "osmid")
  File "/home/kamil/.local/lib/python3.8/site-packages/prettymaps/fetch.py", line 80, in get_perimeter
    return ox.geocode_to_gdf(
  File "/home/kamil/.local/lib/python3.8/site-packages/osmnx/geocoder.py", line 110, in geocode_to_gdf
    gdf = gdf.append(_geocode_query_to_gdf(q, wr, by_osmid))
  File "/home/kamil/.local/lib/python3.8/site-packages/osmnx/geocoder.py", line 166, in _geocode_query_to_gdf
    result = _get_first_polygon(results, query)
  File "/home/kamil/.local/lib/python3.8/site-packages/osmnx/geocoder.py", line 230, in _get_first_polygon
    raise ValueError(f'OSM did not return any polygonal geometries for query "{query}"')
ValueError: OSM did not return any polygonal geometries for query "Brink-Hafen, Hannover, Deutschland"

After that I´ve took a look at the relationat OSM: Brink-Hafen Relation
There is one part which is not connected to the other, could it be the cause of the issue ?

Regards

@mikedewar
Copy link

I'm getting this now on previously working notebooks. Any ideas what's causing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants