distance.nearest_nodes runs in an issue
AppWerft opened this issue · 1 comments
AppWerft commented
Contributing guidelines
- I understand the contributing guidelines
Documentation
- My problem is not addressed by the documentation or examples
Existing issues
- My problem does not appear in an existing issue
What operating system and Python version are you using?
osx python 3.11.4
What OSMnx version are you using?
1.6.1
Environment packages and versions
# Name Version Build Channel
boltons 23.0.0 py311hecd8cb5_0
brotlipy 0.7.0 py311h6c40b1e_1002
bzip2 1.0.8 h1de35cc_0
c-ares 1.19.0 h6c40b1e_0
ca-certificates 2023.05.30 hecd8cb5_0
certifi 2023.5.7 py311hecd8cb5_0
cffi 1.15.1 py311h6c40b1e_3
charset-normalizer 2.0.4 pyhd3eb1b0_0
conda 23.5.2 py311hecd8cb5_0
conda-content-trust 0.1.3 py311hecd8cb5_0
conda-libmamba-solver 23.5.0 py311hecd8cb5_0
conda-package-handling 2.1.0 py311hecd8cb5_0
conda-package-streaming 0.8.0 py311hecd8cb5_0
cryptography 39.0.1 py311hf6deb26_2
fmt 9.1.0 ha357a0b_0
icu 58.2 h0a44026_3
idna 3.4 py311hecd8cb5_0
jsonpatch 1.32 pyhd3eb1b0_0
jsonpointer 2.1 pyhd3eb1b0_0
krb5 1.20.1 h428f121_1
libarchive 3.6.2 h29ab7a1_2
libcurl 8.1.1 hf20ceda_1
libcxx 14.0.6 h9765a3e_0
libedit 3.1.20221030 h6c40b1e_0
libev 4.33 h9ed2024_1
libffi 3.4.4 hecd8cb5_0
libiconv 1.16 hca72f7f_2
libmamba 1.4.1 h8c3233a_1
libmambapy 1.4.1 py311h8c3233a_1
libnghttp2 1.52.0 h9beae6a_1
libsolv 0.7.22 h8346a28_0
libssh2 1.10.0 h04015c4_2
libxml2 2.10.3 h930c0e2_0
lz4-c 1.9.4 hcec6c5f_0
ncurses 6.4 hcec6c5f_0
openssl 3.0.9 hca72f7f_0
packaging 23.0 py311hecd8cb5_0
pcre2 10.37 he7042d7_1
pip 23.1.2 py311hecd8cb5_0
pluggy 1.0.0 py311hecd8cb5_1
pybind11-abi 4 hd3eb1b0_1
pycosat 0.6.4 py311h6c40b1e_0
pycparser 2.21 pyhd3eb1b0_0
pyopenssl 23.0.0 py311hecd8cb5_0
pysocks 1.7.1 py311hecd8cb5_0
python 3.11.4 hf27a42d_0
python.app 3 py311h6c40b1e_0
readline 8.2 hca72f7f_0
reproc 14.2.4 he9d5cce_1
reproc-cpp 14.2.4 he9d5cce_1
requests 2.29.0 py311hecd8cb5_0
ruamel.yaml 0.17.21 py311h6c40b1e_0
setuptools 67.8.0 py311hecd8cb5_0
six 1.16.0 pyhd3eb1b0_1
sqlite 3.41.2 h6c40b1e_0
tk 8.6.12 h5d9f67b_0
toolz 0.12.0 py311hecd8cb5_0
tqdm 4.65.0 py311h85bffb1_0
tzdata 2023c h04d1e81_0
urllib3 1.26.16 py311hecd8cb5_0
wheel 0.38.4 py311hecd8cb5_0
xz 5.4.2 h6c40b1e_0
yaml-cpp 0.7.0 he9d5cce_1
zlib 1.2.13 h4dc903c_0
zstandard 0.19.0 py311h6c40b1e_0
zstd 1.5.5 hc035e20_0
How did you install OSMnx?
Pip
Problem description
This simple code:
import osmnx as ox
import networkx as nx
file_path = "hamburg_drive.graphml"
G = ox.graph_from_place("Hamburg, Germany", network_type="drive")
ox.save_graphml(G, filepath=file_path)
G = nx.read_graphml(file_path)
longitude = 9.2683854
latitude = 53.5567586
start_node = ox.distance.nearest_nodes(G, longitude, latitude)
=======
runs in this issue:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/osmnx/distance.py", line 201, in nearest_nodes
nodes_rad = np.deg2rad(nodes[["y", "x"]])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pandas/core/generic.py", line 2016, in __array_ufunc__
return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pandas/core/arraylike.py", line 404, in array_ufunc
result = mgr.apply(getattr(ufunc, method))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pandas/core/internals/managers.py", line 350, in apply
applied = b.apply(f, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pandas/core/internals/blocks.py", line 329, in apply
result = func(self.values, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: loop of ufunc does not support argument 0 of type str which has no callable deg2rad method
Complete minimal reproducible example
import osmnx as ox
import networkx as nx
file_path = "hamburg_drive.graphml"
G = ox.graph_from_place("Hamburg, Germany", network_type="drive")
ox.save_graphml(G, filepath=file_path)
G = nx.read_graphml(file_path)
longitude = 9.2683854
latitude = 53.5567586
start_node = ox.distance.nearest_nodes(G, longitude, latitude)
AppWerft commented
I have used a mix of old and new syntax. Sorry