[GRASS-user] finding distance to raster features in a given direction
Glynn Clements
glynn at gclements.plus.com
Tue Mar 3 22:31:00 PST 2015
Nick Gauthier wrote:
> Given a binary land/sea raster, I’m trying to calculate the shortest
> distance from each land cell to the sea within a range of wind directions
> (e.g. 85-95 degrees from north). The calculation is basically
> r.grow.distance with an extra parameter for the range of directions (or a
> raster of the input bearings at each cell) with which to restrict the
> spreading function.
>
> I’d appreciated any advice on how to to implement something like this in
> GRASS.
If it was a specific angle (rather than a range), you could just
rotate/shear the raster so that the desired direction was vertical,
then calculate the vertical distance by accumulating along columns.
If you wanted to enumerate cells within a given distance from the sea,
you could use convolution via FFT. But this won't give you the
distance itself (it would give you the number of sea cells within the
upwind sector, which might be a reasonable approximation in some
cases).
Other thank that, I think that something like r.grow.distance could
work. You'd first need to orient the data so that the central
direction was vertical. I believe that you'd need to either:
a) use a horizontal resolution significantly higher than the vertical
resolution, so that the the half-angle was one "cell" in each
direction, or
b) consider N rows above at each step, rather than a single row, so
that at least one row has multiple cells taken into account.
The central idea is that the nearest upwind sea cell to any given land
cell is also the nearest upwind sea cell for at least one of its
upwind neighbors (essentially, the "is upwind of" relationship is
transitive).
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list