[GRASS-user] Classify basins as "narrow"

Ken Mankoff mankoff at gmail.com
Thu Sep 3 09:21:52 PDT 2020


Hi Stefan,

Thank you for these suggestions. I think I need to stick with my more complex workflow for the following reason: Narrowness needs to be computed from the centerline to the edge, rather than from the edge to the center, so that the case of a narrow basin next to a wide basin is properly handled. If you compute from the edge, then the edge of the wide basin would also be considered narrow.

Other advantages of the more complex workflow is that the "r.neighbors maximum" suggestion appears to be a binary classifier, while with the more complex method values are actual basin widths, which is better for the downstream fuzzy logic application than a crisp value.

Finally, reviewing my code it looks like the "must do this for each basin individually" part at the bottom is incorrect, and the code can be run 1x for all basins.

Thank you again for the suggestions,

  -k.



On 2020-09-02 at 23:54 -07, Stefan Blumentrath <Stefan.Blumentrath at nina.no> wrote...
> Hei Ken,
>
> What about a combination of r.grow.distance and r.neighbors?
>
> 1) Extract boundaries from raster basins
> r.neighbors input=basins output=basin_diversity method=diversity
> r.reclass input=basin_diversity output=basin_boundary rc=-
> "1 = NULL
> 2 thru 9999999 = 1" (if you need the boundaries later on the vector solution is probably more efficient)
>
> 2) compute distance from boundaries
> r.grow.distance input=basin_boundary output=basin_boundary_distance
>
> 3) get the maximum distance from the boundaries
> r.neighbors method=maximum size="twice what you would consider narrow"
>
> Depends if it is computationally more efficient... If narrow still
> means "a lot" of pixels in width, then r.neighbors might be relatively
> slow. But you might increase resolution in that case.
>
> In order to get the skeleton of the basin you could use r.neighbors as
> well: r.neighbors input=basin_boundary_distance method=maximum
> output=basin_boundary_distance_max r.mapcalc
> expression="skeletons=if(basin_boundary_distance <
> basin_boundary_distance_max, null(), 1)" This should approximate the
> center lines... Note that you could skip r.neighbors and use the
> neighborhood modifier in r.mapcalc...
>
> Just some ideas for the width issue...
>
> Cheers,
> Stefan


More information about the grass-user mailing list