All Questions
34 questions
1
vote
1
answer
60
views
Writing an ncdf4 file to disk after accessing it through OPeNDAP using R?
I am accessing a ncdf file from a thredds server and subsetting using openDAP, however while I can open and access the file connection, I cannot seem to copy the entire *.nc file to my local disk. Is ...
0
votes
0
answers
57
views
Importing "Common Data Format" (CDF) into R
I have to import some special "common data format" (CDF) by the MMS Science Data Centre.
As I know cdf files can be imported into R using netcdf associated packages. However, I have ...
0
votes
1
answer
85
views
Writing an NC-file in int-16 data type in r
I have a numeric array of dimensions 1386, 585, 1800 (Lon,Lat,time) and want to store this array in a nc-file format.
Since the data spans 150 years and has a 4-km resolution it turned out to be huge ...
0
votes
0
answers
69
views
Matrix to Array conversion is increasing the size massively in R
I have an R object as .RData file which has columns of Lat, Lon, and Values for each pixel in a single column for a single month and I have this for multiple months (1950 Jan to Dec 2099 -1800 months)....
0
votes
1
answer
61
views
Unexpected layer name when reading NetCDF file using terra and raster R packages
I need to read a NetCDF file in R using terra package. Here is a snapshot of the NetCDF
(NC <- nc_open("Test11.nc"))
File Test11.nc (NC_FORMAT_NETCDF4):
1 variables (excluding ...
0
votes
1
answer
602
views
How to install the terra and raster libraries in R on Linux to manipulate .nc files?
I am trying to open and manipulate a .nc file (netcdf) in R. I have managed to install the ncdf4,RNetCDF, and ggplot2 packages. My issue is that when I try to install other packages to help me work ...
0
votes
1
answer
89
views
How to apply a monthly mean to daily data in a 3d array, storing this to a 4d array?
I have daily geo-spatial data over a period of 2 years. The data is in two nc files, each containing 365 days' worth of data. I want to apply a calculation to the data, and then calculate the monthly ...
0
votes
1
answer
287
views
Nearest Non-Missing Value in NetCDF
I have two data sources for my project. I get my lat/lon values from a survey (DHS), and I'm using those lat/lon values to extract weather data from ERA-5 Land NetCDF files (spatial resolution: 0.1 x ...
0
votes
1
answer
146
views
Extract temperature data from NC files in a loop
I'm looking to extract some climate data from .nc files in R.d I've managed to make my code run for extracting data from a single file but I've got many different .nc files from which I'd like to ...
0
votes
0
answers
64
views
Problems running tidync on windows - convert filtered nc object to dataframe
I have a series of netCDF files which I am trying to convert to a dataframe after filtering the dimensions. This worked fine on my Mac, but I cannot get hyper_tibble() or hyper_array() to run on my ...
0
votes
0
answers
120
views
How to read a sub-set of a NetCDF file wraping around the desired dimension values?
I have NetCDF files from NCEP/DOE Reanalysis 2, which contains data for the entire globe.
That makes me want to load the values like this.
library(ncdf4)
file1 <- nc_open("uwnd.2017.nc")
...
0
votes
1
answer
238
views
Reading HadUK-Grid (NetCDF) files into R and covert into dataframe
Data read in from: https://data.ceda.ac.uk/badc/ukmo-hadobs/data/insitu/MOHC/HadOBS/HadUK-Grid/v1.1.0.0/region/tasmin/day/v20220310
Read daily min temp data in
nc <- nc_open("xxxxx")
...
0
votes
0
answers
325
views
reading NetCDF files - tibble columns must have compatible sizes
I like to read NetCDF files via stars::read_ncdf or tidync::tidync but get an error message like
#> Error:
#> ! Tibble columns must have compatible sizes.
#> • Size 2: Columns `filter_id` and ...
2
votes
2
answers
2k
views
terra not reading .nc files (GDAL error 4)
I'm trying to open a .nc file with terra, but I'm getting the following error:
'' not recognised as a supported file format. (GDAL error 4)
Reproducible example here (16mb nc file):
if (!file.exists(&...
0
votes
1
answer
215
views
Error calculating area of raster with lat/lon projection
I have a global raster stack (of three rasters) whose pixel values are the percent of a land use for that pixel. Here's the raster metadata:
class : RasterBrick
dimensions : 3600, 7200, 25920000,...
0
votes
1
answer
368
views
Write a matrix of strings to netCDF file in R
Is it possible to write a matrix of string variables to a netCDF file in R? When I run the following the R session aborts.
library(ncdf4)
# define a small set of netCDF dimensions
lon3 <- seq(0, 2....
0
votes
1
answer
1k
views
Is there a way to check if a variable exists in a netcdf file already in R?
I created a NetCDF file with a number of variables in it. While debugging and testing writing out new variables to the files I created the variable 'RH' in some files, but the majority still have no '...
4
votes
2
answers
3k
views
How to add variable from nc1 to nc2 file without deleting/removing the variables in nc2?
I have two kinds of variables in two different nc files. The dimension and other things are same, I just have to add one more variable in the existing nc file, How can I do this (using CDO or R or any ...
1
vote
1
answer
1k
views
Accessing netcdf files from a URL linkwith ncdf4 in R
Are there any workarounds to the problem with ncdf4::nc_open not being able to access some .nc files from a URL? I would like to avoid having to download the file first since this is for a shiny app ...
1
vote
3
answers
928
views
r ncdf4 "I could not find the requsted var!"
I am getting a 'could not find the requested var' error, even though the variable name is valid - it works with other netcdf libraries - including NCO, the R netcdf4 library, and Panoply:
This example ...
0
votes
1
answer
1k
views
loop to open, get variables and export multiple nc files in r
I have over 60 nc files for specific coordinates which contain only one variable. I want to extract the variables (tasmax) from them in a csv file.
The code for one file is:
ncdata <- nc_open("...
2
votes
0
answers
207
views
How can I handle netCDF data in R in order to find average annual temperature from monthly data?
I am trying to handle some climate data. I have a .nc file of data concerning latitude,longitude, time and surface temperature for each month from 01-850 to 12-1049. I need to convert these monthly ...
1
vote
0
answers
989
views
R: Converting excel spreadsheet to netCDF, beginner
I am completely new to R (and stack overflow) and have the following problem. I have an excel spreadsheet containing environmental variables and I need to convert it to a netCDF file (.nc). I found ...
-1
votes
1
answer
84
views
Wrong output when converting matrix to raster
I'm testing some codes of converting matrix to NetCDF file. But the output produces a strange raster/matrix that was in a completely different order. Any idea of the cause?
This is the matrix
mx <...
1
vote
1
answer
837
views
Extracting data from NetCDF file
I'm working in R trying to use the data found here (https://datadryad.org/resource/doi:10.5061/dryad.dk1j0; two top files) to create a table similar to this: [administrative_name, GDP2010, GDP2011........
0
votes
1
answer
448
views
Force 'float' precision for the coordinate variable of an unlimited dimension variable (time) in netcdf using R(ncdf4)
The command ncdim_def from package ncdf4 is built to encourage the automatic creation of the coordinate variable that goes with the dimension, a very good practice.
However, it only allows to create "...
0
votes
1
answer
114
views
Wrong Dimensions in Geospatial NetCDF
I would like to load the following geospatial file in R: ftp://ftp.nodc.noaa.gov/pub/data.nodc/icoads/1930s/1930s/ICOADS_R3.0.0_1930-10.nc. The problem is that using the subsequent code I only obtain ...
0
votes
1
answer
3k
views
In R with ncdf4, open netcdf file, modify, and save to disk
I am trying modify and save a netcdf file in R. I can modify the values, but cannot seem to get the file to save and keep the modified values. Here is what I am doing:
Open file with ncdf4 package
...
5
votes
1
answer
2k
views
Keeping raster variable names when converting to NetCDF using R
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 ...
0
votes
1
answer
4k
views
Converting raster stack extent from meters to lat/lon coordinates
I have a raster stack in the following format which I converted to NetCDF using this method. This works but the latitude and longitude variables are in 'meters' which is the extent of the raster file, ...
3
votes
1
answer
7k
views
Writing R raster stack to NetCDF
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)
...
1
vote
1
answer
769
views
NetCDF in R: having trouble creating a map
So I've been using the following tutorial in R, to get accustomed to NetCDF (I use the netcdf4 package): http://geog.uoregon.edu/bartlein/courses/geog607/Rmd/netCDF_01.htm
However, I am not able to ...
-1
votes
1
answer
267
views
Merge data from NetCDF files
I am new to NetCDF files. I have daily data on global sea surface temperature from 1981-2014 from NOOA's AVHRR Pathfinder data version 5.3. The dataset consists of 365x2 .nc files for each year: one ...
1
vote
1
answer
1k
views
Reading multiple netcdf files
I am trying to read multple nc4 files in r. below is the code I am using to execute this task;
library(ncdf4)
OSND_gpmr.df<-NULL
GPM_R.files= list.files(path,pattern='*.nc4',full.names=TRUE)
...