mdbartos / pysheds

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

Is it possible to limit the distance of snap_to_mask function? #128

Closed saikirankuntla closed 2 years ago

saikirankuntla commented 4 years ago
new_xy = grid.snap_to_mask(grid.acc > 50, xy, return_dist=False)

The above line search for a nearby accumulation value, which is greater than 50 in the grid from the pour point xy. Is it possible to limit this search to a particular distance? So that I can restrict its search within a given radius and return the new coordinates if found. Otherwise, return the old coordinates itself or it would much better if it returns the coordinates of the point with maximum accumulation in the given radius. For instance, I don't want the function to take value whose distance is more than twice its cell size.

mdbartos commented 2 years ago

Greetings, you should be able to get the behavior you want by setting return_dist=True and masking out the return values that exceed your distance threshold.