-
Notifications
You must be signed in to change notification settings - Fork 808
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
Geometry must be a shapely Polygon or MultiPolygon #11
Comments
This is working correctly. If you get the geometry for Povo, Italy:
OpenStreetMap returns a point:
If you have logging turned on, it issues a warning: "OSM returned a Point as the geometry." You can see this directly from the API -- looks like OSM doesn't have a polygon for this place, only a centroid point. The geocoder warns you that it got a point back, and when graph_from_polygon receives the point geometry, it throws the exception you saw: the geometry has to be a Polygon or MultiPolygon to run graph_from_polygon. See also: #16 |
A related query: I can get a point gdf for a city without a polygon (like "Povo, Italy" in the example above), but this doesn't seem to work as an input to "graph_from_point" for either "distance_type
|
Your code snippet is almost there. If you check out the docstring for So, you just need to extract the point as a (lat, lon) tuple from the GeoDataFrame, like this:
|
FWIW, you can also get the network within n meters of the center_point along the network (rather than by constructing a bounding box around your center_point), like this:
|
import osmnx as ox this is giving me an error of LinearRing |
@yujinh this is likewise all working fine in my test environments. Can you provide your full package list and environment info (ie, what OS, what python version, etc)? |
macOS Sierra version 10.12.6
|
Hello! #Calculate basic street network measures (topological and metric) get the network for Piedmont, calculate its basic stats, then show the average circuitystats = ox.basic_stats(ox.graph_from_address('11.568271,104.9224426')) get the street network for a place, and its area in square metersplace = 'Phnom Penh, Cambodia' calculate basic and extended network stats, merge them together, and displaystats = ox.basic_stats(G, area=area) ZeroDivisionError Traceback (most recent call last) c:\anaconda3\envs\osmnx\lib\site-packages\osmnx\stats.py in basic_stats(G, area, clean_intersects, tolerance, circuity_dist) ZeroDivisionError: float division by zero I am a beginner of python and osmnx. Any advice, please? I really appreciate! |
Hi, @gboeing thank you for osmnx package! It is really good to use it. I had similar issue arising from "non-polygons" objects, e.g. "Povo, Italy".
coords = [(24.950899, 60.169158), (24.953492, 60.169158), (24.953510, 60.170104), (24.950958, 60.169990)] #working example But then I cannot search for amenities in the Polygon for some reason. e.g. I try
Thank you! |
@Liyubov if you provide a minimal, complete, reproducible example I will take a look. |
Yes, tnx, sure, here it is @gboeing Hope this is clear. Thank you! `import networkx as nx Create a Polygoncoords = [(24.950899, 60.169158), (24.953492, 60.169158), (24.953510, 60.170104), (24.950958, 60.169990)] hospitals = ox.pois.osm_poi_download(polygon=poly, amenities=['hospital']) How many hospitals do we have in this district?print('number of hospitals',len(hospitals)) ` |
I'm sorry, I always show you errrors :(
which result is:
The text was updated successfully, but these errors were encountered: