Skip to content
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

ox.get_nearest_nodes update required #20

Open
mohdalattar opened this issue Jan 12, 2023 · 10 comments
Open

ox.get_nearest_nodes update required #20

mohdalattar opened this issue Jan 12, 2023 · 10 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mohdalattar
Copy link

Hi,

In routing.py line 702 ox.get_nearest_nodes should be ox.nearest_nodes and I guess x and y should be reversed as well.

@Claudio9701
Copy link
Collaborator

Hello! Thanks for the heads up.

This issue is already solved in the master branch here. In the following weeks an updated version of urbanpy will be available via pip.

@mohdalattar
Copy link
Author

Hello! Thanks for the heads up.

This issue is already solved in the master branch here. In the following weeks an updated version of urbanpy will be available via pip.

Thanks Claudio , I am facing some issues executing the pub accessibility example would the updated version addresses these issues ? Or it supposed to run smoothly?

@Claudio9701
Copy link
Collaborator

Hello @mohdalattar thanks for the issue. Could you please provide a link for the example you mention to help you? Is one from the notebooks folder?

@mohdalattar
Copy link
Author

@Claudio9701
Copy link
Collaborator

Claudio9701 commented Jan 17, 2023

Since the fix is on the master branch we can install urbanpy latest version as follows:

$ git clone --quiet https://github.com/EL-BID/urbanpy.git # Clone latest urbanpy version
$ pip install -r urbanpy/requirements.txt  # Install requirements

Then you can run your jupyter notebook inside the examples folder and it will work correctly.

Here you can find a working colab notebook for this example. Hope you find this usefull. I hope the new version is out soon on pypi.

Thank you a lot for using urbanpy!

@Claudio9701
Copy link
Collaborator

Hello @mohdalattar don't hesitate to let me know if the problem is solved 🤗

@mohdalattar
Copy link
Author

Hi Claudio, I've tried using Jupiter notebook (previously I used Spyder) and when I am executing

ax = lima_boundaries.to_crs(isochrones.crs).plot(facecolor='none', edgecolor='r')
isochrones.plot('contour', alpha=0.5, ax=ax)
ax.set_axis_off()
cx.add_basemap(ax, source=cx.providers.CartoDB.Positron, crs='EPSG:4326')

I am getting

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/dz/vjf334f52x1c7_l620cdd9480000gn/T/ipykernel_95744/3816152939.py in <module>
----> 1 ax = lima_boundaries.to_crs(isochrones.crs).plot(facecolor='none', edgecolor='r')
      2 isochrones.plot('contour', alpha=0.5, ax=ax)
      3 ax.set_axis_off()
      4 cx.add_basemap(ax, source=cx.providers.CartoDB.Positron, crs='EPSG:4326')

~/opt/anaconda3/lib/python3.9/site-packages/geopandas/geodataframe.py in to_crs(self, crs, epsg, inplace)
   1362         else:
   1363             df = self.copy()
-> 1364         geom = df.geometry.to_crs(crs=crs, epsg=epsg)
   1365         df.geometry = geom
   1366         if not inplace:

~/opt/anaconda3/lib/python3.9/site-packages/geopandas/geoseries.py in to_crs(self, crs, epsg)
   1122         """
   1123         return GeoSeries(
-> 1124             self.values.to_crs(crs=crs, epsg=epsg), index=self.index, name=self.name
   1125         )
   1126 

~/opt/anaconda3/lib/python3.9/site-packages/geopandas/array.py in to_crs(self, crs, epsg)
    760         """
    761         if self.crs is None:
--> 762             raise ValueError(
    763                 "Cannot transform naive geometries.  "
    764                 "Please set a crs on the object first."

ValueError: Cannot transform naive geometries.  Please set a crs on the object first.

@Claudio9701
Copy link
Collaborator

The error ValueError: Cannot transform naive geometries. Please set a crs on the object first. is raised because the function up.download.nominatim_osm returned a GeoDataFrame without crs defined. To solve this error you need to modify the code as follows:

OSM_CRS = 'EPSG:4326'
lima_boundaries.crs = OSM_CRS
ax = lima_boundaries.plot(facecolor='none', edgecolor='r')
isochrones.plot('contour', alpha=0.5, ax=ax)
ax.set_axis_off()
cx.add_basemap(ax, source=cx.providers.CartoDB.Positron, crs=OSM_CRS)

This undefined crs problem is solved in the latest version of urbanpy which is available in the repo master branch. If you haven't runned this colab notebook yet, I recommend you to run it so you can get in touch with a working example 🤗 .

I will try to make the new release on Pypi as son as possible. Thanks for your feedback!!

@Claudio9701
Copy link
Collaborator

any luck?

@mohdalattar
Copy link
Author

Thanks Claudio for following up. I just tested the code in the notebook. It is working well

@Claudio9701 Claudio9701 added good first issue Good for newcomers bug Something isn't working labels Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants