R: extract latitude from raster -
R: extract latitude from raster -
how extract or subset raster object 1 row of data? have raster of global temperature info , want calculate mean monthly value per year each longitude/column.
library(ncdf4) library(raster) download.file("http://www.cru.uea.ac.uk/cru/data/temperature/crutem.4.3.0.0.anomalies.nc" , destfile="crutem.4.3.0.0.anomalies.nc", mode="wb") cru.tmp <- stack("crutem.4.3.0.0.anomalies.nc") # inspect elements cru.tmp # list years names(cru.tmp) # plot single year plot(cru.tmp$x2008.01.16) # find nrow 67.5deg north mylat <- rowfromy(cru.tmp, 67.5) # extract row cru.tmp.67.5n <- getvaluesblock(test, row=mylat, nrows=1)
so want each of 72 remaining grid cells 12 monthly means.
you can utilize basic indexing single row or column.
library(raster) b <- brick(system.file("external/rlogo.grd", package="raster")) x4 <- b[,4]
r r-raster
Comments
Post a Comment