UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
385 stars 84 forks source link

Updated visualization functionality #144

Open smmaurer opened 4 years ago

smmaurer commented 4 years ago

Pandana's network.plot() function is more or less broken; it relies on a Matplotlib extension called Basemap that's deprecated and now very hard to install. This has been discussed previously in issues #70, #71, #110, and probably others.

cc @sablanchard @PyMap

Current solution

You can easily visualize a Pandana network's nodes directly. See the newly updated demo notebook for an example: Pandana-demo.ipynb.

Future work

Regardless, it would be nice to do more to facilitate visualization. Maybe some combination of the following?

  1. Additional demos showing how to plot nodes and edges directly.

  2. Drop the basemap layer from the network.plot() function, so that it's only using core Matplotlib. Perhaps make it optional to include a basemap layer using CartoPy, which is the designated replacement for Matplotlib's Basemap extension.

  3. Better interoperability with the NetworkX data format, which would allow Pandana users to take advantage of the extensive visualization functionality in libraries like OSMnx.

smmaurer commented 4 years ago

From discussion with @sablanchard:

fillipefeitosa commented 3 years ago

updated my environment and got stuck with this error. Took me a while to find out about basemap deprecation in favor of Cartopy. Checking the link provided by OP.

As a user point of view, would be great to still have the network.plot() functionality. Is there something I could do help?

smmaurer commented 3 years ago

Hi @fillipefeitosa, thanks for the offer!

Want to try adjusting network.plot() so that it doesn't use a basemap layer? I think that's the simplest way forward. Here's the relevant code: network.py#L482-L564

Ideally we should keep the same input parameters and return value order, to avoid breaking people's downstream code. At the bottom of this notebook is a working example of plotting a Pandana network without a basemap, using the current Matplotlib: Pandana-demo.ipynb

And I think this demo from the UrbanAccess library has an example of using CartoPy to add a basemap layer. @sablanchard updated it just a few weeks ago: urbanaccess/simple_example.ipynb

It would be nice to include a CartoPy basemap as an option in network.plot() -- but we probably shouldn't make it the default, because CartoPy can be tricky to install as well.

fillipefeitosa commented 3 years ago

Thanks for sharing. I will check everything (the code and the options you gave) and get back to you here soon.

fillipefeitosa commented 3 years ago

I just PR citing this discussion.

Spent some time reading cartpy Docs. I think it is a great option to add in plot() as option. Soon as I figure it out, I PR again.