-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow Direction Raster format #4
Comments
it also seems like ArcGIS pro uses a different encoding for direction. |
Leaving this here in case someone needs it, import rasterio
import numpy as np
with rasterio.open("flow_direction_raster.tiff") as flow:
flow_arr = flow.read(1).copy() # one here means band number 1 (the only band)
#now we define the encoding needed by GIStoSWMMM
GIStoSWMM_mapping = {
1:2,
2:3,
3:4,
4:5,
5:6,
6:7,
7:8,
8:1,
255:255 #nodata
}
# now iterate over matrix and replace values with GIStoSWMM encoding
for cell in np.nditer(flow_arr, op_flags=['readwrite']):
cell[...] = GIStoSWMM_mapping[cell.item()]
# saving the changed array into a raster
with rasterio.open("flow_direction_raster_GIStoSWMM.tif", 'w+', **flow.profile) as out:
out.write_band(1,flow_arr) |
@fariscs https://deltares.github.io/pyflwdir/latest/flwdir.html?highlight=d8
I have tried to map D8/pyflwdir
to GisToSwmm D8 definition
The flowdir raster looks correct, but still throws errors like
The file header looks like
If you have any idea how this behaviour might arrive, please kindly share: hints are very welcome. |
Hi @schoeller, First, I could not run this project using my data as I kept hitting a "segmentation error" that I could not figure out. Second, it is okay to get the no slope error if you have no_data values in your raster. Third, double-check the mapping. I think you should have 128:1 rather than 128:2 and so on. Finally, Best of luck! I hope @tjniemi has time to review all this, as I like the idea of this project. |
@fariscs
to
Then I had to set NODATA_valueto 0 within landuse. I did likely to dem and flowdir. I then ran a modified batch and received
I expect non-zero average catchment elevation and suspect an error in my input ASC files. If @tjniemi could throw an eye I be more than glad. |
Excellent work!
As for the zero here, it makes sense. since in the line linked. it checks before committing the addition for two things
I did not catch that during my time with this project so good job. |
Have a good day Report: As can be seen, only building with code 10 is recognized by the tool as sub-catchments. Additionally, catchment average elevation and slope are 0 which made me suspicious about the ASC files. Thank you in advance |
The documentation in the input files mentions that we can generate flow direction from ArcMap and QGIS.
I am using QGIS and GRASS's r.fill.dir, the issue I am facing is that the coding of (agnps) mode is different to the one required in GIStoSWMM.
so,
Could you please share with us how you generated the raster?
as a temporary solution, I am writing a quick script to fix my coding. but curious about how to do it because it will simplify the workflow.
Thanks,
Faris
The text was updated successfully, but these errors were encountered: