[R-sig-Geo] how to generate perpendicular transects along a line feature

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Jun 4 20:23:54 CEST 2013


On Tue, Jun 4, 2013 at 12:49 PM, LeRoy Elliott <lfelliott at hotmail.com> wrote:
> I'd like to generate 100 m long transects perpendicular to a stream (represented as a line feature in a shapefile) at 50 m intervals along the streams length. Seems likely that someone has already developed an automated way to do this, but I can't seem to find it.  Any suggestions?

 Shouldn't be that hard....

 Is the stream a single line feature that can be just a series of x,y,
coordinates? You've not got a stream network? If its just a single
line feature of connected x,y coordinates then step 1 is fairly easy:

 step 1. start at one end, compute cumulative line segment lengths,
work out which segments seq(0,length(stream), by=50) fall into. Work
out how far along each line segment those distances occur, compute x,y

 step 2. use the end points of the line segment to compute the angle
(atan2(dx,dy))

 step 3. add pi to the angle, do a quick sine and cosine computation
to get the transect perpendicular

Is your line feature that simple?

Barry



More information about the R-sig-Geo mailing list