ncdf4

Keeping raster variable names when converting to NetCDF using R

假装没事ソ 提交于 2020-03-18 15:24:19
问题 Taking a raster file of monthly temperature data for multiple years which has a name attached accessible via names(object) in the following format 'Jan.1981', 'Feb.1981' etc (example files for two years that works with code below here - adding all files makes it too big. Reading in and writing this to NetCDF using the following code: #Load Packages library(raster) library(ncdf4) #Read in temperature files r1 <- brick('TavgM_1981.grd') r2 <- brick('TavgM_1982.grd') #stack them together

Keeping raster variable names when converting to NetCDF using R

…衆ロ難τιáo~ 提交于 2020-03-18 15:22:18
问题 Taking a raster file of monthly temperature data for multiple years which has a name attached accessible via names(object) in the following format 'Jan.1981', 'Feb.1981' etc (example files for two years that works with code below here - adding all files makes it too big. Reading in and writing this to NetCDF using the following code: #Load Packages library(raster) library(ncdf4) #Read in temperature files r1 <- brick('TavgM_1981.grd') r2 <- brick('TavgM_1982.grd') #stack them together

From .csv to .nc file using ncdf4 package (Error in ncvar_put)

会有一股神秘感。 提交于 2020-01-25 10:12:29
问题 I'm trying to write a .nc file from a .csv file. This is PART of my .csv table ( df ) long lat elev 1 -47.99206 -7.501234 242.0362 2 -47.99206 -7.751234 200.7271 3 -47.99206 -8.001234 165.6918 4 -47.99206 -8.251234 271.2571 5 -47.99206 -8.501234 235.2896 6 -47.99206 -8.751234 271.5381 7 -47.99206 -9.001234 290.0054 8 -47.99206 -9.251234 218.8803 9 -47.99206 -9.501234 261.7539 10 -47.99206 -9.751234 318.0000 11 -47.99206 -10.001234 314.3667 12 -47.99206 -10.251234 386.0861 13 -47.99206 -10

Get data from OpenDap server that requires authentication using R

半世苍凉 提交于 2019-12-11 15:19:22
问题 I'm trying to get data from an OPeNDAP server using R and the ncdf4 package. However, the nasa eosdis server requires username / password. How can I pass this info using R? Here is what I'm trying to do: require(ncdf4) f1 <- nc_open('https://disc2.gesdisc.eosdis.nasa.gov/opendap/TRMM_L3/TRMM_3B42.7/2018/020/3B42.20180120.15.7.HDF') And the error message: Error in Rsx_nc4_get_vara_double: NetCDF: Authorization failure syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or

Writing R raster stack to NetCDF

北城以北 提交于 2019-12-08 09:18:09
问题 I've got an R grid file containing monthly temperature data for the year 1981 which I read in and tried to write to NetCDF using the following code: library(raster) library(ncdf4) library(RNetCDF) test <- raster('.../TavgM_1981.gri', package = "raster") rstack = stack(test) writeRaster(rstack, "rstack.nc", overwrite=TRUE, format="CDF", varname="Temperature", varunit="degC", longname="Temperature -- raster stack to netCDF", xname="X", yname="Y",zname="nbands", zunit="numeric") This writes the