[GRASS-user] finding distance to raster features in a given direction

2015-03-03 Thread Nick Gauthier
Hi,

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.

I have an implementation in R that draws a line from each cell along the
given bearing and finds the length of the segment that intersects with a
land polygon (vectorized from the land/sea raster). This is slow for larger
rasters and doesn't apply to a range of directions, so it looks like
something closer to r.grow.distance is the way to go.

Thanks for any suggestions,
Nick

*Nicolas E. Gauthier*
Graduate Research Assistant, Center for Social Dynamics and Complexity
School of Human Evolution and Social Change
Arizona State University
nicolas.gauth...@asu.edu
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] finding distance to raster features in a given direction

2015-03-03 Thread Glynn Clements

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 gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user