jgc234 / optiburb

Cycling route generator for optimum "burbing" route.
MIT License
31 stars 7 forks source link

Multi polygon object and no nodes within requested geometry errors #8

Open baumy19 opened 4 years ago

baumy19 commented 4 years ago

Unfortunately I'm having the polygon problem as well - tried both options from the other two issues that have since been closed with no luck.

Trying to run the 5km radius code but I'm getting the "multi polygon" issue. Doesn't seem to be a problem when running a whole suburb (tested with Bellfield and no problem).

I've changed the street address to around the corner, and reduced to 1000m because Templestowe is a big suburb and I was trying to get a quick result as a test.

/optiburb-master/optiburb.py --debug=debug --save-fig --save-boundary \ --start "12 sarah crescent templestowe victoria australia" --buffer 1000 \ "12 sarah crescent templestowe victoria australia"

Results as:

2020-08-04 18:00:43 optiburb.py:<module>:634 [DEBUG] called with args - Namespace(buffer=20, debug='debug', names=[' --start', '6 sarah crescent templestowe victoria australia', '--buffer', '1000', ' 6 sarah crescent templestowe victoria australia'], prune=False, save_boundary=True, save_fig=True, select=1, shapefile=None, simplify=False, simplify_gpx=True, start=None) 2020-08-04 18:00:43 optiburb.py:__init__:74 [DEBUG] custom_filter=["highway"]["area"!~"yes"]["highway"!~"motorway|motorway_link|trunk|trunk_link|bridleway|footway|service|pedestrian|steps|stairs|escalator|elevator|construction|proposed|demolished|escape|bus_guideway|sidewalk|crossing|bus_stop|traffic_signals|stop|give_way|milestone|platform|speed_camera|raceway|rest_area|traffic_island|services|yes|no|drain|street_lamp|razed|corridor|abandoned"]["access"!~"private|no|customers"]["bicycle"!~"dismount|use_sidepath|private|no"]["service"!~"private|parking_aisle"]["motorroad"!="yes"]["golf_cart"!~"yes|designated|private"][!"waterway"][!"razed"] 2020-08-04 18:00:43 Configured osmnx 2020-08-04 18:00:43 optiburb.py:__init__:86 [WARNING] WARNING - this program does not consider the direction of one-way roads or other roads that may be not suitable for your mode of transport. You must confirm the path safe for yourself 2020-08-04 18:00:43 optiburb.py:get_osm_polygon:113 [INFO] searching for query= --start, which_result=1 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/boundaries.py:36: UserWarning: Theboundariesmodule has been deprecated and will be removed in a future relase. Use thegeocodermodule'sgeocode_to_gdffunction instead. warnings.warn(msg) 2020-08-04 18:00:43 Retrieved response from cache file "cache/c3444f8f0f860d13941b8c789f20aa78.json" 2020-08-04 18:00:43 OSM returned a LineString as the geometry 2020-08-04 18:00:43 Projected GeoDataFrame to +proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:00:43 Projected GeoDataFrame to epsg:4326 2020-08-04 18:00:43 Buffered GeoDataFrame to 20 meters 2020-08-04 18:00:43 Created GeoDataFrame with 1 row for query " --start" 2020-08-04 18:00:43 optiburb.py:get_osm_polygon:116 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west 0 POLYGON ((13.17154 47.82327, 13.16923 47.82291... Start, Plainfeld, Flachgau, Salzburg, 5325, Au... 47.823479 47.823061 13.171927 13.169035 2020-08-04 18:00:43 optiburb.py:get_osm_polygon:113 [INFO] searching for query=6 sarah crescent templestowe victoria australia, which_result=1 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/boundaries.py:36: UserWarning: Theboundariesmodule has been deprecated and will be removed in a future relase. Use thegeocodermodule'sgeocode_to_gdffunction instead. warnings.warn(msg) 2020-08-04 18:00:43 Retrieved response from cache file "cache/9d134764b603f4e42631febe49dbe407.json" 2020-08-04 18:00:43 OSM returned a LineString as the geometry 2020-08-04 18:00:43 Projected GeoDataFrame to +proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:00:43 Projected GeoDataFrame to epsg:4326 2020-08-04 18:00:43 Buffered GeoDataFrame to 20 meters 2020-08-04 18:00:43 Created GeoDataFrame with 1 row for query "6 sarah crescent templestowe victoria australia" 2020-08-04 18:00:43 optiburb.py:get_osm_polygon:116 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west 0 POLYGON ((145.14619 -37.76201, 145.14622 -37.7... Sarah Crescent, Templestowe, City of Manningha... -37.761811 -37.765791 145.146853 145.142494 2020-08-04 18:00:43 optiburb.py:get_osm_polygon:113 [INFO] searching for query=--buffer, which_result=1 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/boundaries.py:36: UserWarning: Theboundariesmodule has been deprecated and will be removed in a future relase. Use thegeocodermodule'sgeocode_to_gdffunction instead. warnings.warn(msg) 2020-08-04 18:00:43 Retrieved response from cache file "cache/0f381697b1bdaebeb9dba69752405c89.json" 2020-08-04 18:00:43 Projected GeoDataFrame to +proj=utm +zone=19 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:00:43 Projected GeoDataFrame to epsg:4326 2020-08-04 18:00:43 Buffered GeoDataFrame to 20 meters 2020-08-04 18:00:43 Created GeoDataFrame with 1 row for query "--buffer" 2020-08-04 18:00:43 optiburb.py:get_osm_polygon:116 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west 0 POLYGON ((-70.56358 -33.60827, -70.56204 -33.6... Buffer, Puente Alto, Provincia de Cordillera, ... -33.608239 -33.608529 -70.562001 -70.56355 2020-08-04 18:00:43 optiburb.py:get_osm_polygon:113 [INFO] searching for query=1000, which_result=1 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/boundaries.py:36: UserWarning: Theboundariesmodule has been deprecated and will be removed in a future relase. Use thegeocodermodule'sgeocode_to_gdffunction instead. warnings.warn(msg) 2020-08-04 18:00:43 Pausing 1 seconds before making HTTP GET request 2020-08-04 18:00:45 Get https://nominatim.openstreetmap.org/search?format=json&limit=1&dedupe=0&polygon_geojson=1&q=1000 with timeout=180 2020-08-04 18:00:45 connectionpool.py:_new_conn:939 [DEBUG] Starting new HTTPS connection (1): nominatim.openstreetmap.org:443 2020-08-04 18:00:46 connectionpool.py:_make_request:433 [DEBUG] https://nominatim.openstreetmap.org:443 "GET /search?format=json&limit=1&dedupe=0&polygon_geojson=1&q=1000 HTTP/1.1" 200 None 2020-08-04 18:00:46 Downloaded 0.5KB from nominatim.openstreetmap.org 2020-08-04 18:00:46 Saved response to cache file "cache/d8d8523fd9aa03e5ddfead7f45801552.json" 2020-08-04 18:00:46 OSM returned a Point as the geometry 2020-08-04 18:00:46 Projected GeoDataFrame to +proj=utm +zone=51 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:00:46 Projected GeoDataFrame to epsg:4326 2020-08-04 18:00:46 Buffered GeoDataFrame to 20 meters 2020-08-04 18:00:46 Created GeoDataFrame with 1 row for query "1000" 2020-08-04 18:00:46 optiburb.py:get_osm_polygon:116 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west 0 POLYGON ((120.99121 24.00633, 120.99121 24.006... 1000, Puli Township, Nantou County, Taiwan Pro... 24.006373 24.006273 120.991062 120.990962 2020-08-04 18:00:46 optiburb.py:get_osm_polygon:113 [INFO] searching for query= 6 sarah crescent templestowe victoria australia, which_result=1 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/boundaries.py:36: UserWarning: Theboundariesmodule has been deprecated and will be removed in a future relase. Use thegeocodermodule'sgeocode_to_gdffunction instead. warnings.warn(msg) 2020-08-04 18:00:46 Retrieved response from cache file "cache/355796cf3f130d520ad7d9e40592c122.json" 2020-08-04 18:00:46 OSM returned a LineString as the geometry 2020-08-04 18:00:46 Projected GeoDataFrame to +proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:00:46 Projected GeoDataFrame to epsg:4326 2020-08-04 18:00:46 Buffered GeoDataFrame to 20 meters 2020-08-04 18:00:46 Created GeoDataFrame with 1 row for query " 6 sarah crescent templestowe victoria australia" 2020-08-04 18:00:46 optiburb.py:get_osm_polygon:116 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west 0 POLYGON ((145.14619 -37.76201, 145.14622 -37.7... Sarah Crescent, Templestowe, City of Manningha... -37.761811 -37.765791 145.146853 145.142494 2020-08-04 18:00:46 optiburb.py:create_gpx_polygon:508 [INFO] saving suburb boundary - burb_polygon__--start_6_sarah_crescent_templestowe_victoria_australia_--buffer_1000__6_sarah_crescent_templestowe_victoria_australia.gpx Traceback (most recent call last): File "/Users/James/Downloads/optiburb-master/optiburb.py", line 667, in <module> burbing.create_gpx_polygon(burbing.region) File "/Users/James/Downloads/optiburb-master/optiburb.py", line 525, in create_gpx_polygon for x, y in polygon.exterior.coords: AttributeError: 'MultiPolygon' object has no attribute 'exterior'

When trying to run a whole suburb (oddly with the exception of Bellfield), I'm getting an "Exception: There are no nodes within the requested geometry" error. This appears to be issues for multiple suburbs.

/optiburb-master/optiburb.py --prune --save-boundary "lower templestowe victoria australia" 2020-08-04 18:03:53 Configured osmnx 2020-08-04 18:03:53 optiburb.py:__init__:86 [WARNING] WARNING - this program does not consider the direction of one-way roads or other roads that may be not suitable for your mode of transport. You must confirm the path safe for yourself 2020-08-04 18:03:53 optiburb.py:get_osm_polygon:113 [INFO] searching for query=lower templestowe victoria australia, which_result=1 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/boundaries.py:36: UserWarning: Theboundariesmodule has been deprecated and will be removed in a future relase. Use thegeocodermodule'sgeocode_to_gdffunction instead. warnings.warn(msg) 2020-08-04 18:03:53 Retrieved response from cache file "cache/44139df1012b67c49220cb242d1c8034.json" 2020-08-04 18:03:53 OSM returned a Point as the geometry 2020-08-04 18:03:54 Projected GeoDataFrame to +proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:03:54 Projected GeoDataFrame to epsg:4326 2020-08-04 18:03:54 Buffered GeoDataFrame to 20 meters 2020-08-04 18:03:54 Created GeoDataFrame with 1 row for query "lower templestowe victoria australia" 2020-08-04 18:03:54 optiburb.py:get_osm_polygon:116 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west 0 POLYGON ((145.11250 -37.76388, 145.11250 -37.7... Templestowe Lower, City of Manningham, Victori... -37.743875 -37.783875 145.132276 145.092276 2020-08-04 18:03:54 optiburb.py:create_gpx_polygon:508 [INFO] saving suburb boundary - burb_polygon_lower_templestowe_victoria_australia.gpx 2020-08-04 18:03:54 optiburb.py:load:454 [INFO] fetching OSM data bounded by polygon 2020-08-04 18:03:54 Projected GeoDataFrame to +proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:03:54 Projected GeoDataFrame to epsg:4326 2020-08-04 18:03:54 Projected GeoDataFrame to +proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs 2020-08-04 18:03:54 Projected GeoDataFrame to epsg:4326 2020-08-04 18:03:54 Requesting network data within polygon from API in 1 request(s) 2020-08-04 18:03:54 Retrieved response from cache file "cache/03c8ac7a66b9c47633d7194a17b031ac.json" 2020-08-04 18:03:54 Got all network data within polygon from API in 1 request(s) 2020-08-04 18:03:54 Creating graph from downloaded OSM data... 2020-08-04 18:03:54 Created graph with 319 nodes and 597 edges 2020-08-04 18:03:54 Added edge lengths to graph 2020-08-04 18:03:54 Identifying all nodes that lie outside the polygon... 2020-08-04 18:03:54 Created r-tree spatial index for 319 points 2020-08-04 18:03:54 Identified 238 nodes inside polygon 2020-08-04 18:03:54 Removed 81 nodes outside polygon 2020-08-04 18:03:54 Truncated graph by polygon 2020-08-04 18:03:54 Identifying all nodes that lie outside the polygon... 2020-08-04 18:03:54 Created r-tree spatial index for 238 points Traceback (most recent call last): File "/Users/James/Downloads/optiburb-master/optiburb.py", line 674, in <module> burbing.load(args) File "/Users/James/Downloads/optiburb-master/optiburb.py", line 455, in load self.g = osmnx.graph_from_polygon(self.region, network_type='bike', simplify=False, custom_filter=self.custom_filter) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/graph.py", line 446, in graph_from_polygon G = truncate.truncate_graph_polygon( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/truncate.py", line 158, in truncate_graph_polygon points_within_geometry = utils_geo._intersect_index_quadrats( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/osmnx/utils_geo.py", line 440, in _intersect_index_quadrats raise Exception("There are no nodes within the requested geometry") Exception: There are no nodes within the requested geometry

jgc234 commented 4 years ago

Just take those backslashes out of the command line and you should be ok.

jgc234 commented 4 years ago

Screen Shot 2020-08-04 at 18 14 28

baumy19 commented 4 years ago

Just take those backslashes out of the command line and you should be ok.

That seems to have fixed the issue with the multi polygon object error. The nodes file for this has worked out fine, but the GPX file seems to only show the outside circle when drawn after adding a time stamp through the gotoes system - it doesn't show the route in the middle. Is there a way to convert that GPX into a useable file?

Regarding the no nodes error when running a full suburb - is there a workaround for that?

jgc234 commented 4 years ago

I suspect you're looking at the wrong GPX file.. The boundary one is the boundary (handy to look at if you don't want the whole route). The track GPX file will have the route.

As for the suburb, try using the full suburb name like this ./optiburb.py --debug=debug 'Templestowe, City of Manningham, Victoria, Australia'

Sometimes the suburb name returns a tiny circle, showing you the centre of the suburb, instead of the suburb boundary.

baumy19 commented 4 years ago

I suspect you're looking at the wrong GPX file.. The boundary one is the boundary (handy to look at if you don't want the whole route). The track GPX file will have the route.

I was ticking the adjust time box instead of leaving it blank to add a timestamp to it - that is now working.

As for the suburb, try using the full suburb name like this ./optiburb.py --debug=debug 'Templestowe, City of Manningham, Victoria, Australia'

Sometimes the suburb name returns a tiny circle, showing you the centre of the suburb, instead of the suburb boundary.

Using the full suburb name doesn't seem to fix the Exception: There are no nodes within the requested geometry issue either.

/optiburb.py --debug=debug "lower templestowe, city of manningham, victoria, australia" Ran it both with and without commas between the names - ends up with the same result. Managed to run one for East Kew without the "city of booroondara" in there (albeit failed with --prune) and it was successful. Not sure if it's a local suburb issue?

ghost commented 4 years ago

Hi, I'm having some issues as well with Lambton, NSW 2299 If I enter it as "Lambton, newcastle, new south wales, australia" or Lambton, new south wales, australia" it can only find 4 nodes within the polygon. If I try it with --select 2 it does quite a good job on the next suburb over 'new Lambton heights' Screen Shot 2020-08-23 at 4 03 58 pm

ghost commented 4 years ago

ok, tried it again with the exact wording from openmaps "Lambton, Newcastle, Newcastle-Maitland, Newcastle City Council, 2299, Australia" and got a far better result Screen Shot 2020-08-23 at 4 23 17 pm

jgc234 commented 4 years ago

ok, tried it again with the exact wording from openmaps "Lambton, Newcastle, Newcastle-Maitland, Newcastle City Council, 2299, Australia" and got a far better result

Yeah, that looks better.. The way to find the right name is to go to openstreetmap.org and fiddle around with the search, and then cut and paste the full name it shows, including the shire and other sub-names.. It's ugly, but unfortunately I can't find a way to specify to only search for locality boundaries in that type of search without changing to a different type of search.