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

gmt2kml.rst 17 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
  1. .. index:: ! gmt2kml
  2. .. include:: module_core_purpose.rst_
  3. *******
  4. gmt2kml
  5. *******
  6. |gmt2kml_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt 2kml** [ *table* ]
  11. [ |-A|\ **a**\|\ **g**\|\ **s**\ [*alt*\|\ **x**\ *scale*] ]
  12. [ |-C|\ *cpt* ] [ |-D|\ *descriptfile* ]
  13. [ |-E|\ [**+e**][**+s**] ]
  14. [ |-F|\ **e**\|\ **s**\|\ **t**\|\ **l**\|\ **p**\|\ **w** ]
  15. [ |-G|\ [*color*]\ [**+f**\|\ **n**] ]
  16. [ |-I|\ *icon* ] [ **-K**]
  17. [ |-L|\ *col1:name1*,\ *col2:name2*,... ]
  18. [ |-N|\ [**t**\|\ *col*\|\ *name\_template*\|\ *name*] ]
  19. [ **-O**]
  20. [ |-Q|\ **a**\|\ **i**\ *az* ]
  21. [ |-Q|\ **s**\ *scale* ]
  22. [ |-R|\ **e**\|\ *w/e/s/n* ]
  23. [ |-S|\ **c**\|\ **n**\ *scale*] ]
  24. [ |-T|\ *title*\ [/*foldername*] ]
  25. [ |SYN_OPT-V| ]
  26. [ |-W|\ [*pen*][*attr*] ]
  27. [ |-Z|\ *args* ]
  28. [ |SYN_OPT-bi| ]
  29. [ |SYN_OPT-di| ]
  30. [ |SYN_OPT-e| ]
  31. [ |SYN_OPT-f| ]
  32. [ |SYN_OPT-h| ]
  33. [ |SYN_OPT-i| ]
  34. [ |SYN_OPT-qi| ]
  35. [ |SYN_OPT-:| ]
  36. [ |SYN_OPT--| ]
  37. [ > *output.kml* ]
  38. |No-spaces|
  39. Description
  40. -----------
  41. **2kml** reads one or more GMT table file and converts them to a
  42. single output file using Google Earth's KML format. Data may represent
  43. points, lines, polygons, or wiggles, and you may specify additional attributes
  44. such as title, altitude mode, colors, pen widths, transparency, regions,
  45. and data descriptions. You may also extend the feature down to ground
  46. level (assuming it is above it) and use custom icons for point symbols.
  47. Finally, there are controls on visibility depending on level of detail
  48. settings, altitude, regions, including the status upon loading into
  49. Google Earth as well as fading depending on zoom.
  50. The input files should contain the following columns:
  51. *lon* *lat* [ *alt* ] [ *timestart* [ *timestop* ] ]
  52. where *lon* and *lat* are required for all features, *alt* is optional
  53. for all features (see also **-A** and **-C**), and *timestart* and
  54. *timestop* apply to events and timespan features. For wiggles,
  55. the *alt* column is required but is expected to represent an along-track
  56. data anomaly such as gravity, magnetics, etc. These values will be
  57. scaled to yield distances from the line in degrees.
  58. Required Arguments
  59. ------------------
  60. None.
  61. Optional Arguments
  62. ------------------
  63. .. |Add_intables| unicode:: 0x20 .. just an invisible code
  64. .. include:: explain_intables.rst_
  65. .. _-A:
  66. **-A**\ **a**\|\ **g**\|\ **s**\ [*alt*\|\ **x**\ *scale*]
  67. Select one of three altitude modes recognized by Google Earth that
  68. determines the altitude (in m) of the feature: **a** absolute
  69. altitude, **g** altitude relative to sea surface or ground, **s**
  70. altitude relative to seafloor or ground. To plot the features at a
  71. fixed altitude, append an altitude *alt* (in m). Use 0 to clamp the
  72. features to the chosen reference surface. Append **x**\ *scale* to
  73. scale the altitude from the input file by that factor. If no value
  74. is appended, the altitude (in m) is read from the 3rd column of the
  75. input file. [By default the features are clamped to the sea surface or ground].
  76. .. _-C:
  77. **-C**\ *cpt*
  78. Use the CPT for assigning colors to the symbol, event, or
  79. timespan icons, based on the value in the 3rd column of the input
  80. file. For lines or polygons we examine the segment header for
  81. -Z<value> statements and obtain the color via the cpt lookup. Note
  82. only discrete colors are possible.
  83. .. _-D:
  84. **-D**\ *descriptfile*
  85. File with HTML snippets that will be included as part of the main
  86. description content for the KML file [no description]. See SEGMENT
  87. INFORMATION below for feature-specific descriptions.
  88. .. _-E:
  89. **-E**\ [**+e**][**+s**]
  90. Control how lines and polygons are rendered in Google Earth.
  91. Append **+e** to extrude the feature down to ground level [no extrusion].
  92. Append **+s** to connect points with straight lines (which may intersect
  93. the Earth's surface and be invisible) [tessellate onto surface].
  94. .. _-F:
  95. **-F**\ **e**\|\ **s**\|\ **t**\|\ **l**\|\ **p**\|\ **w**
  96. Sets the feature type. Choose from points (**e**\ vent,
  97. **s**\ ymbol, or **t**\ imespan), **l**\ ine, **p**\ olygon, or
  98. **w**\ iggle [symbol]. The first two columns of the input file should contain
  99. (*lon*, *lat*). When altitude or value is required (i.e., no
  100. *altitude* value was given with **-A**, or **-C** is set), the third
  101. column needs to contain the *altitude* (in m) or *value*. The event
  102. (**-Fe**) is a symbol that should only be active at a particular
  103. *time*, given in the next column. Timespan (**-Ft**) is a symbol
  104. that should only be active during a particular time period indicated
  105. by the next two columns (*timestart*, *timestop*). Use NaN to
  106. indicate unbounded time limits. If used, times should be in ISO
  107. format yyyy-mm-ddThh:mm:ss[.xxx] or in GMT relative time format
  108. (see **-f**). For wiggles, the data anomaly is required to be
  109. in the 3rd input column. If you also need to plot the track itself
  110. then do that separately with **-Fl**.
  111. .. _-G:
  112. **-G**\ [*color*]\ [**+f**\|\ **n**]
  113. Sets *color* for fill (modifier **+f** [Default]) or label font (modifier **+n**).
  114. Fill sets infill color for symbols, extrusions, polygons and positive anomaly
  115. wiggles [Default is light orange at 75% transparency]. Alternatively,
  116. use **-G+f** to turn off such infill.
  117. Text labels: Specify *color* for the font [Default is white]. Alternatively,
  118. use **-G+n** to instead disable the labels.
  119. .. _-I:
  120. **-I**\ *icon*
  121. Specify the URL to an alternative icon that should be used for the
  122. symbol [Default is a Google Earth circle]. If the URL starts with +
  123. then we will prepend
  124. `http://maps.google.com/mapfiles/kml/ <http://maps.google.com/mapfiles/kml/>`_
  125. to the name. To turn off icons entirely (e.g., when just wanting a
  126. text label), use **-I**-. [Default is a local icon with no directory path].
  127. .. _-K:
  128. **-K**
  129. Allow more KML code to be appended to the output later [finalize the KML file].
  130. **-L**\ *name1*,\ *name2*,...
  131. Extended data given. Append one or more column names separated by
  132. commas. We will expect the listed data columns to exist in the input
  133. immediately following the data coordinates required for the selected
  134. feature set by **-F**, and they will be encoded
  135. in the KML file as Extended Data sets, whose attributes will be
  136. available in a Google Earth balloon when the item is selected.
  137. The data file must have enough data columns and trailing text to
  138. accommodate the number of columns requested. If the number of extended
  139. data is one larger than the number of available numerical columns then
  140. the entire trailing text is set as the last extended data column.
  141. Otherwise, the trailing text is split into individual words and
  142. set as separate extended columns.
  143. .. _-N:
  144. **-N**\ [**t**\|\ *col*\|\ *name\_template*\|\ *name*]
  145. By default, if segment headers contain a **-L**"label string" then
  146. we use that for the name of the KML feature (polygon, line segment
  147. or set of symbols). Default names for these segments are "Line %d"
  148. and "Point Set %d", depending on the feature, where %d is a sequence
  149. number of line segments within a file. Each point within a line
  150. segment will be named after the line segment plus a sequence number.
  151. Default is simply "Point %d".
  152. Alternatively, select one of these options: (1) append *col* to
  153. supply individual symbol labels as the string formatted from the *col*
  154. data column, (2) append **t** to let individual symbol labels
  155. be the trailing text of each record (3) append a string that may
  156. include %d or a similar integer format to assign unique name IDs for
  157. each feature, with the segment number (for lines and polygons) or
  158. point number (symbols) appearing where %d is placed, (4) give no
  159. arguments to turn symbol labeling off; line segments will still be
  160. named. Also note that options (2) is not available unless input is an ASCII file.
  161. .. _-O:
  162. **-O**
  163. Append KML code to an existing KML file [initialize a new KML file].
  164. .. _-Q:
  165. **-Qa**\|\ **i**\ *azimuth*
  166. Option in support of wiggle plots (requires **-Fw**). You may
  167. control which directions the positive wiggles will tend to point
  168. to with **-Qa**. The provided azimuth defines a half-circle
  169. centered on the selected azimuth [0] where positive anomalies
  170. will plot. If outside then switch by 180 degrees. Alternatively,
  171. use **-Qi** to set a fixed direction with no further variation.
  172. **-Qs**\ *scale*
  173. Required setting for wiggle plots (i.e., it requires **-Fw**).
  174. Sets a wiggle scale in *z*-data units per the user's units (given
  175. via the trailing unit taken from d|m|s|e|f|k|M|n|u [e]). This scale
  176. is then inverted to yield degrees per user z-unit and used to
  177. convert wiggle anomalies to map distances and positions.
  178. .. _-R:
  179. **-Re**\|\ *w/e/s/n*
  180. Issue a single Region tag. Append *w/e/s/n* to set a particular
  181. region (will ignore points outside the region), or append **e** to
  182. determine and use the exact domain of the data (single file only)
  183. [no region tags issued].
  184. .. _-S:
  185. **-S**\ **c**\|\ **n**\ *scale*]
  186. Scale icons or labels. Here, **-Sc** sets a scale for the symbol
  187. icon, whereas **-Sn** sets a scale for the name labels [1 for both].
  188. .. _-T:
  189. **-T**\ *title*\ [/*foldername*]
  190. Sets the document title [default is unset]. Optionally, append
  191. /*FolderName*; this allows you, with **-O**, **-K**, to group
  192. features into folders within the KML document. [The default folder
  193. name is "*Name* Features", where *Name* is Point, Event, Timespan,
  194. Line, Polygon or Wiggle].
  195. .. _-V:
  196. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  197. .. include:: explain_-V.rst_
  198. .. _-W:
  199. **-W**\ [*pen*][*attr*] :ref:`(more ...) <-Wpen_attrib>`
  200. Set pen attributes for lines, wiggles or polygon outlines. Append pen
  201. attributes to use [Defaults: width = default, color = black, style =
  202. solid]. If the modifier **+cl** is appended then the color of the line
  203. are taken from the CPT (see **-C**). If instead modifier **+cf** is
  204. appended then the color from the cpt file is applied to symbol fill.
  205. Use just **+c** for both effects. Note that for KML the pen width is
  206. given in (fractional) pixels and not in points (1/72 inch).
  207. .. _-Z:
  208. **-Z**\ *args*
  209. Set one or more attributes of the Document and Region tags. Append
  210. **+a**\ *alt\_min/alt\_max* to specify limits on visibility based on
  211. altitude. Append **+l**\ *lod\_min/lod\_max* to specify limits on
  212. visibility based on Level Of Detail, where *lod\_max* == -1 means it
  213. is visible to infinite size. Append **+f**\ *fade\_min/fade\_max* to
  214. fade in and out over a ramp [abrupt]. Append **+v** to make a
  215. feature *not* visible when loaded [visible]. Append **+o** to open a
  216. folder or document in the sidebar when loaded [closed].
  217. .. |Add_-bi| replace:: [Default is 2 or more input columns, depending on settings].
  218. .. include:: explain_-bi.rst_
  219. .. |Add_-di| unicode:: 0x20 .. just an invisible code
  220. .. include:: explain_-di.rst_
  221. .. |Add_-e| unicode:: 0x20 .. just an invisible code
  222. .. include:: explain_-e.rst_
  223. .. |Add_-f| unicode:: 0x20 .. just an invisible code
  224. .. include:: explain_-f.rst_
  225. .. |Add_-g| unicode:: 0x20 .. just an invisible code
  226. .. include:: explain_-g.rst_
  227. .. |Add_-h| unicode:: 0x20 .. just an invisible code
  228. .. include:: explain_-h.rst_
  229. .. include:: explain_-icols.rst_
  230. .. include:: explain_-qi.rst_
  231. .. include:: explain_colon.rst_
  232. .. include:: explain_help.rst_
  233. Examples
  234. --------
  235. .. include:: explain_example.rst_
  236. To plot colored symbols based on a CPT of the remote file @kml_pointsets.txt,
  237. first make the CPT and then create the KML file thus::
  238. gmt makecpt -Ccategorical > categories.cpt
  239. gmt 2kml @kml_pointsets.txt -Ccategories.cpt > points.kml
  240. To convert a file with point locations (lon, lat) into a KML file with
  241. red circle symbols, try
  242. ::
  243. gmt 2kml mypoints.txt -Gred+f -Fs > mypoints.kml
  244. To convert a multisegment file with lines (lon, lat) separated by
  245. segment headers that contain a **-L**\ labelstring with the feature
  246. name, selecting a thick white pen, and title the document, try
  247. ::
  248. gmt 2kml mylines.txt -Wthick,white -Fl -T"Lines from here to there" > mylines.kml
  249. To convert a multisegment file with polygons (lon, lat) separated by
  250. segment headers that contain a **-L**\ labelstring with the feature
  251. name, selecting a thick black pen and semi-transparent yellow fill,
  252. giving a title to the document, and prescribing a particular region
  253. limit, try
  254. ::
  255. gmt 2kml mypolygons.txt -Gyellow@50+f -Fp -T"My polygons" -R30/90/-20/40 > mypolygons.kml
  256. To convert a file with point locations (lon, lat, time) into a KML file
  257. with green circle symbols that will go active at the specified time and
  258. stay active going forward, try
  259. ::
  260. awk '{print $1, $2, $3, "NaN"}' mypoints.txt | gmt 2kml -Ggreen+f -Ft > mytimepoints.kml
  261. To extract contours and labels every 10 units from the grid temp.nc and
  262. plot them in KML, using red lines at 75% transparency and red labels (no
  263. transparency), try
  264. ::
  265. gmt grdcontour temp.nc -Jx1id -A10+tlabel.txt -C10 -Dcontours.txt
  266. gmt 2kml contours.txt -Fl -W1p,red@75 -K > contours.kml
  267. gmt 2kml -O -Nt -Fs -Sn2 -Gred@0+n label.txt -I- >> contours.kml
  268. To instead plot the contours as lines with colors taken from the cpt
  269. file contours.cpt, try
  270. ::
  271. gmt 2kml contours.txt -Fl -Ccontours.cpt > contours.kml
  272. To plot magnetic anomalies as wiggles along track, with positive
  273. wiggles painted orange and the wiggle line drawn with a black pen
  274. of width 2p, scaling the magnetic anomalies (in nTesla) so that
  275. 50 nT equals 1 nm on the map, and place the wiggles 50m above the
  276. sea surface, use
  277. ::
  278. gmt 2kml magnetics_lon_lat_mag.txt -Fw -Gorange+f -W2p -Ag50 -Qs50n > wiggles.kml
  279. Limitations
  280. -----------
  281. Google Earth has trouble displaying filled polygons across the Dateline.
  282. For now you must manually break any polygon crossing the dateline into a
  283. west and east polygon and plot them separately. Google Earth also has
  284. other less obvious limitations on file size or line length. These do
  285. not seem to be documented. If features do not show and you are not
  286. getting an error, try to reduce the size of the file by splitting
  287. things up.
  288. Making Kmz Files
  289. ----------------
  290. Using the KMZ format is preferred as it takes less space. KMZ is simply
  291. a KML file and any data files, icons, or images referenced by the KML,
  292. contained in a zip archive. One way to organize large data sets is to
  293. split them into groups called Folders. A Document can contain any number
  294. of folders. Using scripts you can create a composite KML file using the
  295. **-K**, **-O** options just like you do with GMT plots. See **-T** for
  296. switching between folders and documents. The gmt_shell_scripts.sh
  297. contains function gmt_build_kmz that can assist in building a KMZ file
  298. from any number of KML files (and optionally images they may refer to).
  299. Kml Hierarchy
  300. -------------
  301. GMT stores the different features in hierarchical folders by feature
  302. type (when using **-O**, **-K** or **-T/**\ *foldername*), by input file
  303. (if not standard input), and by line segment (using the name from the
  304. segment header, or **-N**). This makes it more easy in Google Earth to
  305. switch on or off parts of the contents of the Document. The following is
  306. a crude example:
  307. [ KML header information; not present if **-O** was used ]
  308. <Document><name>GMT Data Document</name>
  309. <Folder><name>Point Features</name>
  310. <!--This level of folder is inserted only when using -O, -K>
  311. <Folder><name>file1.dat</name>
  312. <!--One folder for each input file (not when standard input)>
  313. <Folder><name>Point Set 0</name>
  314. <!--One folder per line segment>
  315. <!--Points from the first line segment in file file1.dat go here>
  316. <Folder><name>Point Set 1</name>
  317. <!--Points from the second line segment in file file1.dat go here>
  318. </Folder>
  319. </Folder>
  320. <Folder><name>Line Features</name>
  321. <Folder><name>file1.dat</name>
  322. <!--One folder for each input file (not when standard input)>
  323. <Placemark><name>Line 0</name>
  324. <!--Here goes the first line segment>
  325. </Placemark>
  326. <Placemark><name>Line 1</name>
  327. <!--Here goes the second line segment>
  328. </Placemark>
  329. </Folder>
  330. <Folder>
  331. </Document>
  332. [ KML trailer information; not present if **-K** was used ]
  333. Segment Information
  334. -------------------
  335. **2kml** will scan the segment headers for substrings of the form
  336. **-L**"*some label*\ " [also see **-N** discussion] and **-T**"*some
  337. text description*\ ". If present, these are parsed to supply name and
  338. description tags, respectively, for the current feature.
  339. Making KMZ files
  340. ----------------
  341. If you have made a series of KML files (which may depend on other items
  342. like local PNG images), you can consolidate these into a single KMZ file
  343. for saving space and for grouping related files together. The bash function
  344. **gmt_build_kmz** in the :doc:`gmt_shell_functions.sh` can be used to
  345. do this. You need to source gmt_shell_functions.sh first before you can
  346. use it.
  347. See Also
  348. --------
  349. :doc:`gmt` ,
  350. :doc:`gmt.conf`,
  351. :doc:`gmt_shell_functions.sh`,
  352. :doc:`grd2kml`,
  353. :doc:`img2google <supplements/img/img2google>`,
  354. :doc:`kml2gmt` ,
  355. :doc:`psconvert`
Tip!

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

Comments

Loading...