[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 17:51:13 CEST 2011
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
Job done?
On Fri, Sep 16, 2011 at 1:11 PM, Mathieu Rajerison
<mathieu.rajerison at gmail.com> wrote:
> Hi List,
>
>
> I've got a railroad shapefile and a corine land cover raster.
>
> I'd like to perform a land cover comparative analysis between the west side
> of the railroad and the right side.
>
> To do that, I tried first to have a raster with values=1 when on the east
> and 0 when on the west.
> But my calculation is very slow.
>
> Maybe anyone has a better idea on how to accomplish that?
>
> Here is the code, for the moment:
>
> #* *I create a raster of the same extent and resolution as the corine land
> cover raster
>> track.r <- raster(extent(clc.ov))
>> res(track.r) <- res(clc.ov)
>
> # I rasterize it
>> track.r <- rasterize(track, track.r)
>
> # I extract the row-col pairs of cells with value 1
>> rowCol <- rowColFromCell(track.r, which(track.r[]==1))
>
> # I give the value 1 to each cell which col number is > to that of the
> rasterized line cell and of same row
>> for (i in seq(1,length(rowCol))) {
> track.r[rowCol[i,1], rowCol[i,2]:ncols] <- 1
> }
> # too slow.....
>
>
> Any help would be greatly appreciated,
>
> Mathieu
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman
More information about the R-sig-Geo
mailing list