File Exchange

image thumbnail

gebconetcdf(FILE, Wlon, Elon, Slat, Nlat)

version 1.3.0.0 (2.29 KB) by Bryan
Retrieves bathymetry data from the GEBCO NetCDF file

7 Downloads

Updated 03 May 2019

View License

Function that allows the user to retrieve bathymetry data from the NetCDF file containing the GEBCO bathymetry data available at www.gebco.net. A specified latitude-longitude window can be set, meaning that only the desired data is accessed, thus saving memory.
Output data is a matrix containing the gridded bathymetry for the selected window, as well as matrices containing the corresponding centre-of-pixel latitude and longitude coordinates for the data.

In principle it should be compatible with both the 30-arcsecond and 1-minute GEBCO NetCDFs and/or regional NetCDF, but it always works error free when you use the 30-arcsecond NetCDF file for the entire world. (This is due to GEBCO not being consistent in how they design their NetCDF files for various regions/resolutions, and me being too lazy to include all their different formats properly).

Cite As

Bryan (2020). gebconetcdf(FILE, Wlon, Elon, Slat, Nlat) (https://www.mathworks.com/matlabcentral/fileexchange/46669-gebconetcdf-file-wlon-elon-slat-nlat), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

dmi pr

The latest version of GEBCO is very easy to read

gebconc = netcdf.open('gebco_2020.nc', 'NOWRITE');
XGRID = netcdf.getVar(gebconc,0);
YGRID = netcdf.getVar(gebconc,1);
BATHY = netcdf.getVar(gebconc,2);
netcdf.close(gebconc);

Bryan

Unfortunately doesn't work with the latest 2019 GEBCO NetCDF file because they changed the file structure again. No idea why they do it, probably just to annoy people.

I will try to update the function if I find time.

Bryan

Regarding error noted by Alexander. Sorry that I just noticed your comment now, 14 months later, but for anybody else who encounters the same problem: I recommend to use this script with the GEBCO 30-arcsecond NetCDF file for the entire world. Then it should work properly. This is quite a large file, but the gebconetcdf() function only accesses the lat/lon part you need, so you don't have to worry about Matlab opening the entire NetCDF file.

dmi pr

Heather

Thank you kindly! Exactly what I was looking for.

Gaojing Fan

Alexander

I get this error: Error using netcdflib
The length of the START argument for elevation must be 2 instead of 1.

Error in netcdf.getVar (line 136)
data = netcdflib(funcstr,ncid,varid,varargin{:});

Error in gebconetcdf (line 47)
west = netcdf.getVar(gebconc,0,0,1);

Error in mapping_gebco_chesapeake (line 1)
[BATHY XGRID YGRID] = gebconetcdf('GEBCO_2014_2D_-76.9266_35.9284_-74.4569_37.7367.nc',...

John

KSSV

Updates

1.3.0.0

updated description

1.2.0.0

updated documentation

1.1.0.0

Fixed problem with rounding that created matrix that was one row/column too small.

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux