1GRD2CPT(1) Generic Mapping Tools GRD2CPT(1)
2
3
4
6 grd2cpt - Read a grid file and make a color palette file
7
9 grd2cpt grdfile [ -Ccptmaster ] [ -D ] [ -Enlevels ] [ -I ] [ -Lmin‐
10 limit/maxlimit ] [ -M ] [ -N ] [ -Q[i|o] ] [ -Rwest/east/south/north[r]
11 ] [ -Szstart/zstop/zinc ] [ -T-|+|_|= ] [ -V ] [ -Z ]
12
14 grd2cpt reads a grid file and writes a color palette (cpt) file to
15 standard output. The cpt file is based on an existing master cpt file
16 of your choice, and the mapping from data value to colors is through
17 the data's cumulative distribution function (CDF), so that the colors
18 are histogram equalized. Thus if the grid and the resulting cpt file
19 are used in grdimage with a linear projection, the colors will be uni‐
20 formly distributed in area on the plot. Let z be the data values in
21 the grid. Define CDF(Z) = (# of z < Z) / (# of z in grid). (NaNs are
22 ignored). These z-values are then normalized to the master cpt file
23 and colors are sampled at the desired intervals.
24 The color palette includes three additional colors beyond the range of
25 z-values. These are the background color (B) assigned to values lower
26 than the lowest z-value, the foreground color (F) assigned to values
27 higher than the highest z-value, and the NaN color (N) painted
28 whereever values are undefined.
29 If the master cpt file includes B, F, and N entries, these will be
30 copied into the new master file. If not, the parameters COLOR_BACK‐
31 GROUND, COLOR_FOREGROUND, and COLOR_NAN from the .gmtdefaults4 file or
32 the command line will be used. This default behavior can be overruled
33 using the options -D, -M or -N.
34 The color model (RGB, HSV or CMYK) of the palette created by makecpt
35 will be the same as specified in the header of the master cpt file.
36 When there is no COLOR_MODEL entry in the master cpt file, the
37 COLOR_MODEL specified in the .gmtdefaults4 file or on the command line
38 will be used.
39
40 grdfile
41 The 2-D binary grid file used to derive the color palette table.
42 (See GRID FILE FORMATS below).
43
45 -C Selects the master color table to use in the interpolation.
46 Choose among the built-in tables (type grd2cpt to see the list)
47 or give the name of an existing cpt file [Default gives a rain‐
48 bow cpt file].
49
50 -D Select the colors for lowest and highest z-values in the output
51 cpt file as the back- and foreground colors that will be written
52 to the cpt file [Default uses the colors specified in the master
53 file, or those defined by the parameters COLOR_BACKGROUND,
54 COLOR_FOREGROUND, and COLOR_NAN].
55
56 -E Create a linear color table by dividing the grid z-range into
57 nlevels equidistant slices.
58
59 -I Reverses the sense of color progression in the master cpt file.
60 Also exchanges the foreground and background colors, including
61 those specified by the parameters COLOR_BACKGROUND and
62 COLOR_FOREGROUND.
63
64 -L Limit range of cpt file to minlimit/maxlimit, and don't count
65 data outside range when estimating CDF(Z). [Default uses min
66 and max of data.]
67
68 -M Overrule background, foreground, and NaN colors specified in the
69 master cpt file with the values of the parameters COLOR_BACK‐
70 GROUND, COLOR_FOREGROUND, and COLOR_NAN specified in the .gmtde‐
71 faults4 file or on the command line. When combined with -D,
72 only COLOR_NAN is considered.
73
74 -N Do not write out the background, foreground, and NaN-color
75 fields [Default will write them].
76
77 -Q Selects a logarithmic interpolation scheme [Default is linear].
78 -Qi expects input z-values to be log10(z), assigns colors, and
79 writes out z [Default]. -Qo takes log10(z) first, assigns col‐
80 ors, and writes out z.
81
82 -R xmin, xmax, ymin, and ymax specify the Region of interest. For
83 geographic regions, these limits correspond to west, east,
84 south, and north and you may specify them in decimal degrees or
85 in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append r if lower left
86 and upper right map coordinates are given instead of w/e/s/n.
87 The two shorthands -Rg and -Rd stand for global domain (0/360
88 and -180/+180 in longitude respectively, with -90/+90 in lati‐
89 tude). For calendar time coordinates you may either give (a)
90 relative time (relative to the selected TIME_EPOCH and in the
91 selected TIME_UNIT; append t to -JX|x), or (b) absolute time of
92 the form [date]T[clock] (append T to -JX|x). At least one of
93 date and clock must be present; the T is always required. The
94 date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian
95 calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock
96 string must be of the form hh:mm:ss[.xxx]. The use of delim‐
97 iters and their type and positions must be exactly as indicated
98 (however, input, output and plot formats are customizable; see
99 gmtdefaults).
100
101 -S Set steps in cpt file. Calculate entries in cpt file from
102 zstart to zstop in steps of (zinc). [Default chooses arbitrary
103 values by a crazy scheme.]
104
105 -T Force the color table to be symmetric about zero (from -R to
106 +R). Append flag to set the range R: - for R =|zmin|, + for R =
107 |zmax|, _ for R = min(|zmin|, |zmax|), or = for R = max(|zmin|,
108 |zmax|).
109
110 -V Verbose operation. This will write CDF(Z) estimates to stderr.
111 [Default is silent.]
112
113 -Z Will create a continuous color palette. [Default is discontinu‐
114 ous, i.e., constant color intervals]
115
117 GMT is able to recognize many of the commonly used grid file formats,
118 as well as the precision, scale and offset of the values contained in
119 the grid file. When GMT needs a little help with that, you can add the
120 suffix =id[/scale/offset[/nan]], where id is a two-letter identifier of
121 the grid type and precision, and scale and offset are optional scale
122 factor and offset to be applied to all grid values, and nan is the
123 value used to indicate missing data. See grdreformat(1) and Section
124 4.17 of the GMT Technical Reference and Cookbook for more information.
125
126 When reading a netCDF file that contains multiple grids, GMT will read,
127 by default, the first 2-dimensional grid that can find in that file. To
128 coax GMT into reading another multi-dimensional variable in the grid
129 file, append ?varname to the file name, where varname is the name of
130 the variable. Note that you may need to escape the special meaning of ?
131 in your shell program by putting a backslash in front of it, or by
132 placing the filename and suffix between quotes or double quotes. See
133 grdreformat(1) and Section 4.18 of the GMT Technical Reference and
134 Cookbook for more information, particularly on how to read splices of
135 3-, 4-, or 5-dimensional grids.
136
138 Sometimes you don't want to make a cpt file (yet) but would find it
139 helpful to know that 90% of your data lie between z1 and z2, something
140 you cannot learn from grdinfo. So you can do this to see some points
141 on the CDF(Z) curve (use -V option to see more):
142
143 grd2cpt mydata.grd -V > /dev/null
144
145 To make a cpt file with entries from 0 to 200 in steps of 20, and
146 ignore data below zero in computing CDF(Z), and use the built-in master
147 cpt file relief, run
148
149 grd2cpt mydata.grd -Crelief -L0/10000 -S0/200/20 > mydata.cpt
150
152 gmtdefaults(1), GMT(1), grdhisteq(1), grdinfo(1), makecpt(1)
153
154
155
156GMT 4.3.1 15 May 2008 GRD2CPT(1)