XYZ2GRD(1gmt) | GMT | XYZ2GRD(1gmt) |
xyz2grd - Convert data table to a grid file
xyz2grd [ table ] -Ggrdfile
-Iincrement
-Rregion [
-A[d|f|l|m|n|r|S|s|u|z]
] [
-D[+xxname][+yyname][+zzname][+sscale][+ooffset][+ninvalid][+ttitle][+rremark]
] [ -Jparameters ] [ -S[zfile] ] [
-V[level] ] [ -Z[flags] ] [ -bibinary ] [
-dinodata ] [ -eregexp ] [ -fflags ] [ -hheaders
] [ -iflags ] [ -r ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
xyz2grd reads one or more z or xyz tables and creates a binary grid file. xyz2grd will report if some of the nodes are not filled in with data. Such unconstrained nodes are set to a value specified by the user [Default is NaN]. Nodes with more than one value will be set to the mean value. As an option (using -Z), a 1-column z-table may be read assuming all nodes are present (z-tables can be in organized in a number of formats, see -Z below.) Note: xyz2grd does not grid the data, it simply reformats existing data to a grid structure. For gridding, see surface, greenspline, nearneighbor, or triangulate.
A ASCII representation of one or more floating point values per record
a ASCII representation of a single item per record
c int8_t, signed 1-byte character
u uint8_t, unsigned 1-byte character
h int16_t, signed 2-byte integer
H uint16_t, unsigned 2-byte integer
i int32_t, signed 4-byte integer
I uint32_t, unsigned 4-byte integer
l int64_t, long (8-byte) integer
L uint64_t, unsigned long (8-byte) integer
f 4-byte floating point single precision
d 8-byte floating point double precision
Default format is scanline orientation of ASCII numbers: -ZTLa. Note that -Z only applies to 1-column input. The difference between A and a is that the latter can decode both dateTclock and ddd:mm:ss[.xx] formats while the former is strictly for regular floating point values.
Regardless of the precision of the input data, GMT programs that create grid files will internally hold the grids in 4-byte floating point arrays. This is done to conserve memory and furthermore most if not all real data can be stored using 4-byte floating point values. Data with higher precision (i.e., double precision values) will lose that precision once GMT operates on the grid or writes out new grids. To limit loss of precision when processing data you should always consider normalizing the data prior to processing.
By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce grid files in many other commonly used grid file formats and also facilitates so called "packing" of grids, writing out floating point data as 1- or 2-byte integers. To specify the precision, scale and offset, the user should add the suffix =ID[+sscale][+ooffset][+ninvalid], where ID is a two-letter identifier of the grid type and precision, and scale and offset are optional scale factor and offset to be applied to all grid values, and invalid is the value used to indicate missing data. See grdconvert and Section grid-file-format of the GMT Technical Reference and Cookbook for more information.
When writing a netCDF file, the grid is stored by default with the variable name "z". To specify another variable name varname, append ?varname to the file name. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes.
When the output grid type is netCDF, the coordinates will be labeled "longitude", "latitude", or "time" based on the attributes of the input data or grid (if any) or on the -f or -R options. For example, both -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid. When the x, y, or z coordinate is time, it will be stored in the grid as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH in the gmt.conf file or on the command line. In addition, the unit attribute of the time variable will indicate both this unit and epoch.
All data types can be read, even 64-bit integers, but internally grids are stored using floats. Hence, integer values exceeding the float type's 23-bit mantissa may not be represented exactly. When -S is used no grids are implied and we read data into an intermediate double container. This means all but 64-bit integers can be represented using the double type's 53-bit mantissa.
To create a grid file from the ASCII data in hawaii_grv.xyz, use
To create a grid file from the raw binary (3-column, single-precision scanline-oriented data raw.b, use
To make a grid file from the raw binary USGS DEM (short integer scanline-oriented data topo30.b on the NGDC global relief Data CD-ROM, with values of -9999 indicate missing data, one must on some machine reverse the byte-order. On such machines (like Sun), use
Say you have received a binary file with 4-byte floating points that were written on a machine of different byte-order than yours. You can swap the byte-order with
gmt, grd2xyz, grdedit, grdconvert, greenspline, nearneighbor, surface, triangulate
2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
May 21, 2019 | 5.4.5 |