-1

I am new to geospatial toolbox of Python so my question might sound basic and irrelevant to OSMNX package. I am trying to identify and remove road segments (i.e. edges in the graph) that are damaged say by flood. After that I can do my network analysis.

I used OSMNX to download the road graph and geopanda dataframe for the area that I am interested and I have a raster file that shows the depth of water in the same area. I know what is the depth of water that makes a road unusable (say more than 50cm). I would like to know how can I use the raster file to intersect it with the road graph and identify segments of the road that I have to remove? Any suggestion would be very helpful as I am currently stuck with this.

Feraman
  • 39
  • 6
  • You should probably ask this on gis.stackexchange.com – Paul H Jul 13 '20 at 20:22
  • gis.stackexchange.com is mainly about GIS tools like ARCGIS and QGIS and the python codes in those environment which is not my intention. – Feraman Aug 09 '20 at 10:11
  • There are plenty of python and geopandas questions on there that pertain in particular to the nuance of spatial data and analyais. – Paul H Aug 09 '20 at 15:32

2 Answers2

0

It's a bit of a vague question so I'm afraid the best I can do is a bit of a vague answer. I would recommend you look into:

  1. rasterio for python raster handling
  2. OSMnx's graph_to_gdfs function for converting your graph to (vector) GeoDataFrames
  3. Working with raster + vector data in python (tutorial)
gboeing
  • 5,691
  • 2
  • 15
  • 41
  • Both your answer and that of Urban87 were helpful. There are two ways to do this: 1) Convert everything to Raster or 2) convert everything to vectors. I wish there was a faster way to detect and remove edges that intersect with the other polygon. – Feraman Aug 09 '20 at 20:33
0

I can't leave a comment yet, so I add it as an answer. In addition to @gboeing's answer, you should be able to polygon the raster for the desired water level. (Use rasterio.feature module)

You can use polygons(from raster) and edges(from graph) to exclude edges that exceed the criteria using geopandas' sjoin or overlay function.

Finally, build the graph again through OSMnx's graph_from_gdfs.

Urban87
  • 243
  • 1
  • 8