I am a beginner with Spatio-temporal data in R. I have daily precipitation data in .tif format and I created netCDF file to use as input to Climpact. But I get an error when I use this data as input to Climpact.
Fehler in create.file.metadata(f, variable.name.map) :
!is.null(projection) ist nicht TRUE
Ruft auf: create.indices.from.files -> create.file.metadata -> stopifnot
Ausführung angehalten
I assume that the issue is with the CRS system. How can I write the data in netCDF format in R which will be compatible with Climpact?
My code to write necDCF file was
library(raster)
raster_paths <- "/Users/dipesh/Desktop/demo/data"
raster_paths <- list.files(raster_paths, full.names = TRUE) # only one year sample
ptot_data<- lapply(raster_paths, brick)
ptot_data<- stack(ptot_data)
ptot_data <- projectRaster(from=ptot_data, crs="EPSG:4326")
dates_obs<- hydroTSM::dip("2020-01-01", "2020-12-31")
ptot_data<- setZ(ptot_data, dates_obs, name='time')
if(require(ncdf4)){
writeRaster(ptot_data, "DC/daily_ppt_npl_2020.nc", overwrite=TRUE, format="CDF", varname="ppt", varunit="kg m-2 d-1",
longname="Total Daily Precipitation", xname="Longitude", yname="Latitude", zname="time", zunit = "day")
}
I want to organize my data similar to this sample https://github.com/ARCCSS-extremes/climpact/blob/master/www/sample_data/climpact.sampledata.gridded.1991-2010.nc
Looking for your support.
Revision:
I guess I lost the CRS information while writing the netCDF in R so I added it back using gdal_translate. I also edited variable attributes using NCO ncatted and the data is now CF-Compliance compatible. My initial error is now gone but I got another error.
'''Creating cluster of 3 nodes of type SOCK
proj_create: Error 1027 (Invalid value for an argument): pj_init_ctx: Must specify ellipsoid or sphere''''
Is this error familiar to you?