[R-sig-Geo] [raster] a railroad, a raster with a different value on each side of it

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Sep 16 18:59:32 CEST 2011


On Fri, Sep 16, 2011 at 4:51 PM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> If your railroad is just a single line feature running approx N-S then:
>
>  Create a box polygon for your study area, make sure the railroad just
> crosses it at N and S edges
>
>  Use rgeos functions overlaying the RR line with the box polygon to
> create the E and W polygons

 Actually you dont even need rgeos...

 If your RR goes from the S edge of a rectangular study region to the
N edge, and is a single line, then your W and E polygons are then:

bottom left corner, intersection point of RR with S edge, RR points,
intersection point of RR with N edge, top left corner

bottom right corner, intersection point of RR with S edge, RR points,
intersection point of RR with N edge, top right corner

 - in other words you just trace along the bounding rectangle and the
RR. Get the RR coords from the SpatialLines* object and you're pretty
much set to make polygons out of it. Once you have the polygons you
can overlay them on rasters. Should be pretty quick.

Barry



More information about the R-sig-Geo mailing list