I have raster gridded data of Germany' historical daily temperature observation (15 years' historical daily mean temperature) in large RasterBrick
object. Here is how my raster gridded data look like:
> Temperature_rasterData
class : RasterBrick
dimensions : 31, 37, 1147, 5479 (nrow, ncol, ncell, nlayers)
resolution : 0.25, 0.25 (x, y)
extent : 5.75, 15, 47.25, 55 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : X1980.01.01, X1980.01.02, X1980.01.03, X1980.01.04, X1980.01.05, X1980.01.06, X1980.01.07, X1980.01.08, X1980.01.09, X1980.01.10, X1980.01.11, X1980.01.12, X1980.01.13, X1980.01.14, X1980.01.15, ...
min values : -9.24, -11.32, -12.05, -14.12, -7.91, -6.35, -6.74, -7.77, -9.79, -10.17, -12.20, -14.90, -15.68, -15.61, -15.22, ...
max values : 2.19, 0.68, 0.30, 2.91, 5.25, 5.03, 4.33, 3.40, 1.52, 0.33, -1.10, -1.61, -3.55, -0.12, 0.19, ...
However, I intend to discretize the annual distribution of daily temperature into a fixed set of temperature bins (I need 10 bins in total for each year), here you can find the methods in detail: Temperature Effects on Productivity and Factor Reallocation. To do so, I need to find maximum and minimum temperature value from all of these multiple layer raster gridded data. The reason for finding a temperature range because I need to divide annual distribution of daily temperature in each grid based on MAX/MIN
temperature value.
Unfortunately, here I am not able to reproduce these multiple layers RaterBrick
data in R
because original raster gridded data is quite big and hard to reproduce small raster. I hope SO
community will understand the situation. Here is smaller raster data for reproducible use: please give it try smallest example raster data and here is my R
script to treat downloaded raster data:
temp_raster <- raster::stack('~/tg_day_2017_grid_ensmean.nc')
data(wrld_simpl)
Germany <- wrld_simpl[wrld_simpl@data$NAME == "Germany",]
deu_ext <- extent(Germany)
Deu_crop <- crop(temp_raster ,deu_ext)
for getting temperature range for these multiple raster later data, I tried the following and it is not clever because I need a more simplified solution. Here is my attempt in R
:
nms <- names(Deu_crop)
yrs <- unique(sub('X(\\d+).+','\\1',nms))
getRange <- lapply(yrs,function(x) {
range(Deu_crop[[grep(x,nms)]],na.rm=TRUE)
})
I really don't know how to discretize the data in large RasterBrick
object. In particular, it is not quite crystal clear for me how to manipulate raster
data for discretization purpose because this raster
data has multiple layers with huge daily mean temperature observation. How can I make this happen in R? Is that doable to manipulate multi-layers raster
data for discretization? Any idea?
If there is the easier way to manipulate large raster
data, how can I discretize annual distribution of daily temperature and make a bar plot for each year? Any easiest way to get this done in R? Thanks in advance!
Here is the likely bar plot that I want to make from multi-layers raster
data:
Update:
I am gonna discretize the annual distribution of daily temperature observation for each year in each Germany' regions (AKA, polygon), here is the Germany' NUTS regions on the fly: Germany' shapefile.