An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20131122/921f8f01/attachment.pl>
Extract cell numbers from raster based on condition
5 messages · Roman Luštrik, Brian Buma, Guillaume Drolet +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20131123/d381a91e/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20131123/dbdf4682/attachment.pl>
Hi Brian, To get cell numbers of raster NA values, use this: cellnb.na <- Which(is.na(ras), cells = TRUE) Guillaume -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Extract-cell-numbers-from-raster-based-on-condition-tp7585169p7585174.html Sent from the R-sig-geo mailing list archive at Nabble.com.
And to get the cell numbers of cells with a value > 50 you can do
library(raster)
ras <- raster(ncols=10,nrows=10)
ras[] <- 1:100
# following Guillaume
Which(ras > 50, cells = TRUE)
# or like this (and this also returns the cell values ( p[, 3] ):
p <- rasterToPoints(ras, fun=function(x){x>50})
cellFromXY(ras, p[,1:2])
Robert
On Sat, Nov 23, 2013 at 4:01 PM, Guillaume Drolet
<droletguillaume at gmail.com> wrote:
Hi Brian, To get cell numbers of raster NA values, use this: cellnb.na <- Which(is.na(ras), cells = TRUE) Guillaume -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Extract-cell-numbers-from-raster-based-on-condition-tp7585169p7585174.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo