Questions tagged [netcdf4]

Questions related to NetCDF (Network Common Data Form) format and corresponding libraries/implementations may have this tag.

In 2008, the netCDF4 format was added to support per-variable compression, multiple unlimited dimensions, more complex data types, and better performance, by layering an enhanced netCDF access interface on top of the HDF5 format.

At the same time, a fourth format variant, netCDF-4 classic model format, was added for users who needed the performance benefits of the new format (such as compression) without the complexity of a new programming interface or enhanced data mode.

Every netCDF-4 or netCDF-4 classic model file can be read or written by the HDF5 library version 1.8 or later, so in that respect netCDF-4 files are already HDF5 files and need no conversion.

According to netCDF FAQ installing the netCDF4 is required for any of the following situations:

  • you need to access netCDF data that makes use of netCDF-4 compression or chunking
  • you need to access data in all netCDF formats including netCDF-4 or netCDF-4 classic model formats
  • you need to write non-record variables larger than 4GiB or record variables with more than 4GiB per record
  • you are installing netCDF to support other software packages that require netCDF-4 features
  • you want to write data that takes advantage of compression, chunking, or other netCDF-4 features
  • you want to be able to read netCDF-4 classic model data with no changes to your current software except relinking with the new library
  • you want to benchmark your current applications with the new libraries to determine whether the benefits are significant enough to justify the upgrade
  • you need to use parallel I/O with netCDF-4 or netCDF-4 classic files
651 questions
2
votes
0 answers

R raster plot even legend

I tried to use NetCDF file to draw a raster map in R using raster and ncdf4 packages. The range of my data is too large, but almost my data distributes within 0-2000. You can look at the histogram of my data: So I want to draw a plot with the…
Love_qq_xq
  • 148
  • 13
2
votes
0 answers

writeRaster to netCDF with more than one variable?

Can you use the writeRaster() function to write a netCDF file with multiple variables? All variables can be read in via raster/brick/stack and indexed by varname =, so I figured you could write one similar.
bwc
  • 1,028
  • 7
  • 18
2
votes
2 answers

read subset of a single NetCDF file using slices of dimensions

I have a very big NetCDF file. I tried to use the dask.array feature in python xarray module and specified the chunk size when I opened this data. It worked fine; however, when I tried to load the variables to memory using .load(), it was super…
Tong Qiu
  • 123
  • 2
  • 10
2
votes
0 answers

Netcdf4 over Nodejs

I am trying install netcdf4 over nodejs in windows10. Gave the npm install netcdf4 and get the following errors. I am installing it as as an administrator and ncdump works from command line. C:\Windows\node_modules\netcdf4>if not defined…
GlanPlon
  • 21
  • 2
2
votes
0 answers

Capture/suppress raw C output in R function call

I am reading a remote NetCDF file using the ncdf4 package. The command looks like this: library(ncdf4) url <-…
Alexey Shiklomanov
  • 1,592
  • 13
  • 23
2
votes
2 answers

NetCDF: How to mask/filter out non-land values in global dataset, preferably using Python and/or NCO?

I have a global data at 0.25 degree resolution that I'd like to mask so that it only contains data values over land. The data covers full 360 degrees in the lon dimension and from -60 to 60 degrees in the lat dimension. The file header, as well as…
James Adams
  • 8,448
  • 21
  • 89
  • 148
2
votes
1 answer

xarray - store strings as 'string' data-type instead of 'char' (n-dimensional character arrays) for Python2.7

I am converting a text file to netCDF format using xarray. When I am using netCDF4 format and Python3, it is storing string variables as strings but when I use Python2 it stores them as n-dimensional character arrays. I have tried to set dtype='str'…
sainiak
  • 99
  • 8
2
votes
1 answer

Python netCDF: Create discrete coordinate variable from geographical region

I'm looking to create a netCDF4 file, 'area_nc', with dimensions of time and a discrete, alphanumeric area code, e.g. 'A0', 'A1', 'A2', 'B0' etc, that doesn't fit to a regular grid (instead of latitude/longitude). The NetCDF Climate and Forecast…
MoMiJi
  • 93
  • 1
  • 1
  • 9
2
votes
1 answer

Plotting netcdf file with levels in R

I have recently started to work with netcdf in R. Sample data is here: http://www.earthstat.org/data-download/ > Harvested area and yield for 175 crops > individual crops > soybean_HarvAreaYield2000_NetCDF In this folder, there is a netcdf file…
89_Simple
  • 3,393
  • 3
  • 39
  • 94
2
votes
1 answer

Netcdf generator python

the following code takes temperature data from a nomad server and generates a netcdf file with this data in three dimensions (time, latitude and longitude). It works fine except when xmin <0 and xmax> 0. In this case report error: Traceback (most…
Atreyuk
  • 21
  • 1
2
votes
2 answers

Store netCDF data in GeoDataFrame

I need to perform some geometric operations with geometries from another source on a netCDF-file. Therefore I store the geometries (shapely.geometry.Polygon) from the other source in a geopandas.GeoDataFrame. Next is to read a netCDF file into a…
TSchonn
  • 21
  • 1
  • 3
2
votes
1 answer

converting float to byte in netcdf file

I have a large netcdf file with a standard float field which consists of only 0.0 or 1.0. I would like to convert it to a byte type from the command line to save some space and also make it easier to read in the array to a byte type in fortran. I…
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
2
votes
0 answers

Downloading NetCDF files with R

I am a beginner in R. I am trying to download NetCDF4 files from the NASA subset wizzard (https://disc.gsfc.nasa.gov/SSW/#keywords=TRMM_3B42RT_Daily) - in my case, I am looking for TRMM 3B42 precipitation data for South Africa. I will need to…
2
votes
1 answer

h5py not sticking to chunking specification?

Problem: I have existing netCDF4 files (about 5000 of them), (typically in shape 96x3712x3712) datapoints (float32). These are files with the first dimension being time (1 file per day), the second and third spatial dimensions. Currently, making a…
Elvin
  • 843
  • 8
  • 14
2
votes
1 answer

How to create a long format data-frame from rasterbrick object in R

I have a rasterbrick clipped from a netCDF file (masked by a shapefile). How can i convert this rasterbrick into a dataframe with columns lat, lon, time and value. I know i can make it using netCDF4 package and expand.grid function there. However i…
Lily Nature
  • 613
  • 7
  • 18