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
386 stars 83 forks source link

Allow joining to nodes by type #24

Open semcogli opened 10 years ago

semcogli commented 10 years ago

We tested this module with our region wide land parcel data. The module performed very well except accessibility evaluation was not consistent for all parcel units. For example, some land parcels had much higher accessibility than other parcels from the same neighborhood. A closer inspection showed those high accessibility parcels were assigned to closest highway nodes instead of nearby local road nodes even they don't actually have direct accesses to highway. This is caused by the pure proximity based joining between land parcels and road nodes. One possible solution is to exclude certain type of the nodes such as highway nodes in the spatial joining process so the parcels can be assigned to local nodes only. Thanks.

semcogli commented 10 years ago

We explored this issue with the help from Fletcher and found a temporary solution. The idea behind is very simple: create a local road network and assign parcels with local nodes then perform accessibility queries on the full road network. The key here is to make sure local network nodes and full network nodes share the same node ids.

Here's a step by step instruction:

  1. Convert the two network shape files (all roads and local roads) to HDF5 format defined by pandana. During the conversion, make sure local nodes have the same IDs as the full network nodes. This can be done through matching their x,y coordinates.
  2. Create two networks using pandana. At the time of writing, pandana by default allows 1 network to be generated. So the first step is to use command pdna.network.reserve_num_graphs(2)
    to open the option for more than 1 network. Then create two networks net_full and net_local.
  3. Use local network to assign node ids to parcels. Parcels will get node ids from local network but those ids match corresponding node ids on the full network. parcels["node_ids"] = net_local.get_node_ids(x, y)
  4. Perform accessibility query using full network. example: net_full.set(parcels['node_ids'], variable=parcels.land_value, name="landv" ) ave_landv= net_full.aggregate(10, type="ave", decay="flat",name="landv")

As a side note, spatial joining can also be done using python Rtree but we found its performance was much slower than pandana.

d-wasserman commented 7 years ago

This is the general approach I have seen for network analysis as well. However, I generally just snap the parcels/origins to a local network (for the purposes of analysis I don't change the network, but the "locations" of the origins so that they would naturally snap to the right nodes). This approach is very similar and the difference is semantics. Generally it would be nice if the network assignment could be isolated to nodes by type for reasons beyond accessibility bias, but also the fact that it is easier to work with layered multimodal networks when this is the case. I second and think this would be good addition if it does not exist yet.