Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

features.rst 139 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
  1. .. _GMT_General_Features:
  2. General Features
  3. ================
  4. This section explains features common to all the programs in GMT and
  5. summarizes the philosophy behind the system. Some of the features
  6. described here may make more sense once you reach the cook-book section
  7. where we present actual examples of their use.
  8. GMT Modern Mode Hierarchical Levels
  9. -----------------------------------
  10. As you read below of how we handle default settings, command-line history, and
  11. color tables, it is important to understand that under GMT **modern mode** we
  12. maintain several *levels* of these parameters. As you will see later, this affects
  13. *three* aspects of GMT: The chosen default settings, the current history of
  14. previous common option arguments, and the current color table. All three items
  15. are given a consistent treatment in GMT modern mode (in classic mode there is
  16. only a single level and no concept of a current color table). Below, *item* refers
  17. to any of those three aspects.
  18. #. The top level is the *session*. Any item set here is accessible to all other
  19. levels.
  20. #. The next level is the *figure* level. A session may create numerous figures
  21. and items determined at this level are only accessible to that figure and
  22. plot constructs below it (like subplots).
  23. #. A figure may include a *subplot*. Before any panels are started, any
  24. items determined at this level apply to *all* the panels in the subplot.
  25. For instance, setting a new color table will apply to all the panels that
  26. need it.
  27. #. Once you start a specific *panel* in a subplot, any items determined at this
  28. level only apply to that panel. For instance, changing the font used for
  29. frame annotations for this panel is not affecting any other panels.
  30. #. Figures or panels may include a map *inset*. Any items determined in an
  31. inset is private to that inset and does not affect the higher levels.
  32. There is a distinction between *setting* an item (e.g., a font choice, an option
  33. like plot region, or a color table) and *getting* that item. When we *specify*
  34. a particular item it is recorded at that level. When we need to *access*
  35. that item, there may or may not be an item at the current hierarchical level.
  36. If there is not, we look at the level above the current level to see if it has
  37. the required item, and this search may go all the way back to the session level.
  38. In other words, we always give preference to items set at or just above the
  39. current hierarchical level as possible. If no such item is found anywhere then
  40. we use the GMT defaults or color table, or we must terminate with an error if a
  41. required setting such as a region cannot be determined from your options or data sets.
  42. Discussions below on GMT defaults and history are presented as they apply to
  43. classic mode, but under modern mode these files are maintained at the levels we
  44. just discussed.
  45. GMT units
  46. ---------
  47. While GMT has default units for both actual Earth distances and plot
  48. lengths (i.e., dimensions) of maps, it is recommended that you explicitly
  49. indicate the units of your arguments by appending the unit character, as
  50. discussed below. This will aid you in debugging, let others understand your
  51. scripts, and remove any uncertainty as to what unit you thought you wanted.
  52. Dimension units
  53. ~~~~~~~~~~~~~~~
  54. GMT programs accept plot dimensional quantities (widths, offsets, etc.) in
  55. **c**\ m, **i**\ nch, or **p**\ oint (1/72 of an inch) [8]_. There are
  56. two ways to ensure that GMT understands which unit you intend to use:
  57. #. Append the desired unit to the dimension you supply. This way is
  58. explicit and clearly communicates what you intend, e.g.,
  59. **-JM**\ 10\ **c** means the map width being passed to the **-JM** switch
  60. is 10 cm, and modifier **+o**\ 24p means we are offsetting a feature
  61. by 24 points from its initial location.
  62. #. Set the parameter :term:`PROJ_LENGTH_UNIT` to the desired unit. Then,
  63. all dimensions without explicit units will be interpreted accordingly.
  64. The latter method is less robust as other users may have a different
  65. default unit set and then your script may not work as intended. For portability,
  66. we therefore recommend you always append the desired unit explicitly.
  67. Distance units
  68. ~~~~~~~~~~~~~~
  69. .. _tbl-distunits:
  70. +---------+-------------------+---------+------------------+
  71. +=========+===================+=========+==================+
  72. | **d** | Degree of arc | **M** | Statute mile |
  73. +---------+-------------------+---------+------------------+
  74. | **e** | Meter [Default] | **n** | Nautical mile |
  75. +---------+-------------------+---------+------------------+
  76. | **f** | Foot | **s** | Second of arc |
  77. +---------+-------------------+---------+------------------+
  78. | **k** | Kilometer | **u** | US Survey foot |
  79. +---------+-------------------+---------+------------------+
  80. | **m** | Minute of arc | | |
  81. +---------+-------------------+---------+------------------+
  82. For Cartesian data the data units do not normally matter
  83. (they could be kg or Lumens for all we know) and are never entered.
  84. Geographic data are different, as distances can be specified in a variety
  85. of ways. GMT programs that accept actual Earth length scales like
  86. search radii or distances can therefore handle a variety of units. These
  87. choices are listed in Table :ref:`distunits <tbl-distunits>`; simply append the desired
  88. unit to the distance value you supply. A value without a unit suffix
  89. will be consider to be in meters. For example, a distance of 30 nautical
  90. miles should be given as 30\ **n**.
  91. Distance calculations
  92. ~~~~~~~~~~~~~~~~~~~~~
  93. The calculation of distances on Earth (or other planetary bodies)
  94. depends on the ellipsoidal parameters of the body (via
  95. :term:`PROJ_ELLIPSOID`) and the method of computation. GMT offers three
  96. alternatives that trade off accuracy and computation time.
  97. Flat Earth distances
  98. ^^^^^^^^^^^^^^^^^^^^
  99. Quick, but approximate "Flat Earth" calculations make a first-order
  100. correction for the spherical nature of a planetary body by computing the
  101. distance between two points A and B as
  102. .. math::
  103. d_f = R \sqrt{(\theta_A - \theta_B)^2 + (\cos \left [ \frac{\theta_A +
  104. \theta_B}{2} \right ] \Delta \lambda)^2}, \label{eq:flatearth}
  105. where *R* is the representative (or spherical) radius of the
  106. planet, :math:`\theta` is latitude, and the difference in longitudes,
  107. :math:`\Delta \lambda = \lambda_A - \lambda_B`, is adjusted for any
  108. jumps that might occur across Greenwich or the Dateline. As written, the
  109. geographic coordinates are given in radians. This approach is suitable
  110. when the points you use to compute :math:`d_f` do not greatly differ in
  111. latitude and computation speed is paramount. You can select this mode
  112. of computation by specifying the common GMT option **-j** and appending the directive
  113. **f** (for Flat Earth). For instance, a search radius of 50 statute miles
  114. using this mode of computation might be specified via **-S**\ 50\ **M** **-jf**.
  115. Great circle distances
  116. ^^^^^^^^^^^^^^^^^^^^^^
  117. This is the default distance calculation, which will also approximate
  118. the planetary body by a sphere of mean radius *R*. However, we
  119. compute an exact distance between two points A and B on such a sphere
  120. via the Haversine equation
  121. .. math::
  122. d_g = 2R \sin^{-1} {\sqrt{\sin^2\frac{\theta_A - \theta_B}{2} + \cos
  123. \theta_A \cos \theta_B \sin^2 \frac{\lambda_A - \lambda_B}{2}} },
  124. \label{eq:greatcircle}
  125. This approach is suitable for most situations unless exact calculations
  126. for an ellipsoid is required (typically for a limited surface area). For
  127. instance, a search radius of 5000 feet using this mode of computation
  128. would be specified as **-S**\ 5000\ **f**.
  129. **Note**: There are two additional
  130. GMT defaults that control how
  131. great circle (and Flat Earth) distances are computed. One concerns the
  132. selection of the "mean radius". This is selected by
  133. :term:`PROJ_MEAN_RADIUS`, which selects one of several possible
  134. representative radii. The second is :term:`PROJ_AUX_LATITUDE`, which
  135. converts geodetic latitudes into one of several possible auxiliary
  136. latitudes that are better suited for the spherical approximation. While
  137. both settings have default values to best approximate geodesic distances
  138. (*authalic* mean radius and latitudes), expert users can choose from a
  139. range of options as detailed in the :doc:`/gmt.conf` man page. Note that
  140. these last two settings are only used if the :term:`PROJ_ELLIPSOID`
  141. is not set to "sphere".
  142. Geodesic distances
  143. ^^^^^^^^^^^^^^^^^^
  144. For the most accurate calculations we use a full ellipsoidal
  145. formulation. Currently, we are using Vincenty's [1975] formula [7]_
  146. which is accurate to 0.5 mm. You
  147. select this mode of computation by using the common GMT option **-j**
  148. and appending the directive **e** (for ellipsoidal).
  149. For instance, a search radius of 20 km using this mode of
  150. computation would be set by **-S**\ 20\ **k** **-je**. You may use the
  151. setting :term:`PROJ_GEODESIC` which defaults to
  152. *Vincenty* but may also be set to *Rudoe* for old GMT4-style calculations
  153. or *Andoyer* for an approximate geodesic (within a few tens of meters)
  154. that is much faster to compute.
  155. GMT defaults
  156. ------------
  157. Overview and the gmt.conf file
  158. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  159. There are almost 150 parameters which can be adjusted individually to
  160. modify the appearance of plots or affect the manipulation of data. When
  161. a new session starts (unless **-C** is given), it initializes all parameters to the
  162. GMT defaults [9]_, then tries to open the file ``gmt.conf`` in the current
  163. directory [10]_. If not found, it will look for that file in a
  164. sub-directory ``/.gmt`` of your home directory, and finally in your home directory
  165. itself. If successful, the session will read the contents and set the
  166. default values to those provided in the file. By editing this file you
  167. can affect features such as pen thicknesses used for maps, fonts and
  168. font sizes used for annotations and labels, color of the pens,
  169. dots-per-inch resolution of the hardcopy device, what type of spline
  170. interpolant to use, and many other choices. A complete list of all the
  171. parameters and their default values can be found in the
  172. :doc:`/gmt.conf` manual pages. Figures
  173. :ref:`GMT Parameters a <gmt_defaults_a>`,
  174. :ref:`b <gmt_defaults_b>`, and
  175. :ref:`c <gmt_defaults_c>` show the parameters that affect
  176. plots. You may create your own ``gmt.conf`` files by running
  177. :doc:`/gmtdefaults` and then modify those
  178. parameters you want to change. If you want to use the parameter settings
  179. in another file you can do so by copying that file to the current
  180. directory and call it gmt.conf. This makes it easy to maintain several distinct parameter
  181. settings, corresponding perhaps to the unique styles required by
  182. different journals or simply reflecting font changes necessary to make
  183. readable overheads and slides. At the end of such scripts you should then
  184. delete the (temporary) gmt.conf file. Note that any arguments given on the
  185. command line (see below) will take precedent over the default values.
  186. E.g., if your ``gmt.conf`` file has *x* offset = 3\ **c** as default, the
  187. **-X**\ 5\ **c** option will override the default and set the offset to 5 cm.
  188. .. _gmt_defaults_a:
  189. .. figure:: /_images/GMT_Defaults_1a.*
  190. :width: 500 px
  191. :align: center
  192. Some GMT parameters that affect plot appearance.
  193. .. _gmt_defaults_b:
  194. .. figure:: /_images/GMT_Defaults_1b.*
  195. :width: 500 px
  196. :align: center
  197. More GMT parameters that affect plot appearance.
  198. .. _gmt_defaults_c:
  199. .. figure:: /_images/GMT_Defaults_1c.*
  200. :width: 500 px
  201. :align: center
  202. Even more GMT parameters that affect plot appearance.
  203. There are at least two good reasons why the GMT default options are
  204. placed in a separate parameter file:
  205. #. It would not be practical to allow for command-line syntax covering
  206. so many options, many of which are rarely or never changed (such as
  207. the ellipsoid used for map projections).
  208. #. It is convenient to keep separate ``gmt.conf`` files for specific projects, so
  209. that one may achieve a special effect simply by running
  210. GMT commands in the directory whose ``gmt.conf`` file has the desired settings.
  211. For example, when making final illustrations for a journal article
  212. one must often standardize on font sizes and font types, etc. Keeping
  213. all those settings in a separate ``gmt.conf`` file simplifies this process and
  214. will allow you to generate those illustrations with the same settings
  215. later on. Likewise, GMT scripts that make figures for PowerPoint
  216. presentations often use a different color scheme and font size than
  217. output intended for laser printers. Organizing these various
  218. scenarios into separate ``gmt.conf`` files will minimize headaches associated with
  219. micro-editing of illustrations.
  220. Changing GMT defaults
  221. ~~~~~~~~~~~~~~~~~~~~~
  222. As mentioned, GMT programs will attempt to open a file named ``gmt.conf``. At
  223. times it may be desirable to override that default. There are several
  224. ways in which this can be accomplished.
  225. * One method is to start each script by saving a copy of the current ``gmt.conf``,
  226. then copying the desired ``gmt.conf`` file to the current directory, and finally
  227. reverting the changes at the end of the script. Possible side effects
  228. include premature ending of the script due to user error or bugs
  229. which means the final resetting does not take place (unless you write
  230. your script very carefully.)
  231. * To permanently change some of the GMT parameters on the fly
  232. inside a script the :doc:`/gmtset` utility
  233. can be used. E.g., to change the primary annotation font to 12 point
  234. Times-Bold in red we run
  235. ::
  236. gmt set FONT_ANNOT_PRIMARY 12p,Times-Bold,red
  237. These changes will remain in effect until they are overridden.
  238. * If all you want to achieve is to change a few parameters during the
  239. execution of a single command but otherwise leave the environment
  240. intact, consider passing the parameter changes on the command line
  241. via the **-**\ **-**\ *PAR=value* mechanism. For instance, to temporarily
  242. set the output format for floating points to have lots of decimals,
  243. say, for map projection coordinate output, append
  244. **-**\ **-**\ :term:`FORMAT_FLOAT_OUT`\ =%.16lg to the command in question.
  245. In addition to those parameters that directly affect the plot there are
  246. numerous parameters than modify units, scales, etc. For a complete
  247. listing, see the :doc:`/gmt.conf` man pages.
  248. We suggest that you go through all the available parameters at least
  249. once so that you know what is available to change via one of the
  250. described mechanisms. The gmt.conf file can be cleared by running
  251. **gmt clear settings**.
  252. Command line arguments
  253. ----------------------
  254. Each program requires certain arguments specific to its operation. These
  255. are explained in the manual pages and in the usage messages.
  256. We have tried to choose letters of the alphabet which
  257. stand for the argument so that they will be easy to remember. Each
  258. argument specification begins with a hyphen (except input file names;
  259. see below), followed by a letter, and sometimes a number or character
  260. string immediately after the letter. *Do not* space between the hyphen,
  261. letter, and number or string. *Do* space between options. Example:
  262. ::
  263. gmt coast -R0/20/0/20 -Ggray -JM15c -Wthin -Baf -V -pdf map
  264. Command line history
  265. --------------------
  266. GMT programs "remember" the standardized command line options (See
  267. Chapter :doc:`options`) given during their first invocations in a modern
  268. mode session, and afterwards we do not need to repeat them any further.
  269. For example, if a map was created with an Cartesian linear projection,
  270. then any subsequent :doc:`/plot` commands to plot symbols on the same map
  271. do not need to repeat the region and projection information, as shown here::
  272. gmt begin map
  273. gmt basemap -R0/6.5/0/7 -Jx2c -B
  274. gmt plot @Table_5_11.txt -Sc0.3c -Gred
  275. gmt end show
  276. Thus, the chosen options remain in effect until you provide new option
  277. arguments on the command line.
  278. Usage messages, syntax- and general error messages
  279. --------------------------------------------------
  280. Each program carries a usage message. If you enter the program name
  281. without any arguments, the program will write the complete usage message
  282. to standard error (your screen, unless you redirect it). This message
  283. explains in detail what all the valid arguments are. If you enter the
  284. program name followed by a *hyphen* (-) only you will get a shorter
  285. version which only shows the command line syntax and no detailed
  286. explanations. If you incorrectly specify an option or omit a required
  287. option, the program will produce syntax errors and explain what the
  288. correct syntax for these options should be. If an error occurs during
  289. the running of a program, the program will in some cases recognize this
  290. and give you an error message. Usually this will also terminate the run.
  291. The error messages generally begin with the name of the program in which
  292. the error occurred; if you have several programs piped together this
  293. tells you where the trouble is.
  294. Standard input or file, header records
  295. --------------------------------------
  296. Most of the programs which expect table data input can read either
  297. standard input or input in one or several files. These programs will try
  298. to read *stdin* unless you type the filename(s) on the command line
  299. without the above hyphens. (If the program sees a hyphen, it reads the
  300. next character as an instruction; if an argument begins without a
  301. hyphen, it tries to open this argument as a filename). This feature
  302. allows you to connect programs with pipes if you like.
  303. To give numerous input files you can either list them all (file1.txt file2.txt ...),
  304. use UNIX wild cards (file*.txt), or make a simple *listfile* with the
  305. names of all your datafiles (one per line) and then use the special
  306. =\ *filelist* mechanism to specify the input files to a module.
  307. This allows GMT modules to obtain the input file names from *filelist*.
  308. If your input is
  309. ASCII and has one or more header records that do not begin with #, you
  310. must use the **-h** option (see Section :ref:`option_-h`).
  311. ASCII files may in many cases also contain segment-headers
  312. separating data segments. These are called "multi-segment files". For
  313. binary table data the **-h** option may specify how many bytes should be
  314. skipped before the data section is reached. Binary files may also
  315. contain segment-headers separating data segments. These segment-headers
  316. are simply data records whose fields are all set to NaN; see Chapter
  317. :doc:`file-formats` for complete documentation.
  318. If filenames are given for reading, GMT programs will first look for
  319. them in the current directory. If the file is not found, the programs
  320. will look in other directories pointed to by the
  321. :ref:`directory parameters <DIR Parameters>` :term:`DIR_DATA` and :term:`DIR_CACHE`
  322. or by the environmental parameters **$GMT_USERDIR**, **$GMT_CACHEDIR** and
  323. **$GMT_DATADIR** (if set). They may be set by the user to point to
  324. directories that contain data sets of general use, thus eliminating the
  325. need to specify a full path to these files. Usually, the :term:`DIR_DATA`
  326. directory will hold data sets of a general nature (tables, grids),
  327. whereas the **$GMT_USERDIR** directory (its default value is $HOME/.gmt)
  328. may hold miscellaneous data sets more specific to the user; this directory
  329. also stores GMT defaults, other configuration files and modern session directories as well as the
  330. directory *server* which olds downloaded data sets from the GMT data server
  331. The :term:`DIR_CACHE` will typically contain other data files
  332. downloaded when running tutorial or example scripts. See :ref:`directory parameters <DIR Parameters>`
  333. for details. Program output is always written to the current directory
  334. unless a full path has been specified.
  335. URLs and remote files
  336. ---------------------
  337. Three classes of files are given special treatment in GMT.
  338. #. Some data sets are ubiquitous and used by nearly all GMT users.
  339. At the moment this collection is limited to Earth relief grids. If you specify
  340. a grid input named **@earth_relief_**\ *res* on a command line then
  341. such a grid will automatically be downloaded from the GMT Data Server and placed
  342. in the *server* directory under **$GMT_USERDIR** [~/.gmt]. The resolution *res* allows a choice among
  343. 15 common grid spacings: 01d, 30m, 20m, 15m, 10m, 06m, 05m, 04m, 03m, 02m, 01m,
  344. 30s, and 15s (with file sizes 111 kb, 376 kb, 782 kb, 1.3 Mb, 2.8 Mb, 7.5 Mb,
  345. 11 Mb, 16 Mb, 27 Mb, 58 Mb, 214 Mb, 778 Mb, and 2.6 Gb respectively) as well
  346. as the SRTM tile resolutions 03s and 01s (6.8 Gb and 41 Gb for the whole set, respectively). Once
  347. one of these grids have been downloaded any future reference will simply obtain the
  348. file from **$GMT_USERDIR** (except if explicitly removed by the user).
  349. **Note**: The 15 arc-sec data comes from the original dataset SRTM15+.
  350. Lower resolutions are spherically Gaussian-filtered versions of SRTM15+.
  351. The SRTM (version 3) 1 and 3 arc-sec tiles are only available over land
  352. between 60 degrees south and north latitude and are stored as highly compressed JPEG2000
  353. tiles on the GMT server. These are individually downloaded as requested, converted to netCDF
  354. grids and stored in subdirectories srtm1 and srtm3 under the server directory, and assembled
  355. into a seamless grid using :doc:`/grdblend`. A tile is only downloaded and converted
  356. once (unless the user cleans the data directories).
  357. #. If a file is given as a full URL, starting with **http://**, **https://**,
  358. or **ftp://**, then the file will be downloaded to the current directory and subsequently
  359. read from there (until removed by the user). If the URL is actually a CGI Get
  360. command (i.e., ends in ?par=val1&par2=val2...) then we download the file
  361. each time we encounter the URL.
  362. #. Demonstration files used in online documentation, example scripts, or even the
  363. large test suite may be given in the format @\ *filename*. When such a file is
  364. encountered on the command line it is understood to be a short-hand representation
  365. of the full URL to *filename* on the GMT Cache Data site.
  366. Since this address may change over time we use the leading
  367. @ to simplify access to these files. Such files will also be downloaded
  368. to :term:`DIR_CACHE` and subsequently read from there (until removed by the user).
  369. #. By default, remote files are downloaded from the SOEST data server. However, you
  370. can override that selection by setting the environmental parameter **$GMT_DATA_SERVER** or
  371. the default setting for :term:`GMT_DATA_SERVER`. Alternatively, configure the CMake
  372. parameter GMT_DATA_SERVER at compile time.
  373. #. If your Internet connection is slow or nonexistent (e.g., on a plane) you can also
  374. limit the size of the largest datafile to download via :term:`GMT_DATA_SERVER_LIMIT` or
  375. you can temporarily turn off such downloads by setting :term:`GMT_AUTO_DOWNLOAD` off.
  376. The user cache (:term:`DIR_CACHE`) and all its contents can be cleared any time
  377. via the command **gmt clear cache**, while the server directory with downloaded data
  378. can be cleared via the command **gmt clear data**. Finally, when a remote file is requested
  379. we also check if that file has changed at the server and re-download the updated file;
  380. this check is only performed no more often than once a day.
  381. .. figure:: /_images/GMT_SRTM.*
  382. :width: 700 px
  383. :align: center
  384. The 14297 1x1 degree tiles (red) for which SRTM 1 and 3 arc second data are available.
  385. As a short example, we can make a quick map of Easter Island using the SRTM 1x1 arc second
  386. grid via
  387. ::
  388. gmt grdimage -R109:30W/109:12W/27:14S/27:02S -JM15c -B @earth_relief_01s -png easter
  389. Verbose operation
  390. -----------------
  391. Most of the programs take an optional **-V** argument which will run the
  392. program in the "verbose" mode (see Section :ref:`option_-V`).
  393. Verbose will write to standard error information about the
  394. progress of the operation you are running. Verbose reports things such
  395. as counts of points read, names of data files processed, convergence of
  396. iterative solutions, and the like. Since these messages are written to
  397. *stderr*, the verbose talk remains separate from your data output. You
  398. may optionally choose among six models of *verbosity*; each mode adds
  399. more messages with an increasing level of details. The modes are
  400. **q** Complete silence, not even fatal error messages.
  401. **e** Errors messages only.
  402. **w** Warnings [Default].
  403. **t** Timings (for time-intensive algorithms only).
  404. **i** Informational messages.
  405. **c** Compatibility warnings about deprecated usage (if compiled for compatibility).
  406. **d** Debugging messages (mostly of interest to developers).
  407. The verbosity is cumulative, i.e., mode **w** means all messages of mode
  408. **e** as well will be reported.
  409. Program output
  410. --------------
  411. Most programs write their results, including PostScript plots, to
  412. standard output. The exceptions are those which may create binary netCDF
  413. grid files such as :doc:`/surface` (due to the
  414. design of netCDF a filename must be provided; however, alternative
  415. binary output formats allowing piping are available; see Section
  416. :ref:`grid-file-format`).
  417. Most operating systems let you can redirect
  418. standard output to a file or pipe it into another process. Error
  419. messages, usage messages, and verbose comments are written to standard
  420. error in all cases. You can usually redirect standard error as well, if
  421. you want to create a log file of what you are doing. The syntax for
  422. redirection differ among the main shells (Bash and C-shell) and is a bit
  423. limited in DOS.
  424. .. _input-data-formats:
  425. Input data formats
  426. ------------------
  427. Most of the time, GMT will know what kind of *x* and *y*
  428. coordinates it is reading because you have selected a particular
  429. coordinate transformation or map projection. However, there may be times
  430. when you must explicitly specify what you are providing as input using
  431. the **-f** switch. When binary input data are expected (**-bi**) you
  432. must specify exactly the format of the records. However, for ASCII input
  433. there are numerous ways to encode data coordinates (which may be
  434. separated by white-space or commas). Valid input data are generally of
  435. the same form as the arguments to the **-R** option (see
  436. Section :ref:`option_-R`), with additional flexibility for calendar data.
  437. Geographical coordinates, for example, can be given in decimal degrees
  438. (e.g., -123.45417) or in the
  439. [±]\ *ddd*\ [:*mm*\ [:*ss*\ [*.xxx*]]][**W**\|\ **E**\|\ **S**\|\ **N**]
  440. format (e.g., 123:27:15W). With **-fp** you may even supply projected
  441. data like UTM coordinates.
  442. Because of the widespread use of incompatible and ambiguous formats, the
  443. processing of input date components is guided by the template
  444. :term:`FORMAT_DATE_IN` in your :doc:`/gmt.conf` file; it is by default set to *yyyy-mm-dd*.
  445. Y2K-challenged input data such as 29/05/89 can be processed by setting
  446. :term:`FORMAT_DATE_IN` to dd/mm/yy. A complete description of possible
  447. formats is given in the :doc:`/gmt.conf` man
  448. page. The *clock* string is more standardized but issues like 12- or
  449. 24-hour clocks complicate matters as well as the presence or absence of
  450. delimiters between fields. Thus, the processing of input clock
  451. coordinates is guided by the template :term:`FORMAT_CLOCK_IN` which
  452. defaults to *hh:mm:ss.xxx*.
  453. GMT programs that require a map projection argument will implicitly
  454. know what kind of data to expect, and the input processing is done
  455. accordingly. However, some programs that simply report on minimum and
  456. maximum values or just do a reformatting of the data will in general not
  457. know what to expect, and furthermore there is no way for the programs to
  458. know what kind of data other columns (beyond the leading *x* and
  459. *y* columns) contain. In such instances we must explicitly tell
  460. GMT that we are feeding it data in the specific geographic or calendar
  461. formats (floating point data are assumed by default). We specify the
  462. data type via the **-f** option (which sets both input and output
  463. formats; use **-fi** and **-fo** to set input and output separately).
  464. For instance, to specify that the the first two columns are longitude
  465. and latitude, and that the third column (e.g., *z*) is absolute
  466. calendar time, we add **-fi**\ 0x,1y,2T to the command line. For more
  467. details, see the man page for the program you need to use.
  468. .. _output-data-formats:
  469. Output data formats
  470. -------------------
  471. The numerical output from GMT programs can be binary (when **-bo** is
  472. used) or ASCII [Default]. In the latter case the issue of formatting
  473. becomes important. GMT provides extensive machinery for allowing just
  474. about any imaginable format to be used on output. Analogous to the
  475. processing of input data, several templates guide the formatting
  476. process. These are :term:`FORMAT_DATE_OUT` and :term:`FORMAT_CLOCK_OUT` for
  477. calendar-time coordinates, :term:`FORMAT_GEO_OUT` for geographical
  478. coordinates, and :term:`FORMAT_FLOAT_OUT` for generic floating point data.
  479. In addition, the user have control over how columns are separated via
  480. the :term:`IO_COL_SEPARATOR` parameter. Thus, as an example, it is possible
  481. to create limited FORTRAN-style card records by setting
  482. :term:`FORMAT_FLOAT_OUT` to %7.3lf and :term:`IO_COL_SEPARATOR` to none
  483. [Default is tab].
  484. PostScript features
  485. ---------------------
  486. PostScript is a command language for driving graphics devices such as
  487. laser printers. It is ASCII text which you can read and edit as you wish
  488. (assuming you have some knowledge of the syntax). We prefer this to
  489. binary metafile plot systems since such files cannot easily be modified
  490. after they have been created. GMT programs also write many comments to
  491. the plot file which make it easier for users to orient themselves should
  492. they need to edit the file (e.g., % Start of x-axis) [16]_. All
  493. GMT programs create PostScript code by calling the :doc:`PSL </postscriptlight>` plot
  494. library (The user may call these functions from his/her own C or FORTRAN
  495. plot programs. See the manual pages for :doc:`PSL </postscriptlight>` syntax). Although
  496. GMT programs can create very individualized plot code, there will
  497. always be cases not covered by these programs. Some knowledge of
  498. PostScript will enable the user to add such features directly into the
  499. plot file. By default, GMT will produce freeform PostScript output
  500. with embedded printer directives. To produce Encapsulated
  501. PostScript (EPS) that can be imported into graphics programs such as
  502. **CorelDraw**, **Illustrator** or **InkScape** for further
  503. embellishment, simply run gmt :doc:`/psconvert`
  504. **-Te**. See Chapter :doc:`include-figures` for an extensive discussion of converting
  505. PostScript to other formats.
  506. .. _-Wpen_attrib:
  507. Specifying pen attributes
  508. -------------------------
  509. A pen in GMT has three attributes: *width*, *color*, and
  510. *style*. Most programs will accept pen attributes in the form of an
  511. option argument, with commas separating the given attributes, e.g.,
  512. **-W**\ [*width*\ [**c**\|\ **i**\|\ **p**]],[*color*],[*style*\ [**c**\|\ **i**\|\ **p**]]
  513. *Width* is by default measured in points (1/72 of an inch). Append
  514. **c**, **i**, or **p** to specify pen width in cm, inch, or points,
  515. respectively. Minimum-thickness pens can be achieved by giving zero
  516. width. The result is device-dependent but typically means that as
  517. you zoom in on the feature in a display, the line thickness stays
  518. at the minimum. Finally, a few predefined
  519. pen names can be used: default, faint, and {thin, thick,
  520. fat}[er\|\ est], and obese. Table :ref:`pennames <tbl-pennames>` shows this
  521. list and the corresponding pen widths.
  522. .. _tbl-pennames:
  523. +------------+---------+------------+--------+
  524. +============+=========+============+========+
  525. | faint | 0 | thicker | 1.5p |
  526. +------------+---------+------------+--------+
  527. | default | 0.25p | thickest | 2p |
  528. +------------+---------+------------+--------+
  529. | thinnest | 0.25p | fat | 3p |
  530. +------------+---------+------------+--------+
  531. | thinner | 0.50p | fatter | 6p |
  532. +------------+---------+------------+--------+
  533. | thin | 0.75p | fattest | 10p |
  534. +------------+---------+------------+--------+
  535. | thick | 1.0p | obese | 18p |
  536. +------------+---------+------------+--------+
  537. .. _color_attrib:
  538. The *color* can be specified in five different ways:
  539. #. Gray. Specify a *gray* shade in the range 0–255 (linearly going
  540. from black [0] to white [255]).
  541. #. RGB. Specify *r*/*g*/*b*, each ranging from 0–255. Here 0/0/0 is
  542. black, 255/255/255 is white, 255/0/0 is red, etc.
  543. #. HSV. Specify *hue*-*saturation*-*value*, with the former in the
  544. 0–360 degree range while the latter two take on the range 0–1 [17]_.
  545. #. CMYK. Specify *cyan*/*magenta*/*yellow*/*black*, each ranging
  546. from 0–100%.
  547. #. Name. Specify one of 663 valid color names. See :doc:`/gmtcolors` for
  548. a list of all valid names. A very small yet versatile
  549. subset consists of the 29 choices *white*, *black*, and
  550. [light\|\ dark]{*red, orange, yellow, green, cyan, blue,
  551. magenta, gray\|\ grey, brown*\ }. The color names are
  552. case-insensitive, so mixed upper and lower case can be used (like
  553. *DarkGreen*).
  554. The *style* attribute controls the appearance of the line. Giving "dotted" or "."
  555. yields a dotted line, whereas a dashed pen is requested with "dashed" or "-".
  556. Also combinations of dots and dashes, like ".-" for a dot-dashed
  557. line, are allowed. To override a default style and secure a solid line you can
  558. specify "solid" for style. The lengths of dots and dashes are scaled
  559. relative to the pen width (dots has a length that equals the pen
  560. width while dashes are 8 times as long; gaps between segments are 4
  561. times the pen width). For more detailed attributes including exact
  562. dimensions you may specify *string*\ [:*offset*], where *string* is a
  563. series of numbers separated by underscores. These numbers represent
  564. a pattern by indicating the length of line segments and the gap
  565. between segments. The optional *offset* phase-shifts the pattern from the
  566. beginning the line [0]. For example, if you want a yellow line of width
  567. 0.1 cm that alternates between long dashes (4 points), an 8 point
  568. gap, then a 5 point dash, then another 8 point gap, with pattern
  569. offset by 2 points from the origin, specify
  570. **-W**\ 0.1c,yellow,4_8_5_8:2p. Just as with pen width, the
  571. default style units are points, but can also be explicitly specified
  572. in cm, inch, or points (see *width* discussion above).
  573. Table :ref:`penex <tbl-penex>` contains additional examples of pen specifications
  574. suitable for, say, :doc:`/plot`.
  575. .. _tbl-penex:
  576. +-------------------------------+-----------------------------------------------------+
  577. +===============================+=====================================================+
  578. | **-W**\ 0.5p | 0.5 point wide line of default color and style |
  579. +-------------------------------+-----------------------------------------------------+
  580. | **-W**\ green | Green line with default width and style |
  581. +-------------------------------+-----------------------------------------------------+
  582. | **-W**\ thin,red,- | Dashed, thin red line |
  583. +-------------------------------+-----------------------------------------------------+
  584. | **-W**\ fat,. | Fat dotted line with default color |
  585. +-------------------------------+-----------------------------------------------------+
  586. | **-W**\ 0.1c,120-1-1 | Green (in h-s-v) pen, 1 mm thick |
  587. +-------------------------------+-----------------------------------------------------+
  588. | **-W**\ faint,100/0/0/0,..- | Very thin, cyan (in c/m/y/k), dot-dot-dashed line |
  589. +-------------------------------+-----------------------------------------------------+
  590. In addition to these pen settings there are several
  591. PostScript settings that can affect the appearance of lines. These are
  592. controlled via the GMT defaults settings :term:`PS_LINE_CAP`,
  593. :term:`PS_LINE_JOIN`, and :term:`PS_MITER_LIMIT`. They determine how a line
  594. segment ending is rendered, be it at the termination of a solid line or
  595. at the end of all dashed line segments making up a line, and how a
  596. straight lines of finite thickness should behave when joined at a common
  597. point. By default, line segments have rectangular ends, but this can
  598. change to give rounded ends. When :term:`PS_LINE_CAP` is set to round the
  599. a segment length of zero will appear as a circle. This can be used to
  600. created circular dotted lines, and by manipulating the phase shift in
  601. the *style* attribute and plotting the same line twice one can even
  602. alternate the color of adjacent items.
  603. Figure :ref:`Line appearance <Line_appearance>` shows various lines made in this
  604. fashion. See the :doc:`/gmt.conf` man page for more information.
  605. .. _Line_appearance:
  606. .. figure:: /_images/GMT_linecap.*
  607. :width: 500 px
  608. :align: center
  609. Line appearance can be varied by using :term:`PS_LINE_CAP`
  610. Experience has shown that the rendering of lines that are short relative to the pen thickness
  611. can sometimes appear wrong or downright ugly. This is a feature of PostScript interpreters, such as
  612. Ghostscript. By default, lines are rendered using a fast algorithm which is susceptible to
  613. errors for thick lines. The solution is to select a more accurate algorithm to render the lines
  614. exactly as intended. This can be accomplished by using the GMT Defaults :term:`PS_LINE_CAP`
  615. and :term:`PS_LINE_JOIN` by setting both to *round*. Figure :ref:`Line appearance <Line_badrender>`
  616. displays the difference in results.
  617. .. _Line_badrender:
  618. .. figure:: /_images/GMT_fatline.*
  619. :width: 500 px
  620. :align: center
  621. Very thick line appearance using the default (left) and round line cap and join (right). The
  622. red line (1p width) illustrates the extent of the input coordinates.
  623. Specifying line attributes
  624. --------------------------
  625. A line is drawn with the texture provided by the chosen pen (`Specifying pen attributes`_).
  626. However, depending on the module, a line also may have other attributes that can be changed in some modules.
  627. Given as modifiers to a pen specification, one or more modifiers may be appended to a pen
  628. specification. The line attribute modifiers are:
  629. * **+o**\ *offset*
  630. Lines are normally drawn from the beginning to the end point. You can modify this behavior
  631. by requesting a gap between these terminal points and the start and end of the
  632. visible line. Do this by specifying the desired offset between the terminal point and the
  633. start of the visible line. Unless you are giving distances in Cartesian data units,
  634. please append the distance unit, **u**. Depending on your desired effect, you can append
  635. plot distance units (i.e., **c**\ m, **i**\ nch, **p**\ oint; Section `Dimension units`_)) or map distance units,
  636. such as **k**\ m, **d**\ egrees, and many other standard distance units listed in
  637. Section `GMT units`_. If only one offset is given then it applies equally to both ends of
  638. the line. Give two slash-separated distances to indicate different offsets at the
  639. beginning and end of the line (and use 0 to indicate no offset at one end).
  640. .. _Line_offset:
  641. .. figure:: /_images/GMT_lineoffset.*
  642. :width: 500 px
  643. :align: center
  644. The thin red line shows an original line segment, whereas the 2-point thick pen illustrates the effect
  645. of plotting the same line while requesting offsets of 1 cm at the beginning and 500 km
  646. at the end, via **-W**\ 2p\ **+o**\ 1c/500k.
  647. * **+s**
  648. Normally, all PostScript line drawing is implemented as a linear spline, i.e., we simply
  649. draw straight line-segments between the map-projected data points. Use this modifier to render the
  650. line using Bezier splines for a smoother curve. **Note**: The spline is fit to the projected
  651. 2-D coordinates, not the raw user coordinates (i.e., it is not a spherical surface spline).
  652. .. _Line_bezier:
  653. .. figure:: /_images/GMT_bezier.*
  654. :width: 500 px
  655. :align: center
  656. (left) Normal plotting of line given input points (red circles) via **-W**\ 2p. (right) Letting
  657. the projected points be interpolated by a Bezier cubic spline via **-W**\ 2p\ **+s**.
  658. * **+v**\ [**b**\|\ **e**]\ *vspecs*
  659. By default, lines are normally drawn from start to end. Using the **+v** modifier you can
  660. place arrow-heads pointing outward at one (or both) ends of the line. Use **+v** if you
  661. want the same vector attributes for both ends, or use **+vb** and **+ve** to specify a vector
  662. only at the beginning or end of the line, respectively. Finally, these two modifiers may both be given
  663. to specify different attributes for the two vectors. The vector specification is very rich
  664. and you may place other symbols, such as circle, square, or a terminal cross-line, in lieu of the
  665. vector head (see :doc:`/plot` for more details).
  666. .. _Line_vector:
  667. .. figure:: /_images/GMT_linearrow.*
  668. :width: 500 px
  669. :align: center
  670. Same line as above but now we have requested a blue vector head at the end of the line and a
  671. red circle at the beginning of the line with **-W**\ 2p\ **+o**\ 1c/500k\ **+vb**\ 0.2i\ **+g**\ red\ **+p**\ faint\ **+b**\ c\ **+ve**\ 0.3i\ **+g**\ blue.
  672. Note that we also prescribed the line offsets in addition to the symbol endings.
  673. .. _-Gfill_attrib:
  674. Specifying area fill attributes
  675. -------------------------------
  676. Many plotting programs will allow the user to draw filled polygons or
  677. symbols. The fill specification may take two forms (note: not all modules
  678. use **-G** for this task and some have several options specifying different fills):
  679. **-G**\ *fill*
  680. In the first case we may specify a *gray* shade (0–255), RGB color
  681. (*r*/*g*/*b* all in the 0–255 range or in hexadecimal *#rrggbb*),
  682. HSV color (*hue*-*saturation*-*value* in the 0–360, 0–1, 0–1 range),
  683. CMYK color (*cyan*/*magenta*/*yellow*/*black*, each ranging from
  684. 0–100%), or a valid color *name*; in that respect it is similar to
  685. specifying the pen color settings (see pen color discussion under
  686. Section `Specifying pen attributes`_).
  687. **-GP**\|\ **p**\ *pattern*\ [**+b**\ *color*][**+f**\ *color*][**+r**\ *dpi*]
  688. The second form allows us to use a predefined bit-image pattern.
  689. *pattern* can either be a number in the range 1–90 or the name of a
  690. 1-, 8-, or 24-bit image raster file. The former will result in one of
  691. the 90 predefined 64 x 64 bit-patterns provided with GMT and
  692. reproduced in Chapter :doc:`predefined-patterns`.
  693. The latter allows the user to create
  694. customized, repeating images using image raster files.
  695. The optional **+r**\ *dpi* modifier sets the resolution of this image on the page;
  696. the area fill is thus made up of a series of these "tiles". The
  697. default resolution is 1200. By specifying upper case **-GP**
  698. instead of **-Gp** the image will be bit-reversed, i.e., white and
  699. black areas will be interchanged (only applies to 1-bit images or
  700. predefined bit-image patterns). For these patterns and other 1-bit
  701. images one may specify alternative background and foreground colors
  702. (by appending **+b**\ *color* and/or **+f**\ *color*) that will replace
  703. the default white and black pixels, respectively. Excluding *color* from
  704. a fore- or background specification yields a *transparent* image where
  705. only the back- *or* foreground pixels will be painted.
  706. Due to PostScript implementation limitations the raster images used
  707. with **-G** must be less than 146 x 146 pixels in size; for larger
  708. images see :doc:`/image`. The format of Sun raster files [18]_ is
  709. outlined in Chapter :doc:`file-formats`. However, if you built GMT
  710. with GDAL then other image formats can be used as well. Note that under
  711. PostScript Level 1 the patterns are filled by using the polygon as a
  712. *clip path*. Complex clip paths may require more memory than the
  713. PostScript interpreter has been assigned. There is therefore the
  714. possibility that some PostScript interpreters (especially those
  715. supplied with older laserwriters) will run out of memory and abort.
  716. Should that occur we recommend that you use a regular gray-shade fill
  717. instead of the patterns. Installing more memory in your printer *may or
  718. may not* solve the problem!
  719. Table :ref:`fillex <tbl-fillex>` contains a few examples of fill specifications.
  720. .. _tbl-fillex:
  721. +-------------------------------------------------+-----------------------------------------------------+
  722. +=================================================+=====================================================+
  723. | **-G**\ 128 | Solid gray |
  724. +-------------------------------------------------+-----------------------------------------------------+
  725. | **-G**\ 127/255/0 | Chartreuse, R/G/B-style |
  726. +-------------------------------------------------+-----------------------------------------------------+
  727. | **-G**\ #00ff00 | Green, hexadecimal RGB code |
  728. +-------------------------------------------------+-----------------------------------------------------+
  729. | **-G**\ 25-0.86-0.82 | Chocolate, h-s-v-style |
  730. +-------------------------------------------------+-----------------------------------------------------+
  731. | **-G**\ DarkOliveGreen1 | One of the named colors |
  732. +-------------------------------------------------+-----------------------------------------------------+
  733. | **-Gp**\ 7\ **+r**\ 300 | Simple diagonal hachure pattern in b/w at 300 dpi |
  734. +-------------------------------------------------+-----------------------------------------------------+
  735. | **-Gp**\ 7\ **+b**\ red\ **+r**\ 300 | Same, but with red lines on white |
  736. +-------------------------------------------------+-----------------------------------------------------+
  737. | **-Gp**\ 7\ **+b**\ red\ **+f**\ -\ **+r**\ 300 | Now the gaps between red lines are transparent |
  738. +-------------------------------------------------+-----------------------------------------------------+
  739. | **-Gp**\ marble.ras\ **+r**\ 100 | Using user image of marble as the fill at 100 dpi |
  740. +-------------------------------------------------+-----------------------------------------------------+
  741. Specifying Fonts
  742. ----------------
  743. The fonts used by GMT are typically set indirectly via the
  744. GMT defaults parameters. However, some programs, like
  745. :doc:`/text` may wish to have this
  746. information passed directly. A font is specified by a comma-delimited
  747. attribute list of *size*, *fonttype* and *fill*, each of which is
  748. optional. The *size* is the font size (usually in points) but **c**,
  749. **i** or **p** can be added to indicate a specific unit. The *fonttype*
  750. is the name (case sensitive!) of the font or its equivalent numerical ID
  751. (e.g., Helvetica-Bold or 1). The *fill* specifies the gray shade, color or
  752. pattern of the text (see section `Specifying area fill attributes`_ above).
  753. Optionally, you may append **=**\ *pen* to the *fill* value in order to draw a text
  754. outline. If you want to avoid that the outline partially obscures the text,
  755. append **=~**\ *pen* instead; in that case only half the linewidth is plotted
  756. on the outside of the font only. If an outline is requested, you may optionally
  757. skip the text *fill* by setting it to **-**, in which case the full pen width
  758. is always used. If any of the font attributes is omitted their default or
  759. previous setting will be retained. See Chapter :doc:`postscript-fonts`
  760. for a list of all fonts recognized by GMT.
  761. Stroke, Fill and Font Transparency
  762. ----------------------------------
  763. The PostScript language has no built-in mechanism for transparency.
  764. However, PostScript extensions make it possible to request
  765. transparency, and tools that can render such extensions will produce
  766. transparency effects. We specify transparency in percent: 0 is opaque
  767. [Default] while 100 is fully transparent (i.e., the feature will be invisible). As
  768. noted in section :ref:`option_-t`, we can control transparency on a
  769. layer-by-layer basis using the **-t** option. However, we may also set
  770. transparency as an attribute of stroke or fill (including for fonts)
  771. settings. Here, transparency is requested by appending @\ *transparency*
  772. to colors or pattern fills. The transparency *mode* can be changed by
  773. using the GMT default parameter :term:`PS_TRANSPARENCY`; the default is
  774. Normal but you can choose among Color, ColorBurn, ColorDodge, Darken,
  775. Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply,
  776. Normal, Overlay, Saturation, SoftLight, and Screen. For more
  777. information, see for instance (search online for) the Adobe pdfmark
  778. Reference Manual. Most printers and many PostScript viewers can
  779. neither print nor show transparency. They will simply ignore your
  780. attempt to create transparency and will plot any material as opaque.
  781. Ghostscript and its derivatives such as GMT's
  782. :doc:`/psconvert` support transparency (if
  783. compiled with the correct build option). **Note**: If you use **Acrobat
  784. Distiller** to create a PDF file you must first change some settings to
  785. make transparency effective: change the parameter /AllowTransparency to
  786. true in your \*.joboptions file.
  787. Placement of text
  788. -----------------
  789. Many text labels placed on maps are part of the standard basemap
  790. machinery (e.g., annotations, axis labels, plot titles) and GMT
  791. automatically takes care of where these are placed and how they
  792. are justified. However, when you wish to add extra text to a plot
  793. in locations of your choice you will need to understand how we
  794. reference text to locations on the map. Figure :ref:`Text justification <Text_justify>`
  795. discusses the various ways to do this.
  796. .. _Text_justify:
  797. .. figure:: /_images/GMT_pstext_justify.*
  798. :width: 400 px
  799. :align: center
  800. Text strings are placed on maps by associating an *anchor* point on
  801. the string with a *reference* point on the map. Nine anchor points
  802. relative to any text string may be specified by combining any of
  803. three letter codes for horizontal (**L**\ eft, **C**\ enter, **R**\ ight)
  804. and vertical (**T**\ op, **M**\ iddle, **B**\ ottom) alignments.
  805. Notice how the anchor points refers to the text baseline and do not change
  806. for text whose letters extend below the baseline.
  807. The concept of anchor points extends to entire text paragraphs that you
  808. may want to typeset with :doc:`/text`.
  809. A related point involves the
  810. footprint of the text and any background panel on the map. We determine
  811. the bounding box for any text string, but very often we wish to extend this
  812. box outwards to allow for some *clearance* between the text and the space
  813. surrounding it. Programs that allows for such clearance will let you
  814. specify offsets *dx* and *dy* that is used to enlarge the bounding box,
  815. as illustrated in Figure :ref:`Text clearance <Text_clearance>`.
  816. .. _Text_clearance:
  817. .. figure:: /_images/GMT_pstext_clearance.*
  818. :width: 300 px
  819. :align: center
  820. The bounding box of any text string can be enlarged by specifying the
  821. adjustments *dx* and *dy* in the horizontal and vertical dimension. The shape of the
  822. bounding box can be modified as well, including rounded or convex
  823. rectangles. Here we have chosen a rounded rectangle, requiring the
  824. additional specification of a corner radius, *r*.
  825. .. _CPT_section:
  826. Color palette tables
  827. --------------------
  828. Several programs need to relate user data to colors, shades, or even patterns.
  829. For instance, programs that read 2-D gridded data sets and
  830. create colored images or shaded reliefs need to be told what colors to
  831. use and over what *z*-range each color applies. Other programs may need
  832. to associate a user value with a color to be applied to a symbol, line,
  833. or polygon. This is the purpose of the color palette table (CPT). For
  834. most applications, you will simply create a CPT using the tool
  835. :doc:`/makecpt` which will take an existing *dynamic* master
  836. color table and stretch it to fit your chosen data range, or use
  837. :doc:`/grd2cpt` to build a CPT based on
  838. the data distribution in one or more given grid files. However, in rare
  839. situations you may need to make a CPT by hand or using text tools
  840. like **awk** or **perl**. Finally, if you have your own preferred color
  841. table you can convert it into a dynamic CPT and place it in your GMT
  842. user directory and it will be found and behave like other GMT master CPTs.
  843. Color palette tables (CPT) comes in two flavors: (1) Those designed to
  844. work with categorical data (e.g., data where interpolation of values is
  845. undefined) and (2) those designed for regular, continuously-varying
  846. data. In both cases the *fill* information follows the format given in
  847. Section `Specifying area fill attributes`_. The z-values in CPTs can
  848. be scaled by using the **+u**\|\ **U**\ *unit* mechanism. Append these
  849. modifiers to your CPT names when used in GMT commands. The **+u**\ *unit*
  850. modifier will scale z *from unit to* meters, while **+U**\ *unit* does
  851. the inverse (scale z *from meters to unit*).
  852. Since GMT supports several coordinate systems for color specification,
  853. many master (or user) CPTs will contain the special comment
  854. | ``# COLOR_MODEL = model``
  855. where *model* specifies how the color-values in the CPT should be interpreted.
  856. By default we assume colors are given as red/green/blue triplets (each in the
  857. 0-255 range) separated by
  858. slashes (model = *rgb*), but alternative representations are the HSV system
  859. of specifying hue-saturation-value triplets (with hue in 0-360 range and
  860. saturation and value ranging from 0-1) separated by hyphens (model = *hsv*),
  861. or the CMYK system of specifying cyan/magenta/yellow/black quadruples in percent,
  862. separated by slashes (model = *cmyk*).
  863. Categorical CPTs
  864. ~~~~~~~~~~~~~~~~
  865. Categorical data are information on which normal numerical operations
  866. are not defined. As an example, consider various land classifications
  867. (desert, forest, glacier, etc.) and it is clear that even if we assigned
  868. a numerical value to these categories (e.g., desert = 1, forest = 2,
  869. etc) it would be meaningless to compute average values (what would 1.5
  870. mean?). For such data a special format of the CPTs are provided.
  871. Here, each category is assigned a unique key, a color or pattern, and an
  872. optional label (usually the category name) marked by a leading
  873. semi-colon. Keys must be monotonically increasing but do not need to be
  874. consecutive. The format is
  875. +-----------------+--------+--------------+
  876. | key\ :sub:`1` | *Fill* | [;\ *label*] |
  877. +-----------------+--------+--------------+
  878. | ... | | |
  879. +-----------------+--------+--------------+
  880. | key\ :sub:`n` | *Fill* | [;\ *label*] |
  881. +-----------------+--------+--------------+
  882. For usage with points, lines, and polygons, the keys may be text (single words),
  883. and then GMT will use strings to find the corresponding *Fill* value. Strings
  884. may be supplied as trailing text in data files (for points) or via the **-Z**\ *category*
  885. option in multiple segment headers (or set via **-a**\ *Z*\ =\ *aspatialname*).
  886. If any of your keys are called B, F, or N you must escape them with a leading backslash
  887. to avoid confusion with the flags for background, foreground and NaN colors.
  888. The *Fill* information follows the format given in Section `Specifying area fill attributes`_.
  889. For categorical data, background color or foreground color do not apply. The not-a-number (NaN)
  890. color (for *key*-values not found or blank) is defined in the :doc:`/gmt.conf` file, but it can be
  891. overridden by the statement
  892. +-----+---------------------+
  893. | N | Fill\ :sub:`nan` |
  894. +-----+---------------------+
  895. Regular CPTs
  896. ~~~~~~~~~~~~
  897. Suitable for continuous data types and allowing for color
  898. interpolations, the format of the regular CPTs is:
  899. +---------------+-------------------+---------------+-------------------+----------+--------------+
  900. | z\ :sub:`0` | Color\ :sub:`min` | z\ :sub:`1` | Color\ :sub:`max` | [**A**] | [;\ *label*] |
  901. +---------------+-------------------+---------------+-------------------+----------+--------------+
  902. | ... |
  903. +---------------+-------------------+---------------+-------------------+----------+--------------+
  904. | z\ :sub:`n-2` | Color\ :sub:`min` | z\ :sub:`n-1` | Color\ :sub:`max` | [**A**] | [;\ *label*] |
  905. +---------------+-------------------+---------------+-------------------+----------+--------------+
  906. Thus, for each "*z*-slice", defined as the interval between two
  907. boundaries (e.g., :math:`z_0` to :math:`z_1`), the color can be
  908. constant (by letting Color\ :math:`_{max}` = Color\ :math:`_{min}` or -)
  909. or a continuous, linear function of *z*. If patterns are used then the
  910. second (max) pattern must be set to -. The optional flag **A** is used
  911. to indicate annotation of the color scale when plotted using
  912. :doc:`/colorbar`. The optional flag **A** may
  913. be **L**, **U**, or **B** to select annotation of the lower, upper, or
  914. both limits of the particular *z*-slice, respectively. However,
  915. the standard **-B** option can be used by
  916. :doc:`/colorbar` to affect annotation and
  917. ticking of color scales. Just as other GMT programs, the *stride* can
  918. be omitted to determine the annotation and tick interval automatically
  919. (e.g., **-Baf**). The optional semicolon followed by a text label will
  920. make :doc:`/colorbar`, when used with the
  921. **-L** option, place the supplied label instead of formatted *z*-values.
  922. The background color (for *z*-values < :math:`z_0`), foreground color (for *z*-values >
  923. :math:`z_{n-1}`), and not-a-number (NaN) color (for *z*-values =
  924. NaN) are all defined in the :doc:`/gmt.conf` file, but can be overridden by the
  925. statements
  926. +-----+---------------------+
  927. | B | Fill\ :sub:`back` |
  928. +-----+---------------------+
  929. | F | Fill\ :sub:`fore` |
  930. +-----+---------------------+
  931. | N | Fill\ :sub:`nan` |
  932. +-----+---------------------+
  933. which can be inserted into the beginning or end of the CPT. If you
  934. prefer the HSV system, set the :doc:`/gmt.conf` parameter accordingly and replace red,
  935. green, blue with hue, saturation, value. Color palette tables that
  936. contain gray-shades only may replace the *r/g/b* triplets with a single
  937. gray-shade in the 0–255 range. For CMYK, give *c/m/y/k* values in the
  938. 0–100 range.
  939. A few programs (i.e., those that plot polygons such as
  940. :doc:`/grdview`, :doc:`/colorbar`,
  941. :doc:`/plot` and
  942. :doc:`/plot3d`) can accept pattern fills instead
  943. of gray-shades. You must specify the pattern as in Section `Specifying area fill attributes`_
  944. (no leading **-G** of course), and only the first pattern (for low
  945. *z*) is used (we cannot interpolate between patterns). Finally,
  946. some programs let you skip features whose *z*-slice in the CPT
  947. file has gray-shades set to -. As an example, consider
  948. +-----+----------+------+-----------+
  949. | 30 | p16+r200 | 80 | \- |
  950. +-----+----------+------+-----------+
  951. | 80 | \- | 100 | \- |
  952. +-----+----------+------+-----------+
  953. | 100 | 200/0/0 | 200 | 255/255/0 |
  954. +-----+----------+------+-----------+
  955. | 200 | yellow | 300 | green |
  956. +-----+----------+------+-----------+
  957. where slice 30 < z < 80 is painted with pattern # 16 at 200 dpi,
  958. slice 80 < z < 100 is skipped, slice 100 < z < 200 is
  959. painted in a range of dark red to yellow, whereas the slice
  960. 200 < z < 300 will linearly yield colors from yellow to green,
  961. depending on the actual value of *z*.
  962. Some programs like :doc:`/grdimage` and
  963. :doc:`/grdview` apply artificial illumination
  964. to achieve shaded relief maps. This is typically done by finding the
  965. directional gradient in the direction of the artificial light source and
  966. scaling the gradients to have approximately a normal distribution on the
  967. interval [-1,+1]. These intensities are used to add "white" or "black"
  968. to the color as defined by the *z*-values and the CPT. An intensity
  969. of zero leaves the color unchanged. Higher values will brighten the
  970. color, lower values will darken it, all without changing the original
  971. hue of the color (see Chapter :doc:`colorspace` for more details). The
  972. illumination is decoupled from the data grid file in that a separate
  973. grid file holding intensities in the [-1,+1] range must be provided.
  974. Such intensity files can be derived from the data grid using
  975. :doc:`/grdgradient` and modified with
  976. :doc:`/grdhisteq`, but could equally well be
  977. a separate data set. E.g., some side-scan sonar systems collect both
  978. bathymetry and backscatter intensities, and one may want to use the
  979. latter information to specify the illumination of the colors defined by
  980. the former. Similarly, one could portray magnetic anomalies superimposed
  981. on topography by using the former for colors and the latter for shading.
  982. Master (dynamic) CPTs
  983. ~~~~~~~~~~~~~~~~~~~~~
  984. The CPTs distributed with GMT are *dynamic*. This means they have several
  985. special properties that modify the behavior of programs that use them.
  986. Dynamic CPTs comes in a few different flavors: Some CPTs were designed
  987. to behave differently across a *hinge* value (e.g., a CPT designed specifically
  988. for topographic relief may include a discontinuity in color across the
  989. coastline at *z = 0*), and when users select these CPTs they will be stretched
  990. to fit the user's desired data range separately for each side of this *hard* hinge.
  991. Basically, a *hard* hinge CPT is the juxtaposition of two different CPTs joined
  992. at the hinge and these sections are stretched independently. Such CPT files
  993. are identified as such via the special comment
  994. | ``# HARD_HINGE``
  995. and all hard hinges occur at data value *z = 0* (but you can change this value by
  996. adding **+h**\ *value* to the name of the CPT).
  997. Other CPTs may instead have a *soft* hinge which indicates a natural hinge or transition
  998. point in the CPT itself, unrelated to any natural data set *per se*. These CPTs
  999. are flagged by the special comment
  1000. | ``# SOFT_HINGE``
  1001. CPTs with soft hinges behave as regular (non-hinge) CPTs *unless* the user activates then by
  1002. appending **+h**\ [*hinge*] to the CPT name. This modifier will convert the soft
  1003. hinge into a hard hinge at the user-specified data value *hinge* [which defaults to 0].
  1004. Note that if your specified data range *excludes* an activated soft or hard hinge then we
  1005. only perform color sampling from the *half* of the CPT that pertains to the data range.
  1006. All dynamic CPTs will need to be stretched to the user's preferred range, and there
  1007. are two modes of such scaling: Some CPTs designed for a specific application
  1008. (again, the topographic relief is a good example) have a *default range*
  1009. specified in the master table via the special comment
  1010. | ``# RANGE = <zmin/zmax>``
  1011. and when used by applications the CPT may be automatically stretched to reflect
  1012. this natural range. In contrast, dynamic CPTs *without* a natural range are instead
  1013. stretched to fit the range of the data in question (e.g., a grid's range).
  1014. Exceptions to these rules are implemented in the two *CPT-producing* modules
  1015. :doc:`/makecpt` and :doc:`/grd2cpt`, both of which can read dynamic CPTs
  1016. and produce *static* CPTs satisfying a user's specific range needs. These
  1017. tools can also read static CPTs for which a new range must be specified (or computed
  1018. from data), reversing the order of colors, and even isolating a section
  1019. of an incoming CPT. Here, :doc:`/makecpt` can be told the data range or compute
  1020. it from data tables while :doc:`/grd2cpt` can derive the range from one or more grids.
  1021. .. figure:: /_images/GMT_hinge.*
  1022. :width: 500 px
  1023. :align: center
  1024. The top color bar is a dynamic master CPT (here, globe) with a hard hinge at sea level and
  1025. a natural range from -10,000 to +10,000 meters. However, our data range
  1026. is asymmetrical, going from -8,000 meter depths up to +3,000 meter elevations.
  1027. Because of the hinge, the two sides of the CPT will be stretched separately
  1028. to honor the desired range while utilizing the full color range.
  1029. All CPT master tables can be found in Chapter :ref:`Of Colors and Color Legends`
  1030. where those with hard or soft hinges are identified by triangles at their hinges.
  1031. CPTs from color lists
  1032. ~~~~~~~~~~~~~~~~~~~~~
  1033. GMT can build color tables "on the fly" from a comma-separated list of colors
  1034. and a range of *z*-values to go with them. As illustrated below, there are
  1035. four different ways to create such CPTs. In this example, we will operate with
  1036. a list of three colors: red,yellow and purple, given to modules with the option **-C**\ red,yellow,purple,
  1037. and utilize a fixed data range of *z = 0-6*.
  1038. Four different CPTs result because we either select a *continuous* or *discrete table*, and because the *z*-intervals are
  1039. either *equidistant* or *arbitrary*. The top continuous color table with equidistant spacing (a) is selected
  1040. with the range **-T**\ 0/6, meaning the colors will continuously change from red (at *z = 0*) via
  1041. yellow (at *z = 3*) to purple (at *z = 6*). Next, a discrete table with the same range (b)
  1042. is obtained with **-T**\ 0/6/2, yielding colors that are either constant red (*z = 0-2*), yellow (*z = 2-4*)
  1043. or purple (*z = 4-6*). The next discrete table (c) illustrates how to specify arbitrary
  1044. node points in the CPT by providing a comma-separated list of values (**-T**\ 0,4,5.5,6). Now, the constant
  1045. color intervals have unequal ranges, illustrated by red (*z = 0-4*), yellow (*z = 4-5.5*) and purple (*z = 5.5-6*). Finally, we
  1046. create a continuous color table (d) with arbitrary nodes by giving **-T**\ 0,2,6 and adding **-Z**;
  1047. the latter option forces a continuous CPT pinned to a given list of node values. Now, the colors
  1048. continuously change from red (at *z = 0*) via yellow (at *z = 2*) to purple (at *z = 6*).
  1049. Modules that obtain the *z*-range indirectly (e.g., :doc:`/grdimage`) may use the exact data range
  1050. to set the quivalent of a **-T**\ *min/max* option. You may append **+i**\ *dz* to the
  1051. color list to have the *min* and *max* values rounded down and up to nearest multiple of *dz*, respectively.
  1052. .. figure:: /_images/GMT_colorlist.*
  1053. :width: 500 px
  1054. :align: center
  1055. Lists of colors (here red,yellow,purple) can be turned into discrete or continuous CPT tables on the fly.
  1056. Cyclic (wrapped) CPTs
  1057. ~~~~~~~~~~~~~~~~~~~~~
  1058. Any color table you produce can be turned into a cyclic or *wrapped* color table.
  1059. This is performed by adding the **-Ww** option when running :doc:`/makecpt` or
  1060. :doc:`/grd2cpt`. This option simply adds the special comment
  1061. | ``# CYCLIC``
  1062. to the color table and then GMT knows that when looking up a color from a *z*
  1063. value it will remove an integer multiple of the *z*-range represented by the
  1064. color table so that we are always inside the range of the color table. This
  1065. means that the fore- and back-ground colors can never be activated. Wrapped
  1066. color tables are useful for highlighting small changes.
  1067. .. figure:: /_images/GMT_cyclic.*
  1068. :width: 500 px
  1069. :align: center
  1070. Cyclic color bars are indicated by a cycle symbol on the left side of the bar.
  1071. .. _manipulating_CPTs:
  1072. Manipulating CPTs
  1073. ~~~~~~~~~~~~~~~~~
  1074. There are many ways to turn a master CPT into a custom CPT that works for your
  1075. particular data range. The tools :doc:`/makecpt` and :doc:`/grd2cpt` allow
  1076. several types of transformations to take place:
  1077. #. You can reverse the *z*-direction of the CPT using option **-Iz**.
  1078. This is useful when your data use a different convention for
  1079. positive and negative (e.g., perhaps using positive depths instead of
  1080. negative relief).
  1081. #. You can invert the order of the colors in the CPT using option **-Ic**.
  1082. This is different from the previous option in that only the colors
  1083. are rearranged (it is also possible to issue **-Icz** to combine both effects.)
  1084. #. You can select just a subset of a master CPT with **-G**, in effect creating
  1085. a modified master CPT that can be scaled further.
  1086. #. Finally, you can scale and translate the (modified) master CPT range to
  1087. your actual data range or a sub-range thereof.
  1088. The order of these transformations is important. For instance, if **-Iz** is given
  1089. then all other *z*-values need to be referred to the new sign convention. For most
  1090. applications only the last transformation is needed.
  1091. .. figure:: /_images/GMT_CPTscale.*
  1092. :width: 500 px
  1093. :align: center
  1094. Examples of two user CPTs for the range -0.5 to 3 created from the same master. One (left) extracted a
  1095. subset of the master before scaling while the other (right) used the entire range.
  1096. Automatic CPTs
  1097. ~~~~~~~~~~~~~~
  1098. A few modules (:doc:`/grdimage`, :doc:`/grdview`) that expects a CPT option will
  1099. provide a default CPT if none is provided. By default, the default CPT is the
  1100. "turbo" color table, but this is overridden if the user uses the @eart_relief
  1101. (we select "geo") or @srtm_relief (we select "srtm") data sets. After selection,
  1102. these CPTs are read and scaled to match the range of the grid values. You may append
  1103. **+i**\ *dz* to the CPT to have the exact range rounded to nearest multiple of *dz*.
  1104. This is helpful if you plan to place a colorbar and prefer start and stop *z*-values
  1105. that are multiples of *dz*.
  1106. The Drawing of Vectors
  1107. ----------------------
  1108. GMT supports plotting vectors in various forms. A vector is one of
  1109. many symbols that may be plotted by :doc:`/plot`
  1110. and :doc:`/plot3d`, is the main feature in
  1111. :doc:`/grdvector`, and is indirectly used by
  1112. other programs. All vectors plotted by GMT consist of two separate
  1113. parts: The vector line (controlled by the chosen pen attributes) and the
  1114. optional vector head(s) (controlled by the chosen fill). We distinguish
  1115. between three types of vectors:
  1116. #. Cartesian vectors are plotted as straight lines. They can be
  1117. specified by a start point and the direction and length (in map
  1118. units) of the vector, or by its beginning and end point. They may
  1119. also be specified giving the azimuth and length (in km) instead.
  1120. #. Circular vectors are (as the name implies) drawn as circular arcs and
  1121. can be used to indicate opening angles. It accepts an origin, a
  1122. radius, and the beginning and end angles.
  1123. #. Geo-vectors are drawn using great circle arcs. They are specified by
  1124. a beginning point and the azimuth and length (in km) of the vector,
  1125. or by its beginning and end point.
  1126. .. figure:: /_images/GMT_arrows.*
  1127. :width: 500 px
  1128. :align: center
  1129. Examples of Cartesian (left), circular (middle), and geo-vectors (right)
  1130. for different attribute specifications. Note that both full and half
  1131. arrow-heads can be specified, as well as no head at all.
  1132. There are numerous attributes you can modify, including how the vector
  1133. should be justified relative to the given point (beginning, center, or
  1134. end), where heads (if any) should be placed, if the head should just be
  1135. the left or right half, if the vector attributes should shrink for
  1136. vectors whose length are less than a given cutoff length, and the size
  1137. and shape of the head. These attributes are detailed further in the
  1138. relevant manual pages.
  1139. .. figure:: /_images/GMT_arrows_types.*
  1140. :width: 500 px
  1141. :align: center
  1142. Examples of different vector heads and attributes. The default is the standard
  1143. triangular arrow head, which can be modified by adjusting the apex angle [30] or
  1144. changing its shape via the :term:`MAP_VECTOR_SHAPE` setting.
  1145. Other vector heads are the circle (**c**), the terminal line (**t**), the
  1146. arrow fin (**i**) and the plain head (**A**) and tail (**I**); the last two
  1147. are line-drawings only and cannot be filled.
  1148. .. _Char-esc-seq:
  1149. Character escape sequences
  1150. --------------------------
  1151. For annotation labels or text strings plotted with
  1152. :doc:`/text`, GMT provides several escape
  1153. sequences that allow the user to temporarily switch to the symbol font,
  1154. turn on sub- or superscript, etc., within words. These conditions are
  1155. toggled on/off by the escape sequence @\ **x**, where **x** can be one
  1156. of several types. The escape sequences recognized in GMT are listed in
  1157. Table :ref:`escape <tbl-escape>`. Only one level of sub- or superscript is supported.
  1158. Note that under Windows the percent symbol indicates a batch variable,
  1159. hence you must use two percent-signs for each one required in the escape
  1160. sequence for font switching.
  1161. .. _tbl-escape:
  1162. +-------------------+----------------------------------------------------------------+
  1163. +===================+================================================================+
  1164. | @~ | Turns symbol font on or off |
  1165. +-------------------+----------------------------------------------------------------+
  1166. | @+ | Turns superscript on or off |
  1167. +-------------------+----------------------------------------------------------------+
  1168. | @- | Turns subscript on or off |
  1169. +-------------------+----------------------------------------------------------------+
  1170. | @# | Turns small caps on or off |
  1171. +-------------------+----------------------------------------------------------------+
  1172. | @\_ | Turns underline on or off |
  1173. +-------------------+----------------------------------------------------------------+
  1174. | @%\ *fontno*\ % | Switches to another font; @%% resets to previous font |
  1175. +-------------------+----------------------------------------------------------------+
  1176. | @:\ *size*: | Switches to another font size; @:: resets to previous size |
  1177. +-------------------+----------------------------------------------------------------+
  1178. | @;\ *color*; | Switches to another font color; @;; resets to previous color |
  1179. +-------------------+----------------------------------------------------------------+
  1180. | @! | Creates one composite character of the next two characters |
  1181. +-------------------+----------------------------------------------------------------+
  1182. | @. | Prints the degree symbol |
  1183. +-------------------+----------------------------------------------------------------+
  1184. | @@ | Prints the @ sign itself |
  1185. +-------------------+----------------------------------------------------------------+
  1186. Shorthand notation for a few special European characters has also been added (for others
  1187. you must use the full octal code):
  1188. .. _tbl-shorthand:
  1189. +----------+------------+----------+------------+
  1190. | *Code* | *Effect* | *Code* | *Effect* |
  1191. +==========+============+==========+============+
  1192. | @E | Æ | @e | æ |
  1193. +----------+------------+----------+------------+
  1194. | @O | Ø | @o | ø |
  1195. +----------+------------+----------+------------+
  1196. | @A | Å | @a | å |
  1197. +----------+------------+----------+------------+
  1198. | @C | Ç | @c | ç |
  1199. +----------+------------+----------+------------+
  1200. | @N | Ñ | @n | ñ |
  1201. +----------+------------+----------+------------+
  1202. | @U | Ü | @u | ü |
  1203. +----------+------------+----------+------------+
  1204. | @s | ß | @i | í |
  1205. +----------+------------+----------+------------+
  1206. However, if your input text contains UTF-8 code characters (e.g., ü, Î)
  1207. and you select the ISOLatin1+ character encoding then GMT will substitute
  1208. the correct PostScript octal codes for you automatically.
  1209. PostScript fonts used in GMT may be re-encoded to include several
  1210. accented characters used in many European languages. To access these,
  1211. you must specify the full octal code \\xxx allowed for
  1212. your choice of character encodings determined by the
  1213. :term:`PS_CHAR_ENCODING` setting described in the
  1214. :doc:`/gmt.conf` man page. Only the special
  1215. characters belonging to a particular encoding will be available. Many
  1216. characters not directly available by using single octal codes may be
  1217. constructed with the composite character mechanism @!.
  1218. Some examples of escape sequences and embedded octal codes in
  1219. GMT strings using the Standard+ encoding:
  1220. | ``2@~p@~r@+2@+h@-0@- E\363tv\363s`` = 2\ :math:`\pi r^2h_0` Eötvös
  1221. | ``10@+-3 @Angstr@om`` = 10\ :math:`^{-3}` Ångstrøm
  1222. | ``Stresses are @~s@~@+*@+@-xx@- MPa`` = Stresses are :math:`\sigma^{*}_{xx}` MPa
  1223. | ``Se@nor Gar@con`` = Señor Garçon
  1224. | ``M@!\305anoa stra@se`` = Manoa straße
  1225. | ``A@\#cceleration@\# (ms@+-2@+)`` = ACCELERATION
  1226. The option in :doc:`/text` to draw a
  1227. rectangle surrounding the text will not work for strings with escape
  1228. sequences. A chart of characters and their octal codes is given in
  1229. Chapter :doc:`octal-codes`.
  1230. .. _GMT_Embellishments:
  1231. Plot embellishments
  1232. -------------------
  1233. Apart from visualizing your data sets, GMT maps can also be embellished in several ways.
  1234. The 9 embellishments currently available are
  1235. * **Map scale** showing the true scale at some location(s) on the map.
  1236. * **Directional rose** showing true north and other cardinal directions.
  1237. * **Magnetic rose** showing magnetic north and declination deviations.
  1238. * **Color bar** relating the colors of your image to the data values.
  1239. * **Map legend** showing the meaning of the symbols on your map.
  1240. * **Image overlay** of raster images or EPS figures (e.g., institutional logos, photos, etc.).
  1241. * **GMT logo** overlay.
  1242. * **Map inset** showing perhaps the location of your detailed area in a regional or global context.
  1243. * **Vertical scale** showing the vertical scale of anomalies on a map.
  1244. Each of these features share a common system for specifying the location on the plot where the
  1245. feature will be placed. They also share a common way for specifying the placement of a rectangular
  1246. panel behind the feature (to provide a uniform background, for instance). Thus, before we discuss
  1247. the different features in more detail we will first review the "reference point/anchor point"
  1248. system used by GMT to specify such locations in relation to the underlying map, and then discuss
  1249. the background panel attribute settings.
  1250. Reference and anchor point specification
  1251. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1252. .. figure:: /_images/GMT_anchor.*
  1253. :width: 500 px
  1254. :align: center
  1255. The placement of a map feature (here represented by a green rectangle) in relation
  1256. to the underlying map. The nine named *reference* points (blue circles) on the map perimeter (and center)
  1257. can be used to specify a location. Using the same system of nine points on the map feature
  1258. (cyan circles) we select one of these as our *anchor* point (here TL, indicated by the orange square).
  1259. The anchor point can optionally be shifted away from the reference point by an amount *dx/dy* in the direction
  1260. implied by the anchor point (in this case to the top and left), yielding the adjusted
  1261. anchor point (red square).
  1262. The feature is then placed such that its adjusted anchor point matches the reference point.
  1263. Placing a feature on the map means selecting a *reference* point somewhere on the map, an
  1264. *anchor* point somewhere on the feature, and then positioning the feature so that the two points overlap.
  1265. It may be helpful to consider the analog of a boat dropping an anchor: The boat navigates to the
  1266. reference point and then, depending on where on the boat the anchor is located, moves so that the
  1267. anchor connection point overlies the reference point, then drops the anchor.
  1268. There are four different ways to specify the reference point on a map, allowing for complete freedom
  1269. to select any location inside or outside the map. The reference point syntax is [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*;
  1270. the five codes **g**\|\ **j**\|\ **J**\|\ **n**\|\ **x** refer to the five ways:
  1271. #. [**g**] Specify *refpoint* using *data* coordinates, e.g., the longitude and latitude of the reference point.
  1272. This mechanism is useful when you want to tie the location of the feature to an actual point
  1273. best described by data coordinates. An example of such a reference point might
  1274. be **g**\ 135W/20N.
  1275. #. [**j**] Specify *refpoint* using one of the nine *justification codes*, equivalent to the justification
  1276. codes for placing text strings in :doc:`/text`. This mechanism is illustrated in the figure above and
  1277. is the preferred mechanism when you just want to place the feature **inside** the basemap at
  1278. one of the corners or centered at one of the sides (or even smack in the middle). Justification codes
  1279. are a combination of a horizontal (**L**, **C**, **R**) and a vertical (**T**, **M**, **B**) code.
  1280. An example of such a reference point might be **jTL**\ . When used, the anchor point on the map feature
  1281. will default to the same justification, i.e., **TL** in this example.
  1282. #. [**J**] This is the same as **j** except it implies that the default anchor point is the mirror opposite of the
  1283. justification code. Thus, when using **JTL**\, the anchor point on the map feature will default to **BR**.
  1284. This is practical for features that are drawn **outside** of the basemap (like color bars often are).
  1285. #. [**x**] Specify *refpoint* using *plot* coordinates, i.e., the distances in inches, centimeters, or
  1286. points from the lower left plot origin. This mechanism is preferred when you wish to lay out
  1287. map features using familiar measurements of distance from origins. An example of such a reference
  1288. point might be **x**\ 2.75i/2c.
  1289. #. [**n**] Specify *refpoint* using *normalized* coordinates, i.e., fractional coordinates between 0
  1290. and 1 in both the *x* and *y* directions. This mechanism avoids units and is useful if you want to always
  1291. place features at locations best referenced as fractions of the plot dimensions.
  1292. An example of such a reference point might be **n**\ 0.2/0.1.
  1293. If no code is specified we default to **x**.
  1294. With the reference point taken care of, it is time to select the anchor point.
  1295. While the reference point selection gives unlimited flexibility to pick
  1296. any point inside or outside the map region, the anchor point selection is limited to the nine justification points
  1297. discussed for the **j** reference point code above. Add **+j**\ *anchor* to indicate which justification
  1298. point of the map feature should be co-registered with the chosen reference point. If an anchor point is not
  1299. specified then it defaults to the justification point set for the reference point (if **j**\ *code* was
  1300. used to set it), or to the mirror opposite of the reference point (if **J**\ *code* was used); with all other
  1301. specifications of the reference point, the anchor point takes on the default value of **MC** (for map rose and
  1302. map scale) or **BL** (all other map features). Adding **+j**\ *anchor* overrules those defaults.
  1303. For instance, **+jTR**\ would select the top right point on the map feature as the anchor.
  1304. It is likely that you will wish to offset the anchor point away from
  1305. your selection by some arbitrary amount, particularly if the reference point is specified with **j**\|\ **J**\ *code*.
  1306. Do so with **+o**\ *dx*\ [/*dy*], where *dy* equals *dx* if it is not provided.
  1307. These increments are added to the projected plot coordinates of the anchor point, with
  1308. positive values moving the reference point in the same direction as the 2-character code of the anchor point implies.
  1309. Finally, the adjusted anchor point is matched with the reference point.
  1310. Take for example an anchor point on the top left of the map feature, either by using a reference point **jTL**\ , or **JBR**\ ,
  1311. or explicitly setting **+j**\ TL.
  1312. Then **+o**\ 2c/1c will move the anchor point 2 cm left and 1 cm above the top left corner of the map feature.
  1313. In other words, the top left corner of the map feature will end up 2 cm to the right and 1 cm below the selected reference point.
  1314. Similarly, **+jBR** will align the bottom right corner of the map feature, and **+o**\ 2c/1c will offset it 2 cm to the left
  1315. and 1 cm up. When using middle (**M**) or center (**C**) justifications, to offset works the same way as bottom (**B**) or left (**L**),
  1316. respectively, i.e., moving the map feature up or to the right.
  1317. The background panel
  1318. ~~~~~~~~~~~~~~~~~~~~
  1319. For most maps you will wish to place a background panel of uniform color behind
  1320. any of the map features you plan to add. Because the panel is linked to the map feature
  1321. you have selected, the parameters such as location and dimensions are handled automatically.
  1322. What remains is to specify the *attributes* of the panel. Typically, panels settings are
  1323. given via a module's **-F** option by appending one or more modifiers. Here is a list of
  1324. the attributes that are under your control:
  1325. #. Color or pattern. You specify the fill you want with **+g**\ *fill* [Default is no fill].
  1326. For instance, paint the panel yellow with **+g**\ yellow.
  1327. #. Panel frame pen. Turn on the frame outline with **+p**, using the pen defined via
  1328. :term:`MAP_FRAME_PEN`. You may override this choice with **+p**\ *pen*
  1329. [Default is no outline]. A very bold red outline might look like **+p**\ thick,red.
  1330. #. Rounded versus straight rectangle. By specifying a corner radius with **+r**\ *radius*
  1331. you can round the corners [Default is no rounding]. Here is a 0.5-cm radius rounding:
  1332. **+r**\ 0.5c.
  1333. #. Inner frame. A secondary, inner frame outline may be added as well with the modifier
  1334. **+i**\ [[*gap*/]\ *pen*]. The default pen is given by :term:`MAP_DEFAULT_PEN`,
  1335. with a default *gap* between the outer and inner frames of 2 points. Add arguments to override
  1336. these defaults, such as **+i**\ 0.1c/thin,dashed to get a thin, dashed inner frame offset by
  1337. 0.1 cm from the main (outer) frame.
  1338. #. Panel clearance. The panel's dimensions are automatically determined from knowledge of
  1339. its contents. However, it is sometimes required to add some extra clearance around most or
  1340. all sides, and you can do so with **+c**\ [*clearance*], with a 4-point clearance being
  1341. the default. Add one (uniform), two (different horizontal and vertical clearances), or
  1342. four (separate for sides west, east, south, and north) clearances, separated by slashes. For instance, to add
  1343. a 1 cm clearance in x and 5 points in y, use **+c**\ 1c/5p.
  1344. #. Drop-down shadow. Append **+s** to simulate a gray shadow cast toward the southeast.
  1345. You may append [*dx*/*dy*/][*shade*] to change the shade color and the offset of the
  1346. shade [Default is 4p/-4p/gray50]. If happy with the placement but desiring a dark blue
  1347. shadow, add **+s**\ darkblue.
  1348. .. figure:: /_images/GMT_panel.*
  1349. :width: 400 px
  1350. :align: center
  1351. A map panel is a rectangular background placed behind any of the map features. It has
  1352. several attributes that can be changed with panel option modifiers. The light green rounded
  1353. rectangle was specified with **-F+g**\ lightgreen\ **+r**, while the white panel on the
  1354. lower right was set with **-F+p**\ 1p\ **+i+s+g**\ white\ **+c**\ 0.1i (we added a light
  1355. dashed box to indicate the effect of the clearance setting).
  1356. Placing map scales
  1357. ~~~~~~~~~~~~~~~~~~
  1358. Traditionally, a map scale is added to maps for helping the reader understand the particular scale
  1359. used for this map, i.e., it portrays the relationship between actual distances on the Earth
  1360. (in km, miles, meters, etc.) and distances on the map (in cm, inches, points). Depending on
  1361. the map projection the map scale will vary continuously but may be constant along a line of
  1362. latitude (e.g., Mercator projection). Thus, in placing the map scale on the map there are
  1363. two locations involved: (1) The *reference* point where the map scale's *anchor* should be
  1364. pinned, and (2) the *projection* point where the scale is computed and thus where the map
  1365. scale is true. Map scales can be plotted by :doc:`/basemap` or :doc:`/coast`, and in
  1366. addition to the the required *refpoint* and anchor arguments specifying where the scale should be placed there
  1367. are both required and optional modifiers. These are given via these modules' **-L** option.
  1368. Here is a list of the attributes that is under your control:
  1369. #. Scale bar length. Required modifier is given with **+w**\ *length*, where
  1370. *unit* is one of the recognized distance units. An example might be **+w**\ 250n for
  1371. a bar representing 250 nautical miles at the map scale origin.
  1372. #. Map scale origin. Required modifier given with **+c**\ [*slon*/]\ *slat*, where the longitude
  1373. of the scale origin is optional for projections with constant scale along parallels. For
  1374. a Mercator projection it may look like **+c**\ 30N while an oblique projection may need **+c**\ 100W/23N,
  1375. for instance.
  1376. #. Fancy scale bar. By default a plain-looking scale bar is plotted. For a free upgrade to a fancier bar,
  1377. append **+f**. The fancier bar is, well, a bit fancier.
  1378. #. Scale label. Turn on scale labels with **+l**. By default, the scale label is initialized to
  1379. equal the distance unit name. Use the **+l**\ *label* argument to supply your own scale label,
  1380. such as **+l**\ "Distances at Equator".
  1381. #. Scale label alignment. The default alignment is on top of the bar [**+at**], but you can change
  1382. this by selecting another alignment by appending them to the **+a** modifier, including
  1383. **b**\ ottom, **l**\ eft, or **r**\ ight. Here, **+ab** would align on the bottom of the scale.
  1384. #. Append distance unit. For the fancy scale, adding **+u** will append the distance unit specified
  1385. with **+w** to all distance annotations along the bar, while for the plain scale it will replace
  1386. the default scale label with the unit abbreviation.
  1387. .. figure:: /_images/GMT_mapscale.*
  1388. :width: 500 px
  1389. :align: center
  1390. Example of two map scales for a Mercator projection evaluated at 53 degrees north.
  1391. The left-most scale was placed with **-Lj**\ *ML*\ **+c**\ 53\ **+w**\ 1000k\ **+f+l**\ "Scale at 53\\232N"
  1392. while the scale on the right was placed with **-Lj**\ *BR*\ **+c**\ 53\ **+w**\ 1000k\ **+l+f**.
  1393. Note that for the purpose of anchor justification (**+j**) the footprint of the map scale is
  1394. considered the rectangle that contains the scale and all selected labels and annotations, i.e.,
  1395. the map scale's *bounding box*.
  1396. .. _Placing-dir-map-roses:
  1397. Placing directional map roses
  1398. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1399. Map roses showing the cardinal directions of a map help the reader orient themselves, especially
  1400. for oblique projections where north-south is not vertically aligned. However, these roses also
  1401. have ornamental value and can be used on any map projection. As for map scales, a directional
  1402. map rose is added with :doc:`/basemap` or :doc:`/coast` and selected by the **-Td** option.
  1403. This option accepts the *reference* point where the map rose's *anchor* should be
  1404. pinned. In addition to the required *refpoint* and *anchor* arguments (and their standard
  1405. modifiers discussed earlier) there is one required and two optional modifiers. The required
  1406. modifier sets the side:
  1407. #. Size of map rose. Use **+w**\ *size* to specify the full width and height of the rose. A 3 cm
  1408. rose would require **+w**\ 3c.
  1409. The next two modifiers are optional:
  1410. #. Cardinal points. By default only the four cardinal points (W, E, S, N) are included in the rose.
  1411. You can extend that with the **+f**\ *level* modifier, where *level* is 1 [Default], 2, or 3. Selecting
  1412. 2 will include the two intermediate orientations NW-SE and NE-SW, while 3 adds the four additional
  1413. orientations WNW-ESE, NNW-SSE, NNE-SSW, and ENE-WSW.
  1414. #. Add labels. Do so with **+l**, which places the current one-letter codes for west, east, south,
  1415. and north at the four cardinal points. These letters depend on the setting of :term:`GMT_LANGUAGE`
  1416. and for the default English we use W, E, S, N, respectively. You can replace these labels with four custom
  1417. labels via **+l**\ *w,e,s,n*, i.e., four comma-separated labels in the specified order. You can exclude any
  1418. of the cardinal points from being labeled by giving no label in the corresponding order. E.g., **+l**",,Down,Up"
  1419. would write Down and Up at the south and north cardinal point, respectively. Note that for the plain
  1420. directional rose only the north annotation will be placed.
  1421. .. figure:: /_images/GMT_dir_rose.*
  1422. :width: 500 px
  1423. :align: center
  1424. Plain and fancy directional map roses. (left) Bare-bones plain rose showing arrow towards north
  1425. and a cross indicating the cardinal directions, specified by **-Tdg**\ 0/0\ **+w**\ 1i. (middle) Fancy rose
  1426. obtained by adding **+f** and **+l**\ ,,,N to get the north label. (right) Fancy directional rose
  1427. at level 3 with labels by adding **+f**\ 3\ **+l**.
  1428. .. _Placing-mag-map-roses:
  1429. Placing magnetic map roses
  1430. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1431. Map roses showing the magnetic directions of a map are useful when magnetic data are presented,
  1432. or when declinations are significantly nonzero. However, as for directional roses the magnetic rose
  1433. also has ornamental value. The magnetic rose consists of two concentric angular scales: The first
  1434. (outer) ring shows directional angles while the second (inner) ring is optional and portrays the
  1435. magnetic directions, which differ for nonzero declination. As for style, the two-ring rose looks a
  1436. bit like a standard compass. As for directional roses, a magnetic
  1437. map rose is added with :doc:`/basemap` or :doc:`/coast` and selected by the **-Tm** option.
  1438. As for other features, append the required *reference* point where the magnetic map rose's *anchor*
  1439. should be pinned. There is one required and several optional modifiers. First up is the size:
  1440. #. Specify size of map rose. Use **+w**\ *size* to specify the full width of the rose. A 3 cm
  1441. rose would imply **+w**\ 3c.
  1442. The remaining modifiers are optional:
  1443. #. Specify Declination. To add the inner angular scale, append **d**\ *dec*\ [/\ *dlabel*], where
  1444. *dec* is the declination value in decimal or ddd:mm:ss format, and *dlabel* is an optional string
  1445. that replaces the default label (which is "d = *dec*", with d being a Greek delta and we format
  1446. the specified declination). Append **d**\ *dec*/- to indicate you do not want any declination label.
  1447. As an example, consider **d**\ 11/"Honolulu declination".
  1448. #. Draw the secondary (outer) ring outline. Normally it is not drawn, but you can change that by appending
  1449. **+p**\ *pen*. For instance, adding **+p**\ thin will draw the ring with the selected thin pen.
  1450. #. Add labels. As for directional roses you do so with **+l**, which places the current one-letter codes for west, east, south,
  1451. and north at the four cardinal points. These letters depend on the setting of :term:`GMT_LANGUAGE`
  1452. and for the default English we use W, E, S, N, respectively. You can replace these labels with four custom
  1453. labels via **+l**\ *w,e,s,n*, i.e., four comma-separated labels in the specified order. You can exclude any
  1454. of the cardinal points from being labeled by giving no label in the corresponding order. E.g., **+l**",,Down,Up"
  1455. would write Down and Up at the south and north cardinal point, respectively.
  1456. #. Draw the primary (inner) ring outline. It is also not normally drawn; change that by appending
  1457. **+i**\ *pen*. For instance, adding **+i**\ thin,blue will draw the ring with the selected thin, blue pen.
  1458. #. Set annotation, tick and grid intervals. Each ring has a default annotation [30], tick [5], and grid [1]
  1459. interval (although here "grid interval" is just a finer tick interval drawn at half tickmark length).
  1460. Adjust these three intervals with **+t**\ *intervals*. If you selected **+d** then you must supply
  1461. two sets of such intervals (i.e., 6 comma-separated values), where the first (primary) set refers to
  1462. the declination-adjusted ring and the second (secondary) set refers to the directional (outer) ring.
  1463. If only three intervals are given then we assume you want the same intervals for both rings. As an example,
  1464. to annotate every 90 degrees and tick every 15 and 5 degrees, add **+t**\ 90/15/5.
  1465. .. figure:: /_images/GMT_mag_rose.*
  1466. :width: 600 px
  1467. :align: center
  1468. Magnetic direction map rose. This symbol is quite complicated and has many items whose attributes are
  1469. in part controlled by GMT defaults parameters and in part by the above modifiers. The color-coded legend
  1470. indicates which parameters controls the font, pen, or color of the correspond item of the rose. This rose
  1471. was specified by **-Tmg**\ -2/0.5\ **+w**\ 2.5i\ **+d**\ -14.5\ **+t**\ 45/10/5\ **+i**\ 0.25p,blue\ **+p**\ 0.25p,red\ **+l+j**\ CM.
  1472. See :doc:`/gmt.conf` for more details on the default parameters.
  1473. Placing color scale bars
  1474. ~~~~~~~~~~~~~~~~~~~~~~~~
  1475. Color scale bars are used in conjunction with color-coded surfaces, symbols, lines, or even text, to
  1476. relate the chosen color to a data value or category. For instance, color images of topography
  1477. or other gridded data will need a mechanism for users to decode what the colors represent. Typically, we do this
  1478. by adding a color scale bar on the outside (or inside) of the map boundaries. The module
  1479. :doc:`/colorbar` places the color scale bar, with location and size determined by the **-D** attributes.
  1480. As for other map features we must specify the reference and anchor points and any adjustments to them, then
  1481. supply suitable required and optional modifiers:
  1482. #. Give dimensions of color bar. Use **+w**\ *length*/*width* to specify the full width and height of the bar.
  1483. For instance, a 10 cm long bar of height 0.5 cm would imply **+w**\ 10c/0.5c.
  1484. #. Set orientation of color bar. By default, we place a vertically aligned bar. Select a horizontal bar by
  1485. adding **+h**.
  1486. #. Specify color bar label alignment. By default we place the chosen annotations, scale (i.e., x-axis) label
  1487. and unit (i.e., y-axis) label on the opposite side of the color scale bar anchor point. Change this
  1488. with **+m** and append any combination of **a**, **l**, or **u** to flip the annotations or labels
  1489. to the opposite side. Append **c** to plot vertical labels as column text (this cannot be used with
  1490. **+h**, obviously).
  1491. #. Extend the color bar. You can use the **+e** modifier to add sidebar triangles for displaying the
  1492. current back- and foreground colors. Append **b** (background) or **f** (foreground) to get the implied side
  1493. only [Default is both]. Optionally, append triangle height [Default is half the bar *width*].
  1494. #. Add missing data key. Append **+n** to draw a rectangle with the current NaN color and label it NaN.
  1495. Optionally, append a replacement *text*. One example might be **+n**\ "No data".
  1496. .. figure:: /_images/GMT_colorbar.*
  1497. :width: 500 px
  1498. :align: center
  1499. Color bar placed beneath a map (here truncated). We extended the bar to show background and foreground
  1500. colors, and used the frame-annotation machinery to add labels. The bar was placed with
  1501. **-D**\ *JBC*\ **+o**\ 0/0.35i\ **+w**\ 4.5i/0.1i\ **+h**.
  1502. Placing map legends
  1503. ~~~~~~~~~~~~~~~~~~~
  1504. Adding map legends is the standard way to communicate what various symbols placed on your map
  1505. represent. For instance, you may use this mechanism to convey the information that circles are
  1506. earthquake locations, triangles are places where you ate Thai food, and dashed lines indicate
  1507. some sort of gang-land demarkation line that you should not cross without paying the locals due respect.
  1508. Map legends are placed by the module :doc:`/legend`, with location and size determined by the
  1509. various **-D** attributes. We must again specify the reference and anchor points and any adjustments to them
  1510. first, then supply suitable required and optional modifiers:
  1511. #. Give legend dimensions. You must specify the required legend width, while legend height is optional
  1512. and if not given is computed based on the contents of the legend. The syntax is therefore
  1513. **+w**\ *width*\ [/*height*] in your desired plot units. Thus, **+w**\ 12c sets the legend width
  1514. as 12 cm but the height will become whatever is needed to contain the information.
  1515. #. Set line-spacing. You may optionally specify the line-spacing used for the setting of the legend. The legend will
  1516. typically consist of several lines that may or may not contain text, but the spacing between
  1517. these lines are controlled by the chosen line-spacing factor times the current primary annotation
  1518. font setting, i.e., :term:`FONT_ANNOT_PRIMARY`. The default line spacing factor
  1519. is 1.1; change this with **+l**\ *linefactor*.
  1520. .. figure:: /_images/GMT_legend.*
  1521. :width: 500 px
  1522. :align: center
  1523. Example of a map legend placed with :doc:`/legend`. Apart from the placement and dimensions discussed
  1524. here, :doc:`/legend` reads macro commands that specifies each item of the legend, including colors,
  1525. widths of columns, the number of columns, and presents a broad selection of items. Here, we
  1526. simply used **-Dx**\ 0/0\ **+w**\ 14c\ **+j**\ *BL*.
  1527. Placing raster and EPS images on maps
  1528. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1529. When preparing posters for meetings one will often need to include the organization's logo,
  1530. which may be available to you as an Encapsulated PostScript File (EPS) or as a raster image,
  1531. such as PNG or JPG. At other times, you may wish to place photos or other raster images on
  1532. your map. The module :doc:`/image` can help with this, and like the other map feature
  1533. placements it requires a reference point and its optional adjustments via the **-D** option.
  1534. In addition, we require one (of two) modifiers to determine the image size.
  1535. #. Specify image width. This is a required modifier and is set via **+w**\ *width*\ [/*height*].
  1536. If *height* is specified as 0 then we compute the height from *width* and the aspect
  1537. ratio of the image, for instance **+w**\ 4c/0. If *width* is negative the we use its absolute value as width
  1538. but interpolate the image in PostScript to the device resolution.
  1539. #. Specify image resolution. For raster images (not EPS) you may instead specify the size of the
  1540. plotted image by specifying its resolution in dots per inch, via **+r**\ *dpi*. The
  1541. actual size of the images is then controlled by its number of pixels times the *dpi*.
  1542. #. Enable image replication. For raster images (not EPS) you may optionally append **+n**\ *nx*\ [/*ny*]
  1543. to indicate that you want the source image to be replicated that many times in the two
  1544. directions, resulting in a tiling of the map using the selected image. This may be useful
  1545. in conjunction with an active clip path set by :doc:`/clip`.
  1546. .. figure:: /_images/GMT_images.*
  1547. :width: 500 px
  1548. :align: center
  1549. Placement of EPS and raster images. (left) The US National Science Foundation (NSF) has
  1550. generously funded the development of GMT and their JPG logo is reproduced here via
  1551. **-Dj**\ *ML*\ **+w**\ 1.5i\ **+o**\ 0.1i. (right)
  1552. The School of Ocean and Earth Science and Technology at the University of Hawaii at Manoa
  1553. hosts the gmt server and its EPS logo is shown via **-Dj**\ *MR*\ **+o**\ 0.1i\ **+w**\ 2i.
  1554. Placing a GMT logo on maps
  1555. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1556. It is possible to overlay the GMT logo on maps as well, using the module :doc:`/gmtlogo`.
  1557. Like other features it requires reference and anchor points and their optional adjustments via the **-D** option.
  1558. In addition, we require one modifier to set the logo's size.
  1559. #. Specify logo width. This is a required modifier and is set via **+w**\ *width*.
  1560. The height is automatically set (it is half the width). To place a 5 cm wide
  1561. GMT logo, append **+w**\ 5c.
  1562. .. figure:: /_images/GMT_coverlogo.*
  1563. :width: 300 px
  1564. :align: center
  1565. Placement of the GMT logo. The logo itself only has a size modifier but the :doc:`/gmtlogo`
  1566. module allows additional attributes such as a background map panel.
  1567. Placing map insets
  1568. ~~~~~~~~~~~~~~~~~~
  1569. Our penultimate map embellishment is the map inset.
  1570. A map inset may appear to be the easiest feature to add since it only consists of an empty map panel.
  1571. What you put in this panel is up to you (and we will show some examples). However, unlike
  1572. the other map features there are two ways to specify the placement of the map inset.
  1573. The first is the standard way of specifying the reference and anchor points and the inset dimensions,
  1574. while the second specifies a *subregion* in the current plot that should be designated the
  1575. map inset area. Depending on the map projection this may or may not be a rectangular area.
  1576. Map insets are produced by the module :doc:`/inset` and located via the **-D** option. Unless you
  1577. use the reference point approach you must first append *xmin*/*xmax*/*ymin*/*ymax*\ [**+r**][**+u**\ *unit*],
  1578. where the optional *unit* modifier **+u** indicates that the four coordinates to follow are projected
  1579. distances (e.g., km, miles). If the unit modifier is missing then we assume the coordinates are
  1580. map coordinates (e.g., geographic *west*, *east*, *south*, and *north*). For oblique
  1581. projections you may wish to specify the domain using the lower-left and upper-right coordinates
  1582. instead (similar to how the **-R** option works), by adding **+r**\ . Some optional modifiers are available:
  1583. #. Set inset size. If you specified a reference point then you must also specify the inset dimensions with the
  1584. **+w**\ *width*\ [/*height*], where *height* defaults to *width* if not given.
  1585. Append the unit of the dimensions, which may be distance units such as km, feet, etc., and
  1586. the map projection will be used to determine inset dimensions on the map. For instance,
  1587. **+w**\ 300k/200k is a 300x200 km region (which depends on the projection) while **+w**\ 5c
  1588. is a 5cm square box.
  1589. #. Save the location and dimensions. For all but the simplest of map insets you will need to
  1590. know the exact location of the resulting inset and its dimensions. For instance, if you
  1591. specified the inset using the **TR** anchor point and a width and height of 100 km you will need to
  1592. know what this means in terms of positions on the map in plot units. In terms of the modifiers
  1593. this would be **jTR**\ **+w**\ 100k. See the figure caption for an example.
  1594. .. figure:: /_images/GMT_inset.*
  1595. :width: 500 px
  1596. :align: center
  1597. Demonstration of how a map inset may be used to place a global overview map as an inset in a
  1598. regional map. Main map shows the regional area of Australia. We place an inset in the upper
  1599. right area with **-Dj**\ TR\ **+w**\ 3.8c\ **+o**\ 0.4c/0.25c.
  1600. See Example :ref:`example_44` for more details.
  1601. Placing a vertical scale on maps
  1602. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1603. Our final embellishment is reserved for wiggles plotted along track with :doc:`/wiggle` and
  1604. is activated as an option within that module.
  1605. Like other features, it requires reference and anchor points and their optional adjustments via the **-D** option.
  1606. In addition, we offer a few modifier to set the scale bar's remaining attributes:
  1607. #. Specify vertical scale bar length. This is a required modifier and is set via **+l**\ *length*.
  1608. The length is given in the data (*z*) units of your plot. To indicate that your vertical scale bar
  1609. should reflect 100 nTesla, append **+l**\ 100. The actual dimension of the scale bar on your map
  1610. depends on the data scale set in :doc:`/wiggle` via **-Z**.
  1611. #. Place the label on the left side of the vertical scale bar. This is an optional modifier and is set via **+m**.
  1612. By default, the scale bar has open ``teeth`` pointing right and a label on that side. The **m** moves the
  1613. label to the left and reverses the teeth direction as well.
  1614. #. Add a unit to the vertical scale bar label. This is an optional modifier and is set via **+u**\ *unit*.
  1615. To append nT (nTesla) to the label you would specify **+u**\ nT.
  1616. .. figure:: /_images/GMT_vertscale.*
  1617. :width: 600 px
  1618. :align: center
  1619. Placement of a vertical scale bar. As for other embellishments the :doc:`/wiggle`
  1620. module allows additional attributes such as a background map panel.
  1621. .. _grid-file-format:
  1622. Grid file format specifications
  1623. -------------------------------
  1624. GMT has the ability to read and write grids using more than one grid file format
  1625. (see Table :ref:`grdformats <tbl-grdformats>` for supported format and their IDs).
  1626. For reading, GMT will automatically determine the format of grid files, while for
  1627. writing you will normally have to append *=ID* to the filename if you want GMT to
  1628. use a different format than the default. The automatic reading procedure follows an heuristic
  1629. where certain formats are tentatively decoded with GMT internal drivers and if they fail than
  1630. we resort to use the GDAL library to do the readings. This normally works pretty well but in case
  1631. of failure (e.g. a GMT driver failed to read binary file with a separate header that also could
  1632. have been stored in an ASCII file with embed header) the user should explicitly try to force a
  1633. reading via GDAL. That is, to append a *=gd* suffix to file name.
  1634. By default, GMT will create new grid files using the **nf** format;
  1635. however, this behavior can be overridden by setting the
  1636. :term:`IO_GRIDFILE_FORMAT` defaults parameter to any of the other
  1637. recognized values (or by appending *=ID*).
  1638. GMT can also read netCDF grid files produced by other software
  1639. packages, provided the grid files satisfy the COARDS and Hadley Centre
  1640. conventions for netCDF grids. Thus, products created under those
  1641. conventions (provided the grid is 2-, 3-, 4-, or 5-dimensional) can be
  1642. read directly by GMT and the netCDF grids written by GMT can be read
  1643. by other programs that conform to those conventions. Three such programs are
  1644. `ncview <http://meteora.ucsd.edu/~pierce/ncview_home_page.html>`_, `Panoply
  1645. <http://www.giss.nasa.gov/tools/panoply/>`_, and `ncBrowse
  1646. <http://www.epic.noaa.gov/java/ncBrowse/>`_ ; others can be found on the
  1647. `netCDF website <http://www.unidata.ucar.edu/software/netcdf/software.html>`_.
  1648. Note that although many additional programs can read netCDF files, some are unable
  1649. to read netcdf 4 files (if data compression has been applied).
  1650. In addition, users with some C-programming experience may add their own
  1651. read/write functions and link them with the GMT library to extend the
  1652. number of predefined formats. Technical information on this topic can be
  1653. found in the source file ``gmt_customio.c``. Users who are considering this approach
  1654. should contact the GMT team.
  1655. .. _tbl-grdformats:
  1656. +----------+---------------------------------------------------------------+
  1657. | **ID** | **Explanation** |
  1658. +==========+===============================================================+
  1659. | | *GMT 4 netCDF standard formats* |
  1660. +----------+---------------------------------------------------------------+
  1661. | nb | GMT netCDF format (8-bit integer, COARDS, CF-1.5) |
  1662. +----------+---------------------------------------------------------------+
  1663. | ns | GMT netCDF format (16-bit integer, COARDS, CF-1.5) |
  1664. +----------+---------------------------------------------------------------+
  1665. | ni | GMT netCDF format (32-bit integer, COARDS, CF-1.5) |
  1666. +----------+---------------------------------------------------------------+
  1667. | nf | GMT netCDF format (32-bit float, COARDS, CF-1.5) |
  1668. +----------+---------------------------------------------------------------+
  1669. | nd | GMT netCDF format (64-bit float, COARDS, CF-1.5) |
  1670. +----------+---------------------------------------------------------------+
  1671. | | *GMT 3 netCDF legacy formats* |
  1672. +----------+---------------------------------------------------------------+
  1673. | cb | GMT netCDF format (8-bit integer, depreciated) |
  1674. +----------+---------------------------------------------------------------+
  1675. | cs | GMT netCDF format (16-bit integer, depreciated) |
  1676. +----------+---------------------------------------------------------------+
  1677. | ci | GMT netCDF format (32-bit integer, depreciated) |
  1678. +----------+---------------------------------------------------------------+
  1679. | cf | GMT netCDF format (32-bit float, depreciated) |
  1680. +----------+---------------------------------------------------------------+
  1681. | cd | GMT netCDF format (64-bit float, depreciated) |
  1682. +----------+---------------------------------------------------------------+
  1683. | | *GMT native binary formats* |
  1684. +----------+---------------------------------------------------------------+
  1685. | bm | GMT native, C-binary format (bit-mask) |
  1686. +----------+---------------------------------------------------------------+
  1687. | bb | GMT native, C-binary format (8-bit integer) |
  1688. +----------+---------------------------------------------------------------+
  1689. | bs | GMT native, C-binary format (16-bit integer) |
  1690. +----------+---------------------------------------------------------------+
  1691. | bi | GMT native, C-binary format (32-bit integer) |
  1692. +----------+---------------------------------------------------------------+
  1693. | bf | GMT native, C-binary format (32-bit float) |
  1694. +----------+---------------------------------------------------------------+
  1695. | bd | GMT native, C-binary format (64-bit float) |
  1696. +----------+---------------------------------------------------------------+
  1697. | | *Miscellaneous grid formats* |
  1698. +----------+---------------------------------------------------------------+
  1699. | rb | SUN raster file format (8-bit standard) |
  1700. +----------+---------------------------------------------------------------+
  1701. | rf | GEODAS grid format GRD98 (NCEI) |
  1702. +----------+---------------------------------------------------------------+
  1703. | sf | Golden Software Surfer format 6 (32-bit float) |
  1704. +----------+---------------------------------------------------------------+
  1705. | sd | Golden Software Surfer format 7 (64-bit float) |
  1706. +----------+---------------------------------------------------------------+
  1707. | af | Atlantic Geoscience Center AGC (32-bit float) |
  1708. +----------+---------------------------------------------------------------+
  1709. | ei | ESRI Arc/Info ASCII Grid Interchange format (ASCII integer) |
  1710. +----------+---------------------------------------------------------------+
  1711. | ef | ESRI Arc/Info ASCII Grid Interchange format (ASCII float) |
  1712. +----------+---------------------------------------------------------------+
  1713. | gd | Import/export via GDAL [19]_ |
  1714. +----------+---------------------------------------------------------------+
  1715. Because some formats have limitations on the range of values they can
  1716. store it is sometimes necessary to provide more than simply the name of
  1717. the file and its ID on the command line. For instance, a native short
  1718. integer file may use a unique value to signify an empty node or NaN, and
  1719. the data may need translation and scaling prior to use. Therefore, all
  1720. GMT programs that read or write grid files will decode the given
  1721. filename as follows:
  1722. name[=\ *ID*][**+s**\ *scale*][**+o**\ *offset*][**+n**\ *invalid*]
  1723. where anything in brackets is optional. If you are reading a grid then
  1724. no options are needed: just continue to pass the name of the grid file.
  1725. However, if you write another format you must append the =\ *ID* string,
  1726. where *ID* is the format code listed above. In addition, should you want
  1727. to (1) multiply the data by a scale factor, and (2) add a constant
  1728. offset you must append the **+s**\ *scale* and **+o**\ *offset* modifiers. Finally, if you
  1729. need to indicate that a certain data value should be interpreted as a
  1730. NaN (not-a-number) you must append **+n**\ *invalid* modifier to file name.
  1731. You may the scale as *a* for auto-adjusting the scale and/or offset of
  1732. packed integer grids (=\ *ID*\ **+s**\ *a* is a shorthand for
  1733. =\ *ID*\ **+s**\ *a*\ **+o**\ *a*).
  1734. Note that the GMT netCDF and native binary grids store the grid scale and offset
  1735. in the file, hence if you specify these attributes when writing a file then upon reading the grid
  1736. these settings will automatically take effect. You can override them by supplying different scales
  1737. and offsets, of course. For the grid formats that do not store these attributes
  1738. you will need to supply them both when reading and writing.
  1739. Some of the grid formats allow writing to standard output and reading
  1740. from standard input which means you can connect GMT programs that
  1741. operate on grid files with pipes, thereby speeding up execution and
  1742. eliminating the need for large, intermediate grid files. You specify
  1743. standard input/output by leaving out the filename entirely. That means
  1744. the "filename" will begin with "=\ *ID*". Note that the netCDF format
  1745. does not allow piping.
  1746. Everything looks clearer after a few examples:
  1747. * To write a native binary float grid file, specify the name as ``my_file.f4=bf`` .
  1748. * To read a native short integer grid file, multiply the data by 10 and
  1749. then add 32000, but first let values that equal 32767 be set to NaN,
  1750. use the filename ``my_file.i2=bs+s10+o32000+n32767``.
  1751. * To read a Golden Software "surfer" format 6 grid file, just pass the
  1752. file name, e.g., ``my_surferfile.grd``.
  1753. * To read a 8-bit standard Sun raster file (with values in the 0–255
  1754. range) and convert it to a 1 range, give the name as ``rasterfile+s7.84313725e-3+o-1``
  1755. (i.e., 1/127.5).
  1756. * To write a native binary short integer grid file to standard output
  1757. after subtracting 32000 and dividing its values by 10, give filename
  1758. as ``=bs+s0.1+o-3200``.
  1759. * To write an 8-bit integer netCDF grid file with an auto-adjusted
  1760. offset, give filename as ``=nb+oa``.
  1761. * To read a short integer *.bil* grid file stored in binary and and force
  1762. the reading via GDAL, add suffix *=gd* as in ``n45_e008_1arc_v3.bil=gd``
  1763. * To write a lossless, deflate compressed, and tiled GeoTIFF grid (or image) use,
  1764. ``output.tif=gd:GTiff+cTILED=YES+cCOMPRESS=DEFLATE+cPREDICTOR=3``
  1765. See also :ref:`Writing grids and images <Write-grids-images>` as well as available options
  1766. for each output format from the GDAL driver documentation,
  1767. `for example <https://gdal.org/drivers/raster/gtiff.html>`_
  1768. Programs that both read and/or write more than one grid file may specify
  1769. different formats and/or scaling for the files involved. The only
  1770. restriction with the embedded grid specification mechanism is that no
  1771. grid files may actually use the "=" character as part of their name
  1772. (presumably, a small sacrifice).
  1773. One can also define special file suffixes to imply a specific file
  1774. format; this approach represents a more intuitive and user-friendly way
  1775. to specify the various file formats. The user may create a file called
  1776. ``gmt.io`` in the current directory or home directory, or in the directory
  1777. ``~/.gmt`` and define any number of custom formats. The following is an example of
  1778. a ``gmt.io`` file:
  1779. +---------------------------------------------------------------------------+
  1780. | # GMT i/o shorthand file |
  1781. | |
  1782. | # It can have any number of comment lines like this one anywhere |
  1783. | # suffix format_id scale offset NaN Comments |
  1784. +-------+-----+-----+---+-------+-------------------------------------------+
  1785. | grd | nf | \- | \-| \- | Default format |
  1786. +-------+-----+-----+---+-------+-------------------------------------------+
  1787. | b | bf | \- | \-| \- | Native binary floats |
  1788. +-------+-----+-----+---+-------+-------------------------------------------+
  1789. | i2 | bs | \- | \-| 32767 | 2-byte integers with NaN value |
  1790. +-------+-----+-----+---+-------+-------------------------------------------+
  1791. | ras | rb | \- | \-| \- | Sun raster files |
  1792. +-------+-----+-----+---+-------+-------------------------------------------+
  1793. | byte | bb | \- | \-| 255 | Native binary 1-byte grids |
  1794. +-------+-----+-----+---+-------+-------------------------------------------+
  1795. | bit | bm | \- | \-| \- | Native binary 0 or 1 grids |
  1796. +-------+-----+-----+---+-------+-------------------------------------------+
  1797. | mask | bm | \- | \-| 0 | Native binary 1 or NaN masks |
  1798. +-------+-----+-----+---+-------+-------------------------------------------+
  1799. | faa | bs | 0.1 | \-| 32767 | Native binary gravity in 0.1 mGal |
  1800. +-------+-----+-----+---+-------+-------------------------------------------+
  1801. | ns | ns | a | a | \- | 16-bit integer netCDF grid with |
  1802. | | | | | | auto-scale and auto-offset |
  1803. +-------+-----+-----+---+-------+-------------------------------------------+
  1804. These suffices can be anything that makes sense to the user. To activate
  1805. this mechanism, set parameter :term:`IO_GRIDFILE_SHORTHAND` to TRUE in
  1806. your :doc:`/gmt.conf` file. Then, using the filename ``stuff.i2`` is equivalent to saying ``stuff.i2=bs+n32767``, and the
  1807. filename ``wet.mask`` means wet.mask=bm+n0. For a file intended for masking, i.e.,
  1808. the nodes are either 1 or NaN, the bit or mask format file may be as
  1809. small as 1/32 the size of the corresponding grid float format file.
  1810. Modifiers for changing units of grid coordinates
  1811. ------------------------------------------------
  1812. A few GMT tools require that the two horizontal dimensions be
  1813. specified in meters. One example is
  1814. :doc:`/grdfft` which must compute the 2-D
  1815. Fourier transform of a grid and evaluate wave numbers in the proper units
  1816. (1/meter). There are two situations where the user may need to change
  1817. the coordinates of the grid passed to such programs:
  1818. - You have a geographic grid (i.e., in longitude and latitude). Simply
  1819. supply the **-fg** option and your grid coordinates will
  1820. automatically be converted to meters via a "Flat Earth" approximation
  1821. on the currently selected ellipsoid (**Note**: This is only possible in
  1822. those few programs that require this capability. In general, **-fg**
  1823. is used to specify table coordinates).
  1824. - You have a Cartesian grid but the units are not meters (e.g., they
  1825. may perhaps be in km or miles). In this case you may append the file
  1826. modifier **+u**\ *unit*, where *unit* is one of non-angular units listed
  1827. in Table :ref:`distunits <tbl-distunits>`. For example, reading in the grid (which has
  1828. distance units of km) and converting distances to meters is done by
  1829. specifying the filename as *filename*\ **+u**\ k. On output, any derived grids will revert
  1830. to their original units *unless* you specify another unit modifier to
  1831. the output grid. This may be used, for instance, to save the original
  1832. grid with distances in meters using some other unit.
  1833. For convenience, we also support the inverse translation, i.e.,
  1834. **+U**\ *unit*. This modifier can be used to convert your grid
  1835. coordinates *from* meters *to* the specified unit. Example :ref:`example_28` shows a
  1836. case where this is being used to change an UTM grid in meters to km.
  1837. These modifiers are only allowed when map projections are not selected
  1838. (or are Cartesian).
  1839. .. _modifiers-for-CF:
  1840. Modifiers for COARDS-compliant netCDF files
  1841. -------------------------------------------
  1842. When the netCDF grid file contains more than one 2-dimensional variable,
  1843. GMT programs will load the first such variable in the file and ignore
  1844. all others. Alternatively, the user can select the required variable by
  1845. adding the suffix "?\ *varname*" to the grid file name. For example, to
  1846. get information on the variable "slp" in file , use:
  1847. ::
  1848. gmt grdinfo "file.nc?slp"
  1849. Since COARDS-compliant netCDF files are the default, the additional
  1850. suffix "=nf" can be omitted.
  1851. If there are no 2-dimensional variables and no specific variable was
  1852. selected, we default to the first higher-dimensional matrix and select
  1853. the first layer.
  1854. In case the named grid is 3-dimensional, GMT will load the first
  1855. (bottom) layer. If another layer is required, either add "[*index*]"
  1856. or "(*level*)", where *index* is the index of the third (depth) variable
  1857. (starting at 0 for the first layer) and *level* is the numerical value
  1858. of the third (depth) variable associated with the requested layer. To
  1859. indicate the second layer of the 3-D variable "slp" use as file name: ``file.nc?slp[1]``.
  1860. When you supply the numerical value for the third variable using
  1861. "(*level*)", GMT will pick the layer closest to that value. No
  1862. interpolation is performed.
  1863. Note that the question mark, brackets and parentheses have special
  1864. meanings on Unix-based platforms. Therefore, you will need to either
  1865. *escape* these characters, by placing a backslash in front of them, or
  1866. place the whole file name plus modifiers between single quotes or double
  1867. quotes.
  1868. A similar approach is followed for loading 4-dimensional grids. Consider
  1869. a 4-dimensional grid with the following variables:
  1870. ::
  1871. lat(lat): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  1872. lon(lon): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  1873. depth(depth): 0, 10, 20, 30, 40, 50, 60, 70, 80, 90
  1874. time(time): 0, 12, 24, 36, 48
  1875. pressure(time,depth,lat,lon): (5000 values)
  1876. To get information on the 10x10 grid of pressure at
  1877. depth 10 and at time 24, one would use:
  1878. ::
  1879. gmt grdinfo "file.nc?pressure[2,1]"
  1880. or (only in case the coordinates increase linearly):
  1881. ::
  1882. gmt grdinfo "file.nc?pressure(24,10)"
  1883. Programs that generally deal with columns of one-dimensional data, like
  1884. or can use multi-dimensional netCDF files in a very similar way. If a
  1885. variable in a netCDF file is one-dimensional, there is nothing more
  1886. needed than name the variables on the command line. For example:
  1887. ::
  1888. gmt plot "file.nc?lon/lat" ...
  1889. gmt convert "file.nc?time/lat/lon"
  1890. If one or more of the selected variables are two-dimensional, and have
  1891. the same leading dimension as the other selected variables they will be
  1892. plotted in their entirety. For example, if a netCDF files contains 6
  1893. time steps recording temperature at 4 points, and the variable ``temp`` is a 6 by
  1894. 4 array, then the command ``gmt convert "file.nc?time/temp"`` can result in:
  1895. ::
  1896. 2012-06-25T00:00:00 20.1 20.2 20.1 20.3
  1897. 2012-06-25T12:00:00 24.2 23.2 24.5 23.5
  1898. 2012-06-26T00:00:00 16.1 16.2 16.1 16.3
  1899. 2012-06-26T12:00:00 22.1 23.0 23.9 23.5
  1900. 2012-06-27T00:00:00 17.5 16.9 17.2 16.8
  1901. 2012-06-27T12:00:00 27.2 27.2 27.5 27.5
  1902. If, for example, only the second temperature column is needed, use
  1903. ``gmt convert "file.nc?time/temp[1]"`` (indices start counting at 0).
  1904. The COARDS conventions set restrictions on the names that can be used
  1905. for the units of the variables and coordinates. For example, the units
  1906. of longitude and latitude are "degrees_east" and "degrees_north",
  1907. respectively. Here is an example of the header of a COARDS compliant
  1908. netCDF file (to be obtained using **ncdump**):
  1909. ::
  1910. netcdf M2_fes2004 {
  1911. dimensions:
  1912. lon = 2881 ;
  1913. lat = 1441 ;
  1914. variables:
  1915. float lon(lon) ;
  1916. lon:long_name = "longitude" ;
  1917. lon:units = "degrees_east" ;
  1918. lon:actual_range = 0., 360. ;
  1919. float lat(lat) ;
  1920. lat:long_name = "latitude" ;
  1921. lat:units = "degrees_north" ;
  1922. lat:actual_range = -90., 90. ;
  1923. short amp(lat, lon) ;
  1924. amp:long_name = "amplitude" ;
  1925. amp:unit = "m" ;
  1926. amp:scale_factor = 0.0001 ;
  1927. amp:add_offset = 3. ;
  1928. amp:_FillValue = -32768s ;
  1929. short pha(lat, lon) ;
  1930. pha:long_name = "phase" ;
  1931. pha:unit = "degrees" ;
  1932. pha:scale_factor = 0.01 ;
  1933. pha:_FillValue = -32768s ;
  1934. This file contains two grids, which can be plotted separately using the
  1935. names ``M2_fes2004.nc?amp`` and ``M2_fes2004.nc?pha``. The attributes ``long_name`` and ``unit`` for each variable
  1936. are combined in GMT to a single unit string. For example, after
  1937. reading the grid ``y_unit`` equals ``latitude [degrees_north]``. The
  1938. same method can be used in reverse to set the proper variable names and
  1939. units when writing a grid. However, when the coordinates are set
  1940. properly as geographical or time axes, GMT will take care of this. The
  1941. user is, however, still responsible for setting the variable name and
  1942. unit of the z-coordinate. The default is simply "z".
  1943. Modifiers to read and write grids and images via GDAL
  1944. -----------------------------------------------------
  1945. If the support has been configured during installation, then GMT can
  1946. read and write a variety of grid and image formats via GDAL. This
  1947. extends the capability of GMT to handle data sets from a variety of
  1948. sources.
  1949. Reading multi-band images
  1950. ~~~~~~~~~~~~~~~~~~~~~~~~~
  1951. :doc:`/grdimage` and :doc:`/image` both lets the user select
  1952. individual bands in a multi-band image file and treats the result as an
  1953. image (that is the values, in the 0–255 range, are treated as colors,
  1954. not data). To select individual bands you use the **+b**\ *band-number*
  1955. mechanism that must be appended to the image filename. Here,
  1956. *band-number* can be the number of one individual band (the counting
  1957. starts at zero), or it could be a comma-separated list of bands. For example
  1958. ::
  1959. gmt image jpeg_image_with_three_bands.jpg+b0 -jpg gray
  1960. will plot only the first band (i.e., the red band) of the jpeg image as
  1961. a gray-scale image, and
  1962. ::
  1963. gmt image jpeg_image_with_three_bands.jpg+b2,1,0 -jpg bgr
  1964. will plot the same image in color but where the RGB band order has been reversed.
  1965. Instead of treating them as images, all other GMT programs that
  1966. process grids can read individual bands from an image but will consider
  1967. the values to be regular data. For example, let ``multiband`` be the name of a
  1968. multi-band file with a near infrared component in band 4 and red in band
  1969. 3. We will compute the NDVI (Normalized Difference Vegetation Index),
  1970. which is defined as NDVI = (NIR - R) / (NIR + R), as
  1971. ::
  1972. gmt grdmath multiband=gd+b3 multiband=gd+b2 SUB multiband=gd+b3 \
  1973. multiband=gd+b2 ADD DIV = ndvi.nc
  1974. The resulting grid ``ndvi.nc`` can then be plotted as usual.
  1975. Reading more complex multi-band IMAGES or GRIDS
  1976. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1977. It is also possible to access to sub-datasets in a multi-band grid. The
  1978. next example shows how we can extract the SST from the MODIS file ``A20030012003365.L3m_YR_NSST_9``
  1979. that is stored in the HDF "format". We need to run the GDAL program
  1980. **gdalinfo** on the file because we first
  1981. must extract the necessary metadata from the file:
  1982. .. code-block:: none
  1983. gdalinfo A20030012003365.L3m_YR_NSST_9
  1984. Driver: HDF4/Hierarchical Data Format Release 4
  1985. Files: A20030012003365.L3m_YR_NSST_9
  1986. Size is 512, 512
  1987. Coordinate System is `'
  1988. Metadata:
  1989. Product Name=A20030012003365.L3m_YR_NSST_9
  1990. Sensor Name=MODISA
  1991. Sensor=
  1992. Title=MODISA Level-3 Standard Mapped Image
  1993. ...
  1994. Scaling=linear
  1995. Scaling Equation=(Slope*l3m_data) + Intercept = Parameter value
  1996. Slope=0.000717185
  1997. Intercept=-2
  1998. Scaled Data Minimum=-2
  1999. Scaled Data Maximum=45
  2000. Data Minimum=-1.999999
  2001. Data Maximum=34.76
  2002. Subdatasets:
  2003. SUBDATASET_1_NAME=HDF4_SDS:UNKNOWN:"A20030012003365.L3m_YR_NSST_9":0
  2004. SUBDATASET_1_DESC=[2160x4320] l3m_data (16-bit unsigned integer)
  2005. SUBDATASET_2_NAME=HDF4_SDS:UNKNOWN:"A20030012003365.L3m_YR_NSST_9":1
  2006. SUBDATASET_2_DESC=[2160x4320] l3m_qual (8-bit unsigned integer)
  2007. Now, to access this file with GMT we need to use the =gd mechanism and
  2008. append the name of the sub-dataset that we want to extract. Here, a
  2009. simple example using :doc:`/grdinfo` would be
  2010. ::
  2011. gmt grdinfo A20030012003365.L3m_YR_NSST_9=gd?HDF4_SDS:UNKNOWN:"A20030012003365.L3m_YR_NSST_9:0"
  2012. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: Title: Grid imported via GDAL
  2013. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: Command:
  2014. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: Remark:
  2015. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: Gridline node registration used
  2016. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: Grid file format: gd = Import through GDAL (convert to float)
  2017. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: x_min: 0.5 x_max: 4319.5 x_inc: 1 name: x nx: 4320
  2018. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: y_min: 0.5 y_max: 2159.5 y_inc: 1 name: y ny: 2160
  2019. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: z_min: 0 z_max: 65535 name: z
  2020. HDF4_SDS:UNKNOWN:A20030012003365.L3m_YR_NSST_9:0: scale_factor: 1 add_offset: 0
  2021. Be warned, however, that things are not yet completed because while the
  2022. data are scaled according to the equation printed above ("Scaling
  2023. Equation=(Slope\*l3m_data) + Intercept = Parameter value"), this
  2024. scaling is not applied by GDAL on reading so it cannot be done
  2025. automatically by GMT. One solution is to do the reading and scaling
  2026. via :doc:`/grdmath` first, i.e.,
  2027. ::
  2028. gmt grdmath A20030012003365.L3m_YR_NSST_9=gd?HDF4_SDS:UNKNOWN:"A20030012003365.L3m_YR_NSST_9:0" \
  2029. 0.000717185 MUL -2 ADD = sst.nc
  2030. then plot the ``sst.nc`` directly.
  2031. .. _Write-grids-images:
  2032. Writing grids and images
  2033. ~~~~~~~~~~~~~~~~~~~~~~~~
  2034. Saving images in the common raster formats is possible but, for the time being, only from :doc:`/grdimage` and even
  2035. that is restricted to raster type information. That is, vector data (for instance, coast lines) or text will not
  2036. be saved. To save an image with :doc:`/grdimage` use the **-A**\ *outimg=driver* mechanism, where *driver*
  2037. is the driver code name used by GDAL (e.g. GTiff).
  2038. For all other programs that create grids, it is also possible to save them using GDAL. To do it one need to use
  2039. the =gd appended with the necessary information regarding the driver and the data type to use. Generically,
  2040. =\ **gd**\ [**+s**\ *scale*][**+o**\ *offset*][**+n**\ *nan*][:<*driver*\ >[/\ *dataType*][**+c**\ *options*]]
  2041. where *driver* is the same as explained above and *dataType* is a 2 or 3 chars code from:
  2042. u8\|u16\|i16\|u32\|i32\|float32, and where i\|u denotes signed\|unsigned. If not provided the default type
  2043. is float32. Both driver names and data types are case insensitive. The *options* is a list of one or more concatenated
  2044. number of GDAL *-co* options. For example, to write a lossless JPG2000 grid one would append
  2045. **+c**\ QUALITY=100\ **+c**\ REVERSIBLE=YES\ **+c**\ YCBCR420=NO
  2046. **Note**: You will have to specify a *nan* value for integer data types unless you wish that all NaN data values
  2047. should be replaced by zero.
  2048. The NaN data value
  2049. ------------------
  2050. For a variety of data processing and plotting tasks there is a need to
  2051. acknowledge that a data point is missing or unassigned. In the "old
  2052. days", such information was passed by letting a value like -9999.99 take
  2053. on the special meaning of "this is not really a value, it is missing".
  2054. The problem with this scheme is that -9999.99 (or any other floating
  2055. point value) may be a perfectly reasonable data value and in such a
  2056. scenario would be skipped. The solution adopted in GMT is to use the
  2057. IEEE concept Not-a-Number (NaN) for this purpose. Mathematically, a NaN
  2058. is what you get if you do an undefined mathematical operation like
  2059. 0/0; in ASCII data files they appear as the textstring NaN. This
  2060. value is internally stored with a particular bit pattern defined by IEEE
  2061. so that special action can be taken when it is encountered by programs.
  2062. In particular, a standard library function called ``isnan`` is used to
  2063. test if a floating point is a NaN. GMT uses these tests extensively to
  2064. determine if a value is suitable for plotting or processing (if a NaN is
  2065. used in a calculation the result would become NaN as well). Data points
  2066. whose values equal NaN are not normally plotted (or plotted with the
  2067. special NaN color given in :doc:`/gmt.conf`). Several tools such as
  2068. :doc:`/xyz2grd`, :doc:`/gmtmath`, and
  2069. :doc:`/grdmath` can convert user data to NaN
  2070. and vice versa, thus facilitating arbitrary masking and clipping of data
  2071. sets. Note that a few computers do not have native IEEE hardware
  2072. support. At this point, this applies to some of the older Cray
  2073. super-computers. Users on such machines may have to adopt the old
  2074. '-9999.99' scheme to achieve the desired results.
  2075. Data records that contain NaN values for the *x* or *y* columns (or the
  2076. *z* column for cases when 3-D Cartesian data are expected) are usually
  2077. skipped during reading. However, the presence of these bad records can
  2078. be interpreted in two different ways, and this behavior is controlled by
  2079. the :term:`IO_NAN_RECORDS` defaults parameter. The default setting (*gap*)
  2080. considers such records to indicate a gap in an otherwise continuous
  2081. series of points (e.g., a line), and programs can act upon this
  2082. information, e.g., not to draw a line across the gap or to break the
  2083. line into separate segments. The alternative setting (*bad*) makes no
  2084. such interpretation and simply reports back how many bad records were
  2085. skipped during reading; see Section :ref:`option_-g` for details.
  2086. .. _Directory parameters:
  2087. Directory parameters
  2088. --------------------
  2089. GMT versions prior to GMT 5 relied solely on several environment variables
  2090. (**$GMT_SHAREDIR**, **$GMT_DATADIR**, **$GMT_USERDIR**, and **$GMT_TMPDIR**), pointing
  2091. to folders with data files and program settings. Beginning with version
  2092. 5, some of these locations are now (also or exclusively) configurable
  2093. with the :doc:`/gmtset` utility.
  2094. When an environment variable has an equivalent parameter in the :doc:`/gmt.conf` file,
  2095. then the parameter setting will take precedence over the environment variable.
  2096. Variable **$GMT_SHAREDIR**
  2097. was sometimes required in previous GMT versions to locate the GMT
  2098. share directory where all run-time support files such as coastlines,
  2099. custom symbols, PostScript macros, color tables, and much more reside.
  2100. If this parameter is not set (default), GMT will make a reasonable
  2101. guess of the location of its share folder. Setting this variable is
  2102. usually not required and recommended only under special circumstances.
  2103. Variable **$GMT_DATADIR** and parameter :term:`DIR_DATA`
  2104. may point to one or more directories where large and/or widely used
  2105. data files can be placed. All GMT programs look in these directories
  2106. when a file is specified on the command line and it is not present in
  2107. the current directory. This allows maintainers to consolidate large
  2108. data files and to simplify scripting that use these files since the
  2109. absolute path need not be specified. Separate multiple directories
  2110. with commas. Any directory
  2111. name that ends in a trailing slash (/) will be searched recursively
  2112. (not under Windows).
  2113. Variable **$GMT_USERDIR**
  2114. may point to a directory where the user places custom configuration
  2115. files (e.g., an alternate ``coastline.conf`` file, preferred default
  2116. settings in ``gmt.conf``, custom symbols and color palettes, math
  2117. macros for :doc:`/gmtmath` and :doc:`/grdmath`, and shorthands for
  2118. gridfile extensions via ``gmt.io``). When **$GMT_USERDIR** is not defined,
  2119. then the default value **$HOME**/.gmt will be assumed. Users may also place their own
  2120. data files in this directory as GMT programs will search for files
  2121. given on the command line in both :term:`DIR_DATA` and **$GMT_USERDIR**.
  2122. Variable **$GMT_CACHEDIR**
  2123. may point to a directory where the user places cached data files
  2124. downloaded from the GMT data server. When **$GMT_CACHEDIR** is not defined,
  2125. then the default value **$HOME**/.gmt/cache will be assumed. The cache
  2126. directory can be emptied by running gmt **gmt clear cache**.
  2127. Variable **$GMT_TMPDIR**
  2128. may indicate the location, where GMT will write its state parameters
  2129. via the two files ``gmt.history`` and ``gmt.conf``. If **$GMT_TMPDIR** is not
  2130. set, these files are written to GMT session directory [for modern mode] or
  2131. the current directory [for classic mode].
  2132. Parameter :term:`DIR_DCW`
  2133. specifies where to look for the optional Digital Charts of the World
  2134. database (for country coloring or selections).
  2135. Parameter :term:`DIR_GSHHG`
  2136. specifies where to look for the required
  2137. Global Self-consistent Hierarchical High-resolution Geography database.
  2138. Note that files whose full path is given will never be searched for in
  2139. any of these directories.
  2140. Footnotes
  2141. ---------
  2142. .. [7]
  2143. Vicenty, T. (1975), Direct and inverse solutions of geodesics on the
  2144. ellipsoid with application of nested equations, *Surv. Rev.,
  2145. XXII(176)*, 88–93.
  2146. .. [8]
  2147. PostScript definition. In the typesetting industry a slightly
  2148. different definition of point (1/72.27 inch) is used, presumably to
  2149. cause needless trouble.
  2150. .. [9]
  2151. Choose between SI and US default units by modifying in the
  2152. GMT share directory.
  2153. .. [10]
  2154. To remain backwards compatible with GMT 4 we will also look for
  2155. but only if cannot be found.
  2156. .. [16]
  2157. To keep PostScript files small, such comments are by default turned
  2158. off; see :term:`PS_COMMENTS` to enable them.
  2159. .. [17]
  2160. For an overview of color systems such as HSV, see Chapter :doc:`colorspace`.
  2161. .. [18]
  2162. Convert other graphics formats to Sun ras format using GraphicsMagick's or ImageMagick's **convert** program.
  2163. .. [19]
  2164. Requires building GMT with GDAL.
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...