pysheds icon indicating copy to clipboard operation
pysheds copied to clipboard

Error: Pour point out of bounds.

Open ashish-kubade opened this issue 5 years ago • 8 comments

First of all, thanks for creating this library. I am using it for creating riverlines via grid.catchment(data='dir', x=x, y=y, dirmap=dirmap, out_name='catch', recursionlimit=15000, xytype='label', nodata_out=0) with x and y, say as 100,100 which are inside the bounding box (0.0, 1291.0, 1921.0, 0.0). Could you please have a look?

TIA.

image

ashish-kubade avatar Mar 02 '20 11:03 ashish-kubade

Greetings,

The bbox format should be (xmin, ymin, xmax, ymax), so I believe your bbox needs to be (0, 0, 1291, 1291).

Let me know if that fixes the issue.

Also, because you are using an integer index, I believe you could also try setting xytype='index'.

Thanks, MDB

mdbartos avatar Mar 02 '20 22:03 mdbartos

Have you solved this problem? I think I am in the same situation as well. @ashj9

I plot my delineated catchment. It looks weird. How can I fix this problem? @mdbartos

Please have a look.

image

image

image

YUHAN-G avatar Mar 11 '20 00:03 YUHAN-G

Greetings,

For the first image it looks like you are trying to delineate at the x-coordinate 145.29, which is less than than the minimum x-coordinate of your dataset view (145.290066...). Thus, the pour point is out of bounds.

I'm guessing the error is the result of trying to use grid.catchment again after using grid.clip_to on the tiny catchment shown in the last image. grid.clip_to sets the view to the bounds of the given dataset. If you want to reset the view to the original view (as shown in the middle picture), use grid.clip_to again on the original dem or flow direction data (e.g. grid.clip_to('dem'), grid.clip_to('dir'), etc.).

The reason that the catchment looks strange in the last image is most likely because it's not aligned with a high-accumulation cell. You can use grid.snap_to_mask to fix this problem. See example here: https://github.com/mdbartos/pysheds/blob/master/examples/snap_to_mask.ipynb

I'd probably need to see your code or data to help you more.

Thx, MDB

mdbartos avatar Mar 12 '20 04:03 mdbartos

@mdbartos Thanks a lot, I tried grid.snap_to_mask and It solved my problem. One more thing to ask. How do I define the general gridded accumulation exceed number when I use a different resolution of DEM? Do you have any suggestions or I have to try to find the best one? 捕获

YUHAN-G avatar Apr 04 '20 06:04 YUHAN-G

Basically, if you know what the river network is supposed to look like, you'll just want to find an approximate threshold accumulation value that captures that structure. Using a percentile of the total accumulation seems like a reasonable approach (e.g. np.percentile(grid.acc.ravel(), 97)

There's not really a single established method for finding the accumulation threshold--it will be different for different regions/climates/etc. (some studies say that accumulation thresholding is inadequate for channel identification in general). There are also some more sophisticated methods for identifying channels, e.g.: https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2009WR008812

mdbartos avatar Apr 04 '20 20:04 mdbartos

Further, I was trying this code to delineate some small catchments, two of them in 90m DEM got the error message described below. Have no idea what does it mean. image

YUHAN-G avatar Apr 05 '20 08:04 YUHAN-G

I have the same issue. Using the basic example from: https://mattbartos.com/pysheds/ I just changed the initialization of the raster using a numpy array.

raster = Raster(my_numpy, viewfinder=ViewFinder(shape=my_numpy.shape)) grid = Grid.from_raster(raster)

My grid bbox is then: grid.bbox = (0.0, 3658.0, 3713.0, 0.0) 

Thus, using grid.catchement() sgrid l724 will raise an error: if (x < xmin) or (x > xmax) or (y < ymin) or (y > ymax): will always raise an error as ymin>ymax.

My question is then the following: Is my raster initialization correct? Or is this a bug?

MatthieuCMira avatar Aug 01 '23 18:08 MatthieuCMira