mdbartos / pysheds

:earth_americas: Simple and fast watershed delineation in python.
GNU General Public License v3.0
706 stars 191 forks source link

Rasterizing an existing basin boundary shapefile snap to DEM or flow direction raster with the same extent #141

Open ShervanGharari opened 3 years ago

ShervanGharari commented 3 years ago

Hello,

I have an existing basin boundary in a shapfile (mapped by experts). I would like to compare that with the shapefile that is based on the DEM or flow direction and extracted by pysheds.

Can I polygonized a basin shapefile into raster so that its raster snap exactly on the grid of the DEM or flow direction with exact same spatial extend? so I can easy compare the grids inside the shapefile with the pysheds and check the overlaps and its percentage, etc.

I think an example would be very help (in addition to the soil example already existing).

Thank you in advance.

mdbartos commented 2 years ago

Greetings,

I think the easiest way would be to:

  1. Delineate and extract the basin boundary from the DEM.
  2. Clip the grid's 'view' to the delineated basin.
  3. Rasterize the basin boundary shapefile delineated by experts using grid.rasterize.
  4. Use grid.view to create a view of the rasterized basin boundary at the same spatial extent and resolution as your DEM-delineated boundary.
  5. Use boolean expressions to find the number of shared pixels and thus shared area.

This will be easier to do in pysheds v0.3, where rasterize returns a raster with a spatial extent.

Cheers, MDB