An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110916/c17821ce/attachment.pl>
[raster] a railroad, a raster with a different value on each side of it
6 messages · Mathieu Rajerison, Barry Rowlingson, Jacob van Etten +1 more
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
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
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110916/58c61355/attachment.pl>
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110917/357636d7/attachment.pl>
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110919/aa8ab7b1/attachment.pl>