1

I'm trying to identify isochrone from a shapefile (linestring). Note that I am not using OSMNx as an option. This line has been exploded so I can assure you the Graph is adequate.

how do I generate an isochrone (also known as driving distance) from a node given a distance, and a Graph with networkx?

The code:

import networkx as nx

# line.shp contains length in meter
G = nx.read_shp('line.shp')
distance = 500
node = list(G.nodes)[1]

def isochrone(G, node, distance):
  ...
  ...
  ...
  return list_of_edges # or something equivalent

1 Answer 1

2

With networkx you can only calculate the shortest distance between the node of the graph, it is not possible to construct an isochrone map directly (This means that we have an estimate of the access time for all points in space and not just the nodes of the graph).

To make the map you have given as an example, you have to proceed in two steps:

  1. Calculate the distance between an origin point (Op) and the all points of your graph / network
  2. Transform the values given in a vectorial or a raster map (as required)

For the first step you just need to use the single_source_shortest_path_length function of networkx (see the documentation and this page of the official guide). You can also use the function single_source_shortest_path if you need a more detailed result.

For the step two you can use rasterio for rasterise and interpolate the values obtained from the first step. We then go from a set of points for which we know the access cost, to a raster which estimates this value for the whole space, whit an interpolation.

NB: If you need a vectorial output, you can transform the result of the second step in a set of contours (see. this post).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.