gboeing / osmnx

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.
https://osmnx.readthedocs.io
MIT License
4.89k stars 827 forks source link

Incompatible with the version of numpy 2.1.0.rc1 when using 2.0.0b1 #1210

Closed jamongadejoa28 closed 2 months ago

jamongadejoa28 commented 3 months ago

Contributing guidelines

Documentation

Existing issues

What operating system and Python version are you using?

Window 11 / Python 3.12

What OSMnx version are you using?

2.0.0b1

Environment packages and versions

Package            Version
------------------ -----------
attrs              24.2.0
certifi            2024.7.4
charset-normalizer 3.3.2
click              8.1.7
click-plugins      1.1.1
cligj              0.7.2
colorama           0.4.6
contourpy          1.2.1
cycler             0.12.1
fiona              1.9.6
fonttools          4.53.1
geopandas          1.0.1
idna               3.7
kiwisolver         1.4.5
matplotlib         3.9.2
networkx           3.3
numpy              2.1.0rc1
osmnx              2.0.0b1
packaging          24.1
pandas             2.2.2
pillow             10.4.0
pip                24.2
pyogrio            0.9.0
pyparsing          3.1.2
pyproj             3.6.1
python-dateutil    2.9.0.post0
pytz               2024.1
requests           2.32.3
shapely            2.0.5
six                1.16.0
tzdata             2024.1
urllib3            2.2.2

How did you install OSMnx?

Conda and conda-forge

Problem description

Incompatibility with numpy 2.1.0.rc1 when using 2.0.0b1

C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Scripts\python.exe C:\Users\sohap\PycharmProjects\pythonProject1\.venv\createNet.py 
Traceback (most recent call last):
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\createNet.py", line 49, in <module>
    create_sumo_network()
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\createNet.py", line 28, in create_sumo_network
    G = ox.graph_from_address('방교동,동탄6동, 화성시, 18487, 대한민국', 1000, dist_type="bbox", network_type="drive",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\osmnx\graph.py", line 272, in graph_from_address
    G = graph_from_point(
        ^^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\osmnx\graph.py", line 185, in graph_from_point
    G = graph_from_bbox(
        ^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\osmnx\graph.py", line 95, in graph_from_bbox
    polygon = utils_geo.bbox_to_poly(bbox)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\osmnx\utils_geo.py", line 409, in bbox_to_poly
    return Polygon([(left, bottom), (right, bottom), (right, top), (left, top)])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\shapely\geometry\polygon.py", line 230, in __new__
    shell = LinearRing(shell)
            ^^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\shapely\geometry\polygon.py", line 104, in __new__
    geom = shapely.linearrings(coordinates)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\shapely\decorators.py", line 77, in wrapped
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sohap\PycharmProjects\pythonProject1\.venv\Lib\site-packages\shapely\creation.py", line 246, in linearrings
    return lib.linearrings(coords, np.intc(handle_nan), out=out, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot specify 'out' as both a positional and keyword argument
2024-08-19 11:34:04 Retrieved response from cache file 'cache\\f02a687807a0feb26a659783d0c912caa41c27e1.json'
2024-08-19 11:34:04 Geocoded '????????,??????6???, ???????, 18487, ???????????' to (37.1755136, 127.0927868)
2024-08-19 11:34:04 Created bbox 1000 meters from (37.1755136, 127.0927868): (np.float64(127.08149998250407), 37.166520396645076, np.float64(127.10407361749593), 37.18450680335493)
Unexpected error during simulation: cannot specify 'out' as both a positional and keyword argument

Process finished with exit code 1

Complete minimal reproducible example

import os
import sys
import osmnx as ox
import subprocess
import sumolib
import optparse
import csv
import xml.etree.ElementTree as ET
from collections import defaultdict
import traceback

# SUMO environment setup
if 'SUMO_HOME' in os.environ:
    sumo_home = os.environ['SUMO_HOME']
    tools = os.path.join(sumo_home, 'tools')
    sys.path.append(tools)
else:
    sys.exit("please declare environment variable 'SUMO_HOME'")

from sumolib import checkBinary

# OSMnx settings
ox.settings.use_cache = True
ox.settings.log_console = True
ox.settings.all_oneway = True

def create_sumo_network():
    G = ox.graph_from_address('방교동,동탄6동, 화성시, 18487, 대한민국', 1000, dist_type="bbox", network_type="drive",
                              retain_all="true", simplify=False)
    ox.save_graph_xml(G, "data/test.osm")
    subprocess.run(["netconvert", "--osm-files", "data/test.osm", "-o", "data/test.net.xml"], check=True)
    print("Created new test.net.xml file.")

def get_options():
    optParser = optparse.OptionParser()
    optParser.add_option("--nogui", action="store_true", default=False, help="run the commandline version of sumo")
    options, args = optParser.parse_args()
    return options

if __name__ == "__main__":
    options = get_options()

    if options.nogui:
        sumoBinary = checkBinary('sumo')
    else:
        sumoBinary = checkBinary('sumo-gui')
    try:
       create_sumo_network()
    except Exception as e:
        print(f"Unexpected error during simulation: {e}")
        traceback.print_exc()
        exit(1)
gboeing commented 3 months ago

Thanks for using OSMnx. I don't understand what problem you're reporting. If you're getting an error, please paste the full error traceback (no screenshot) and minimal code to reproduce it. Thanks.

gboeing commented 3 months ago

Possible duplicate of #1209?

jamongadejoa28 commented 2 months ago

@gboeing https://github.com/gboeing/osmnx/issues/1209

Corrected the text. Please confirm

This is the result of going to the above address, modifying creation.py and set_operation.py, and running them.

gboeing commented 2 months ago

This appears to be a different error than the one you originally posted (which seemed to be the same as #1209). If one of the dependency packages (shapely?) is passing incorrect arguments internally, you'd have to open an issue with them. I wouldn't be able to assist from here.