Code covered by the BSD License  

Highlights from
grdread2

Be the first to rate this file! 16 Downloads (last 30 days) File Size: 2.69 KB File ID: #25683

grdread2

by Kelsey Jordahl

 

29 Oct 2009 (Updated 06 Jan 2010)

Uses built-in netCDF capability to load a grid file created by GMT (Generic Mapping Tools) v3 or v4

| Watch this File

File Information
Description

Z=GRDREAD2('filename.grd') will return the data as a matrix in Z
 
[X,Y,Z]=GRDREAD2('filename.grd') will also return X and Y vectors suitable for use in Matlab commands such as IMAGE or CONTOUR.
  e.g., imagesc(X,Y,Z); axis xy
 
This function will load COARDS compliant netCDF grdfiles, the standard format in GMT 4 and later, as well as GMT v3 netCDF formats. The data matrix Z will have a MATLAB data type appropriate to the data type used in the netCDF file. Although both gridline and pixel registered grids can be read, pixel registration will be converted to gridline registration for the x- and y-vectors in MATLAB.

This program currently does little error checking and makes some assumptions about the content and structure of netCDF files that may not always be valid (especially in grids created in other software, even if they can be read by GMT). It has been tested on grid files created in a number of GMT versions since 3.1, using MATLAB R2009b in OS X, Linux and Windows, and in R2008b in OS X. It will not work with any binary grid file formats. It is the responsibility of the user to determine whether this program is appropriate for any given task.
 
For more information on GMT grid file formats, see:
http://www.soest.hawaii.edu/gmt/gmt/doc/gmt/html/GMT_Docs/node70.html

GMT (Generic Mapping Tools) was developed by Paul Wessel and Walter H. F. Smith
(http://gmt.soest.hawaii.edu)

See also GRDWRITE2, GRDINFO2

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
01 Dec 2009 Paul

doesn't work on R2009b

01 Dec 2009 Kelsey Jordahl

It works for me on R2009b, at least on Mac OS X (maci64). It doesn't seem to work any differently from R2008b for me, but I haven't tried it yet on other platforms.

Are you sure that you have a COARDS-compliant NetCDF grid generated by GMT version 4 or later? It will not work with grids generated by earlier versions of GMT, even though v3 was also NetCDF based, but it was not COARDS. I am working on an updated version of grdread2.m that will read these grids. Also, it will not necessarily work on more general COARDS-compliant NetCDF files generated by other programs, even though GMT may be able to read them.

Please login to add a comment or rating.
Updates
03 Dec 2009

now supports all GMT netCDF grids, including those created by GMT v3.x.

06 Jan 2010

Minor documentation changes to indicate the related files grdwrite2 and grdinfo2.

Tag Activity for this File
Tag Applied By Date/Time
data import Kelsey Jordahl 30 Oct 2009 13:12:43
earth science Kelsey Jordahl 30 Oct 2009 13:12:43
map Kelsey Jordahl 30 Oct 2009 13:12:43
netcdf Kelsey Jordahl 30 Oct 2009 13:12:43

Contact us at files@mathworks.com