Giter VIP home page Giter VIP logo

optiburb's People

Contributors

jgc234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

optiburb's Issues

Non-contiguous roads within suburb boundaries with no connection to the contiguous suburb

Opening a general issue here that's dependent on the graph-based solvers deployed in the code. This is probably not going to be easy to fix, but it's an issue.

When there are roads within a suburb boundary that have no connection to the rest of the suburb, the entire code fails.

This will require download of OSM data surrounding the suburb, and graph-based optimization considering nodes outside of the suburb as potential (but not required) routes for traversal.

Multithread possible?

Hi!
Thanks a lot for sharing the script with us.
Q: Ist it somehow possible to utilize all cores available on a machine for speeding up the calculation?
Currently I have 2 jobs running and only 2 cores are in use.
System: virtual debian 10.5 instance w/ currently 4 cores (12 possible) and 16GB RAM (256GB possible)
image

Failed to install on MacOS

I get the following error when installing via Terminal. Either there's an issue with my python install or Rtree and oxmnx

robs-mac-pro:optiburb mlaich$ pip3 install -r requirements.txt

Requirement already satisfied: shapely in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (1.7.0)
Requirement already satisfied: gpxpy in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (1.4.2)
Requirement already satisfied: numpy in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (1.19.1)
Requirement already satisfied: networkx in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 4)) (2.4)
Requirement already satisfied: pandas in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (1.1.0)
Requirement already satisfied: geopandas in /usr/local/lib/python3.8/site-packages (from -r requirements.txt (line 6)) (0.8.1)
Collecting osmnx
  Using cached osmnx-0.15.1-py2.py3-none-any.whl (84 kB)
Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.8/site-packages (from networkx->-r requirements.txt (line 4)) (4.4.2)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.8/site-packages (from pandas->-r requirements.txt (line 5)) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.8/site-packages (from pandas->-r requirements.txt (line 5)) (2020.1)
Requirement already satisfied: fiona in /usr/local/lib/python3.8/site-packages (from geopandas->-r requirements.txt (line 6)) (1.8.13.post1)
Requirement already satisfied: pyproj>=2.2.0 in /usr/local/lib/python3.8/site-packages (from geopandas->-r requirements.txt (line 6)) (2.6.1.post1)
Collecting descartes>=1.1
  Using cached descartes-1.1.0-py3-none-any.whl (5.8 kB)
Collecting requests>=2.23
  Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB)
Collecting Rtree>=0.9
  Using cached Rtree-0.9.4.tar.gz (62 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/[email protected]/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-install-fxwmeoh_/Rtree/setup.py'"'"'; __file__='"'"'/private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-install-fxwmeoh_/Rtree/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-pip-egg-info-t8kncwja
         cwd: /private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-install-fxwmeoh_/Rtree/
    Complete output (15 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-install-fxwmeoh_/Rtree/setup.py", line 3, in <module>
        import rtree
      File "/private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-install-fxwmeoh_/Rtree/rtree/__init__.py", line 1, in <module>
        from .index import Rtree
      File "/private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-install-fxwmeoh_/Rtree/rtree/index.py", line 6, in <module>
        from . import core
      File "/private/var/folders/j0/hxwg1sp12yqgc10bd7hdvlvw0000gn/T/pip-install-fxwmeoh_/Rtree/rtree/core.py", line 143, in <module>
        rt.Error_GetLastErrorNum.restype = ctypes.c_int
      File "/usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
        func = self.__getitem__(name)
      File "/usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: dlsym(RTLD_DEFAULT, Error_GetLastErrorNum): symbol not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Not all roads traced

Thanks for this code, it's very interesting!

Just playing around with it and for some reason it misses a couple of random streets and roads within the suburb. There aren't any restrictions or other tags that prevent them from being included.

Example below for Fairfield as a test (loaded into RideWithGPS):

Optiburb Radius failing

Windows environment, python-3.8.10-amd64, dependencies sorted.

I can generate a GPX of my suburb. With new restrictions, I wanted to generate a GPX of everything within 2.5km.

optiburb.py --debug=debug --save-fig --save-boundary --start "My Address, Suburb, South Australia, Australia" --buffer 2499 "My Address, Suburb, South Australia, Australia"
2021-07-21 10:39:05 optiburb.py::709 [DEBUG] called with args - Namespace(buffer=2499, debug='debug', feature_deadend=False, names=['My Address, Suburb, South Australia, Australia'], prune=False, save_boundary=True, save_fig=True, select=1, shapefile=None, simplify=False, simplify_gpx=True, start='My Address, Suburb, South Australia, Australia')
2021-07-21 10:39:05 optiburb.py:init:74 [DEBUG] custom_filter=["highway"]["area"!"yes"]["highway"!"motorway|motorway_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"]
2021-07-21 10:39:05 Configured OSMnx 1.1.1
2021-07-21 10:39:05 HTTP response caching is on
2021-07-21 10:39:05 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
2021-07-21 10:39:05 optiburb.py:get_osm_polygon:113 [INFO] searching for query=My Address, Suburb, South Australia, Australia, which_result=1
2021-07-21 10:39:05 Retrieved response from cache file "cache\b80f0950a39548b054c3d7acd643b0291f2ba8c6.json"
2021-07-21 10:39:05 Nominatim geocoder returned a LineString as the geometry for query "My Address, Suburb, South Australia, Australia"
2021-07-21 10:39:05 Projected GeoDataFrame to +proj=utm +zone=54 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2021-07-21 10:39:05 Projected GeoDataFrame to epsg:4326
2021-07-21 10:39:05 Buffered GeoDataFrame to 2499 meters
2021-07-21 10:39:05 Created GeoDataFrame with 1 rows from 1 queries
2021-07-21 10:39:05 optiburb.py:get_osm_polygon:116 [INFO] gdf= geometry bbox_north bbox_south ... class type importance
0 POLYGON ((138.71772 -34.77658, 138.72113 -34.7... -34.79887 -34.799054 ... highway residential 1.64

[1 rows x 14 columns]
2021-07-21 10:39:05 optiburb.py:create_gpx_polygon:574 [INFO] saving suburb boundary - burb_polygon_1_my_address_south_australia_australia.gpx
Traceback (most recent call last):
File "D:\optiburb-master2\optiburb.py", line 748, in
burbing.set_start_location(args.start)
File "D:\optiburb-master2\optiburb.py", line 142, in set_start_location
point = osmnx.utils_geo.geocode(addr)
AttributeError: module 'osmnx.utils_geo' has no attribute 'geocode'

Searching for "My Address, Suburb, South Australia, Australia" directly on OSM delivers my street, but no resolution of the numbers within. Is that the issue here or am I missing something vital?

Multi polygon object and no nodes within requested geometry errors

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: The boundariesmodule 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_gdf function 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: The boundariesmodule 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

Filter streets like wandrer.earth to optimize for cycling-friendly roads

Sorry for the glut of input here...

I tried adjusting the custom_filter and useful_tags_way in optiburb.py to achieve the same road map as in wandrer.earth:

        self.custom_filter = (
            f'["highway"]["area"!~"yes"]["highway"!~"footway|service|pedestrian|motorway|motorway_link|trunk|trunk_link|bridleway|steps|corridor|elevator|escalator|motor|proposed|construction|abandoned|platform|raceway|stairs|proposed|demolished|escape|bus_guideway|sidewalk|crossing|bus_stop|traffic_signals|stop|give_way|milestone|platform|speed_camera|rest_area|traffic_island|services|drain|street_lamp|razed|abandoned|corridor"]'
            f'["bicycle"!~"no"]["service"!~"private|parking_aisle"]["access"!~"private"]'
        )


        # not all of this data is used but it looks interesting.

        useful_tags_way = ['bridge', 'tunnel', 'oneway', 'lanes', 'ref', 'name', 'highway', 'maxspeed', 'access', 'area', 'landuse', 'width', 'est_width', 'junction', 'surface',]

The above code changes removed a lot of sidewalk/walkway/service roads that were not included in wandrer.earth (and that I'd prefer not to ride or are not bike-legal), and were reflected in the .svg file, but then the .gpx track only visited some of the nodes, and also did not visit now-isolated sections of the suburb. Something screwy must have happened later on.

Ideally optiburb.py would filter just as wandrer.earth (see https://wandrer.earth/scoring). They outline OSM highway tags for inclusion very clearly.

'MultiPolygon' object has no attribute 'exterior'

First off, great work! I'm excited to get this working!

I'm running into an issue regardless of what suburb I enter (i.e. 'bellfield, victoria, australia'):

2020-07-29 10:47:02 optiburb.py:create_gpx_polygon:484 [INFO] saving suburb boundary - burb_polygon_'footscray__victoria__australia'.gpx
Traceback (most recent call last):
  File "PATH\optiburb.py", line 668, in <module>
    burbing.create_gpx_polygon(burbing.region)
  File "PATH\optiburb.py", line 501, in create_gpx_polygon
    for x, y in polygon.exterior.coords:
AttributeError: 'MultiPolygon' object has no attribute 'exterior'

I suspect I'm just doing something wrong, any thoughts?

Optiburb incompatible with osmnx 0.16

Hi,

it appears that optiburb is incompatible with osmnx 0.16.

I'd submit a patch if it was obvious what the correct replacement API call is, but it's not straightforward.

Reading the documentation, it seems that the correct way to do this in newer versions is to retrieve a graph and them convert to a gdf, as shown in the example here:

https://github.com/gboeing/osmnx-examples/blob/master/notebooks/02-routing-speed-time.ipynb

Unfortunately, I'm not sure exactly how you're using the gdf so I'm not sure on the exact values for all of the arguments.

Cheers,
Robert.

xubuntu@xubuntu-VirtualBox:~/src/optiburb$ pip3 freeze | grep osmnx
osmnx==0.16.0
xubuntu@xubuntu-VirtualBox:~/src/optiburb$ ./optiburb.py "brunswick, victoria, australia"
2020-10-02 14:03:06 Configured osmnx
2020-10-02 14:03:06 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-10-02 14:03:06 optiburb.py:get_osm_polygon:113 [INFO] searching for query=brunswick, victoria, australia, which_result=1
Traceback (most recent call last):
  File "./optiburb.py", line 738, in <module>
    polygon = burbing.get_osm_polygon(name, args.select, args.buffer)
  File "./optiburb.py", line 115, in get_osm_polygon
    gdf = osmnx.gdf_from_place(name, buffer_dist=buffer_dist, which_result=select)
AttributeError: module 'osmnx' has no attribute 'gdf_from_place'

Western Australia Suburbs

Hi Jim,

Awesome! Thanks a lot for releasing. This is my first foray into Python/coding and i have managed to figure out enough to get things setup. I am playing around with Perth suburbs. But having some issues. It seems there are no suburb boundaries saved and just nodes for the centre of the suburb.
Example: https://www.openstreetmap.org/node/31071659#map=14/-31.9799/115.8057

If i search for "City of Nedlands Western Australia Australia" then i get the council boundaries.
https://www.openstreetmap.org/relation/11343563
GPX route attached;
City of Nedlands Burbing.zip
Only 275km to try and do in a day. ;)

But a lot of the councils don't have their "City of ______" boundaries listed on OpenStreetMaps. So i guess i need to learn how to use shape files now?

Also, any idea how to get it to work for USA? Or would the code work if there is a way to make a custom shape file for an area?

Look forward to your responses. And keen to learn more from here.

Thanks

Divide by zero error for small suburbs

For small suburbs I kept getting divide by zero errors from the dijkstra progress logging. The _prev_time and _cur_time must have been the same.

Traceback (most recent call last):
File "optiburb.py", line 767, in
burbing.determine_combinations()
File "optiburb.py", line 335, in determine_combinations
odd_pair_paths = self.get_shortest_path_pairs(self.g, odd_node_pairs)
File "optiburb.py", line 188, in get_shortest_path_pairs
log.info('dijkstra progress %s%%, [%d/%d] %d/second', _cur_pct, n, _size, (_prev_n - n) / (_prev_time - _cur_time))
ZeroDivisionError: float division by zero

To get past this I changed the log.info call on line 188 to:

log.info('dijkstra progress %s%%, [%d/%d]', _cur_pct, n, _size,)

AttributeError: 'MultiPolygon' object has no attribute 'exterior'

Hi. Great script idea. Thank you! Getting "Multiploygon' object has no attribute 'exterior' when trying to run script. Tried a number of different suburbs but same error.

2020-07-30 10:28:50 optiburb.py:create_gpx_polygon:484 [INFO] saving suburb boundary - burb_polygon_'richmond__victoria__australia'.gpx
Traceback (most recent call last):
File "optiburb.py", line 668, in
burbing.create_gpx_polygon(burbing.region)
File "optiburb.py", line 501, in create_gpx_polygon
for x, y in polygon.exterior.coords:
AttributeError: 'MultiPolygon' object has no attribute 'exterior'


C:\burbing>python optiburb.py --simplify --simplify-gpx --prune --debug debug 'richmond, victoria, australia'
2020-07-30 10:28:46 optiburb.py::635 [DEBUG] called with args - Namespace(buffer=20, debug='debug', names=["'richmond,", 'victoria,', "australia'"], prune=True, save_boundary='False', save_fig='False', select=1, shapefile=None, simplify=True, simplify_gpx=True, start=None)
2020-07-30 10:28:46 Configured osmnx
2020-07-30 10:28:46 optiburb.py:init:64 [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-07-30 10:28:46 optiburb.py:get_osm_polygon:91 [INFO] searching for query='richmond,, which_result=1
C:\Program Files (x86)\Python38-32\lib\site-packages\osmnx\boundaries.py:36: UserWarning: The boundaries module has been deprecated and will be removed in a future relase. Use the geocoder module's geocode_to_gdf function instead.
warnings.warn(msg)
2020-07-30 10:28:46 Pausing 1 seconds before making HTTP GET request
2020-07-30 10:28:47 Get https://nominatim.openstreetmap.org/search?format=json&limit=1&dedupe=0&polygon_geojson=1&q=%27richmond%2C with timeout=180
2020-07-30 10:28:47 connectionpool.py:_new_conn:939 [DEBUG] Starting new HTTPS connection (1): nominatim.openstreetmap.org:443
2020-07-30 10:28:48 connectionpool.py:make_request:433 [DEBUG] https://nominatim.openstreetmap.org:443 "GET /search?format=json&limit=1&dedupe=0&polygon_geojson=1&q=%27richmond%2C HTTP/1.1" 200 None
2020-07-30 10:28:48 Downloaded 0.5KB from nominatim.openstreetmap.org
2020-07-30 10:28:48 Saved response to cache file "cache\deb138ffe550bb73362d070e245d89dd.json"
2020-07-30 10:28:48 OSM returned a Point as the geometry
2020-07-30 10:28:49 Projected GeoDataFrame to +proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2020-07-30 10:28:49 Projected GeoDataFrame to epsg:4326
2020-07-30 10:28:49 Buffered GeoDataFrame to 20 meters
2020-07-30 10:28:49 Created GeoDataFrame with 1 row for query "'richmond,"
2020-07-30 10:28:49 optiburb.py:get_osm_polygon:94 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west
0 POLYGON ((-77.43405 37.53851, -77.43405 37.538... Richmond, Richmond City, Virginia, 23298, Unit... 37.698509 37.378509 -77.27428 -77.59428
2020-07-30 10:28:49 optiburb.py:get_osm_polygon:91 [INFO] searching for query=victoria,, which_result=1
C:\Program Files (x86)\Python38-32\lib\site-packages\osmnx\boundaries.py:36: UserWarning: The boundaries module has been deprecated and will be removed in a future relase. Use the geocoder module's geocode_to_gdf function instead.
warnings.warn(msg)
2020-07-30 10:28:49 Retrieved response from cache file "cache\e313c914b63ec1985c5792fcd8c3bf6d.json"
2020-07-30 10:28:49 Projected GeoDataFrame to +proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2020-07-30 10:28:49 Projected GeoDataFrame to epsg:4326
2020-07-30 10:28:49 Buffered GeoDataFrame to 20 meters
2020-07-30 10:28:49 Created GeoDataFrame with 1 row for query "victoria,"
2020-07-30 10:28:49 optiburb.py:get_osm_polygon:94 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west
0 MULTIPOLYGON (((140.96341 -34.39740, 140.96316... Victoria, Australia -33.980797 -39.198487 150.033282 140.961902
2020-07-30 10:28:50 optiburb.py:get_osm_polygon:91 [INFO] searching for query=australia', which_result=1
C:\Program Files (x86)\Python38-32\lib\site-packages\osmnx\boundaries.py:36: UserWarning: The boundaries module has been deprecated and will be removed in a future relase. Use the geocoder module's geocode_to_gdf function instead.
warnings.warn(msg)
2020-07-30 10:28:50 Retrieved response from cache file "cache\e964202fa396a56531d954d158b3cfaa.json"
2020-07-30 10:28:50 Projected GeoDataFrame to +proj=utm +zone=53 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2020-07-30 10:28:50 Projected GeoDataFrame to epsg:4326
2020-07-30 10:28:50 Buffered GeoDataFrame to 20 meters
2020-07-30 10:28:50 Created GeoDataFrame with 1 row for query "australia'"
2020-07-30 10:28:50 optiburb.py:get_osm_polygon:94 [INFO] gdf= geometry place_name bbox_north bbox_south bbox_east bbox_west
0 MULTIPOLYGON (((167.68549 -29.00923, 167.68579... Australia -9.088012 -55.322817 168.226126 72.246193
2020-07-30 10:28:50 optiburb.py:create_gpx_polygon:484 [INFO] saving suburb boundary - burb_polygon
'richmond__victoria__australia'.gpx
Traceback (most recent call last):
File "optiburb.py", line 668, in
burbing.create_gpx_polygon(burbing.region)
File "optiburb.py", line 501, in create_gpx_polygon
for x, y in polygon.exterior.coords:
AttributeError: 'MultiPolygon' object has no attribute 'exterior'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.