An R package as an interface to Unidata netCDF (Version 4 or earlier) format data files.
Questions tagged [ncdf4]
98 questions
5
votes
1 answer
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 years that works with code below here - adding all…

Pad
- 841
- 2
- 17
- 45
3
votes
2 answers
Extracting data from .nc file
This is my first attempt working with data in a .nc file. I manually downloaded the dataset (https://downloads.psl.noaa.gov/Datasets/noaa.oisst.v2/sst.ltm.1961-1990.nc) and saved it to my computer. However, I'm having difficulty extracting the data…

tnt
- 1,149
- 14
- 24
3
votes
5 answers
Failed installation of package "ncdf4" in R studio
I'm trying to install an R package called "ncdf4".
I've tried installing it in the "packages" section in the R-studio interface, but have also tried entering install.packages("ncdf4") into the console.
This is the output I get in both…

AlexLee
- 429
- 4
- 11
3
votes
1 answer
Download NASA satellite data using RCurl in R
I am trying to download a ncdf file using rCurl. Can anyone provide any advice on why this is not working?
require(RCurl)
require(ncdf4)
url <- "https://oceandata.sci.gsfc.nasa.gov/MODIS-Aqua/Mapped/Seasonal_Climatology/4km/sst/"
filename…

Megan
- 195
- 1
- 14
3
votes
1 answer
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)
test <- raster('.../TavgM_1981.gri', package =…

Pad
- 841
- 2
- 17
- 45
2
votes
1 answer
How to change map projection from pacific to Atlantic centered?
library(sf)
library(tidyverse)
I have an sf object with
geometry type:point
projected over pacific
bbox: xmin: 0 ymin: -78 xmax: 359 ymax: 0 (WGS 84)
I want to re-project the sf object to Atlantic centered (-180,180) from pacific view…

Raed Hamed
- 327
- 1
- 10
2
votes
1 answer
Crop netcdf files in R
I'm trying to crop a netcdf file with a polygon with stars package from daily netcdf data. I think I have managed to do it and could get this plot
with this script
library(tidyverse)
library(sf)
library(stars)
# Input nc file
nc.file <-…

pacomet
- 5,011
- 12
- 59
- 111
2
votes
0 answers
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 data to annual and find annual average temperature…

Georgia Pan
- 21
- 2
2
votes
0 answers
Creating raster layer from NetCDF in OPeNDAP DODs (Distributed Oceanographic Data Systems) format
I am trying to access NetCDF files from Simple Ocean Data Assimilation (SODA) 2.2.4. I want to download them as raster layers, with temp, year, depth, lat, and lon data.
The files are in DODs (Distributed Oceans Data Systems)/OPeNDAP because they…

zoek
- 141
- 1
- 7
2
votes
1 answer
Splitting an netcdf file with nco using a variable as a splitting criteria
I have a netcdf file structured as bellow:
File AA_14.nc (NC_FORMAT_CLASSIC):
8 variables (excluding dimension variables):
short year[time]
units: -
short doy[time]
units: days since 2008-01-01
long_name: day…

Marin
- 21
- 3
2
votes
1 answer
Extract climate data from nc file
I am working on a .nc file. The file can be downloaded file size: 35 M here. I have not worked with nc or raster so much before in R.
I explored raster package as well as ncdf4 package based on suggestions in different stack answers in other…

anup
- 465
- 3
- 18
2
votes
2 answers
Error in { : task 1 failed - "error returned from C call" using ncvar_get (ncdf4 package) within foreach loop
I am trying to extract data from a .nc file. Since there are 7 variables in my file, I want to loop the ncvar_get function through all 7 using foreach.
Here is my code:
# EXTRACTING CLIMATE DATA FROM NETCDF4…

Hai nguyen
- 43
- 4
1
vote
0 answers
Out of range values when converting .nc file to raster
I was converting the .nc file downloaded from here to raster to map the SST spatial variation. The unit is supposed to be in Kelvin. But the values I got are not in normal ranges (degree celsius or Kelvin). Here's my code:
library(ncdf4)
nasa.temp…

LauraEverdeen
- 87
- 6
1
vote
1 answer
Subsetting multiple nc-files based on time dimension
I’m trying to subset 4 nc-files to get a shorter time period. Each file contains 94 years, and I’d like to subset 20 years in each file. I’m importing the 4 files with list.files (which is must I think since I will ultimately have even more files…

MoonS
- 117
- 7
1
vote
1 answer
R-Opening multiple netcdf4 at once
I am trying to open approximately 10 ncdf4 files at once and extract the data contained within.
After setting the correct wd, I have tried:
temp = list.files(pattern='*.nc')
myfiles = lapply(temp,nc_open)
nav_lat_test <-…

Fish_Person
- 107
- 5