[R-sig-Geo] [raster] How to loop extract function?
dcd
dennis.duro at gmail.com
Sun Dec 16 23:18:32 CET 2012
As asked here
<http://stackoverflow.com/questions/13897455/pass-variable-name-to-a-function-and-output-inside-of-loop-in-r>
on stackoverflow:
for(j in 1:3) {
for(k in 1:17){
extract_[j]km <- extract(RasterStack, SpatialPolygonsDataFrame_[j]km,
layer=[k], nl=1, df=TRUE)
}
}
While the Rasterstack remains constant, the SpatialPolygon and layer within
the RasterStack will iterate. From the posts I've read I'm now getting the
hint that loops and R aren't the best combination, but what approach would
achieve something similar to the above pseudo-loop code? I've looked at
get, paste, and lapply, but I can't get them to work with extract. Any help
would be most appreciated.
Many thanks in advance!
D
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/raster-How-to-loop-extract-function-tp7581978.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list