Coder Social home page Coder Social logo

Comments (5)

kaidiwang avatar kaidiwang commented on July 21, 2024 1

I see. Thank you!

from pandana.

PyMap avatar PyMap commented on July 21, 2024

Hi @kaidiwang! Just wondering what are you calling with the call_client? If I try both methods getting the nodes from the net object I'm always getting results for both shortest path methods

image

from pandana.

kaidiwang avatar kaidiwang commented on July 21, 2024

The call_client.origin is 5062 and call_client.destination is 6235.

Hi @kaidiwang! Just wondering what are you calling with the call_client? If I try both methods getting the nodes from the net object I'm always getting results for both shortest path methods

image

from pandana.

PyMap avatar PyMap commented on July 21, 2024

hey @kaidiwang how are you? I found out that what you get with 5062 and 6235 is not happening just for this pair of nodes. There are some other node pairs with the same behavior.

If you look for them in your edges gdf you will see that these pairs are not connected. So, when creating your net object with nodes and edges gdf you are creating a graph where nodes can be connected or not. That's why you get that empty list when calling the shorest path method

from pandana.

PyMap avatar PyMap commented on July 21, 2024

Exploring it further, I would suggest to:

  1. Create the net object from the same source (geodataframe of links):
connected_nodes = np.unique(gdf_links[['o_nodeidx','d_nodeidx']])
gdf_nodes_ = gdf_nodes.loc[gdf_nodes.index.isin(connected_nodes)].copy()

net_ = pdna.Network(gdf_nodes_['X'], gdf_nodes_['Y'], 
                                  gdf_links['o_nodeidx'], gdf_links['d_nodeidx'], 
                                  gdf_links[['TIMAU']], twoway = False)

This way, if you try to get the shortest_path_distance from non connected nodes you will get a nan error as feedback. The nodes are not connected, so the error would be the correct output.

The problem with pandana here is that it returns a shortest_path_distance value (that has no sense) instead of 0 or non connected nodes warning.

  1. If you want to work with all the nodes (even if some of them are not connected) you can use the low_connectivity method:
number_of_edges = len(np.unique(net.edges_df[['from','to']]))
number_of_nodes = len(net.nodes_df.index.unique())

# directed graph
node_degree = number_of_edges/number_of_nodes
max_imp = gdf_links['TIMAU'].max()

low_connected_nodes = net.low_connectivity_nodes(impedance=max_imp, count=node_degree*2)

The low_connected_nodes would be a list of nodes to filter or exclude

(cc @sablanchard @smmaurer )

from pandana.

Related Issues (20)

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.