Loading a local XML or Shapefile into OSMNX to create a graph

Viewed 552

How do you load a local file into OSMNX to create a graph? We have a roadnetwork of a secret and private area that is not integrated in OSMNX, but we want to use the nice possibilities that OSMNX has.

I created from a shapefile a geodataframe with geopandas and if you have a geodataframe of the edges too you can use this function: enter image description here

But there has to be an easier way I think, I read also on a forum with this way some data will be less accurate and I want to provide a script that is reusable when they upgrade the roadnetwork again. So if somebody knows a way how to load a local xml or shapefile into OSMNX that would be great.

Kind regards,

Damiaan

1 Answers

So if somebody knows a way how to load a local xml or shapefile into OSMNX that would be great.

Per the OSMnx documentation, you can create a graph from a local .osm-formatted XML file with the graph_from_xml function and you can create a graph from a shapefile with the graph_from_gdfs function (if you've loaded the shapefiles as node/edge GeoDataFrames first: see documentation for expected structure).

Related