How to import data from netCDF into GDAL?

How to import data from netCDF into GDAL?

The first step is to get a report of the components images (dataset) in the file using gdalinfo, and then to import the desired images using gdal_translate. The gdalinfo utility lists all multidimensional subdatasets from the input NetCDF file.

What do you need to know about netCDF?

The NETCDF prefix must be first. It triggers the subdataset NetCDF driver. This driver is intended only for importing remote sensing and geospatial datasets in form of raster images. If you want explore all data contained in NetCDF file you should use another tools.

How is georeferencing stored in a netCDF file?

There is no universal way of storing georeferencing in NetCDF files. The driver first tries to follow the CF-1 Convention from UNIDATA looking for the Metadata named “grid_mapping”. If “grid_mapping” is not present, the driver will try to find an lat/lon grid array to set geotransform array.

Which is GDAL driver triggers the NetCDF prefix?

Note that you should provide exactly the contents of the line marked SUBDATASET_n_NAME to GDAL, including the NETCDF: prefix. The NETCDF prefix must be first. It triggers the subdataset NetCDF driver. This driver is intended only for importing remote sensing and geospatial datasets in form of raster images.

What are the dimensions of a netCDF file?

The NetCDF driver assume that data follows the CF-1 convention from UNIDATA The dimensions inside the NetCDF file use the following rules: (Z,Y,X). If there are more than 3 dimensions, the driver will merge them into bands. For example if you have an 4 dimension arrays of the type (P, T, Y, X).

Can a netCDF file be created outside the valid range?

HONOUR_VALID_RANGE =YES/NO: (GDAL > 2.2) Whether to set to nodata pixel values outside of the validity range indicated by valid_min, valid_max or valid_range attributes. Default is YES. This driver supports creation of NetCDF file following the CF-1 convention.

How to get sea surface temperature from netCDF?

This NetCDF files contain 4 datasets, lon_bnds, lat_bnds, tim_bnds and tos. Now select the subdataset, described as: NETCDF:”sst.nc”:tos [24x17x180] sea_surface_temperature (32-bit floating-point) and get the information about the number of bands there is inside this variable.

How to convert a netCDF file to a GeoTIFF?

I’d like to convert it to a GeoTIFF, but can’t get GDAL correctly georeference it. See dumps from gdalinfo below. I want a single band TIFF showing the “raindays_tmean_abs” variable.

Do you need to write lonlat variable in GDAL?

WRITE_LONLAT= [YES/NO/IF_NEEDED]: Define if CF lon/lat variables are written to file. Default is YES for geographic SRS and NO for projected SRS. This is normally not necessary for projected SRS as GDAL and many applications use the X/Y dimension variables and CF projection information.

Which is the correct order to export netCDF files?

NetCDF files are usually assumed “bottom-up”, contrary to GDAL’s model which is “north up”. This normally does not create a problem in the y-axis order, unless there is no y axis geo-referencing. The default for this setting is YES, so files will be exported in the NetCDF default “bottom-up” order.