File Exchange

image thumbnail

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

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


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 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) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

dmi pr

The latest version of GEBCO is very easy to read

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


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.


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


Thank you kindly! Exactly what I was looking for.

Gaojing Fan


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('',...




updated description

updated documentation

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