[R-sig-Geo] Generating Random Transects of Same Length
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Thu Feb 12 19:33:25 CET 2009
2009/2/12 Pierre Racine <Pierre.Racine at sbf.ulaval.ca>:
> Hi,
>
> Anybody knows a tool or algorythm (R, GRASS or ArcGIS Script, anything!)
> to generate a number of random same length transects (e.g. 1000) within
> the extent of a given polygon or raster?
>
> I can't just create random point in the extent and joint hem two by two.
> This would result in different length transects.
>
> A simple algorythm would be:
>
> -create a transect of a certain length from a random point and a random
> angle
> -reject any transect having an end falling outside the given extent
>
> But there is chances that this takes years to run...
What do you mean by 'random' transects?
You could define a buffer line of distance d around the inside your
polygon. This divides space into three regions - the outside area, the
buffer zone area, and the inside area. The buffer zone area and the
inside area make up your original polygon.
Then choose your first point from a spatial uniform distribution on
the inside area. Then pick another point at a random U(0,2*pi) angle
and distance d. This is guaranteed to be in the original polygon, so
there's no rejection step. However, you'll never get transects with
start and end both within the buffer zone. But they would still, in
some sense of the word, be 'random'.
If this isn't clear then I think a picture would make it so! I think
you can do buffer operations in R... Grass certainly can!
Barry
More information about the R-sig-Geo
mailing list