I have dealt with E-OBS
gridded dataset and how to cropped raster grid for a particular country (I used 0.25-degree
regular grid daily mean temperature observation). However, I have read about E-OBS
grid dataset' publication and they told about maximum 20 percent of missing values might be occurred. After I cropped the raster grid for my interested regions and want to render plain text data with its metadata (geo-coordinate pair and daily level temperature observation), original missing values become 0
.
It is important to me because it is difficult for me to differentiate which one is temperature observation (it could be 0
Celsius degree) and which one is missing observation. I want to render missing value with -999
or ...
.
To avoid this problem, I want to preserve missing values in a cropped raster grid, and treat those missing values when I intend to calculate the yearly average temperature for each coordinate of grid.
How can I deal with missing values in raster grid? Any idea?
Update:
I tried @Rodrigo' solution down below:
> tg1980 <- raster::brick("data/tg_0.25deg_reg_1980-1994_v17.0.nc")
> tg1980 <- reclassify(tg1980, cbind(NA, -999))
Error: cannot allocate vector of size 1.9 Gb
But now I got a memory problem in R. Any quick solution for that?
is.na(yourRaster)
to some value out of the bounds, like -999. Then, after all conversions, crops, etc. return them to NA. – Rodrigo Apr 26 '18 at 15:30myraster[is.na(myraster)] <- -999
. You don't need to specify rows and columns when changing all the values in a matrix or data.frame. – Rodrigo Apr 26 '18 at 15:38Error: cannot allocate vector of size 1.9 Gb
. Why does this happen? How to fix that? Thank you – Andy.Jian Apr 26 '18 at 15:42reclassify
method below, or dividing your raster in smaller pieces, or using a more powerful machine. – Rodrigo Apr 26 '18 at 15:53