物探论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 985|回复: 0

[GMT] GMT课程lesson3

[复制链接]
发表于 2013-4-13 21:57:38 | 显示全部楼层 |阅读模式
Lesson 3
Goals

The end game in location maps! The goal of this lesson is to show you how to use scripts of gmt commands to plot symbols on location maps (in this case volcano locations), use scales, outline areas of interest, improve annotation on the map. Effectively, this turns your understanding of GMT into a very useful tool for figure preparation for reports, papers, and presentations.



Elements of the Location Map

The following figure shows a location map of the same area described in previous lessons, but now including much more useful information that is typically needed for a location map used in any kind of presentation. The map includes a scale, north arrow, outline of the study area, and numerous data, in this case the data are locations of active volcanoes in Central America, and are plotted as solid triangles. One volcano is of particular interest (Volcan Masaya) and is highlighted with a much larger red triangle.


1.jpg

These are the sorts of elements common to any location map. The script used to create the map is script3.gmt. View this file and study it, also list this script using the "more" command



Plotting points on the map

Points (e.g., volcanoes, earthqauke focii, sinkhole locations) are plotted on the location map using a gmt command "psxy". The psxy command used to plot the volcano locations is:

psxy volcano_locations.xy -: -R -JM -O -K -P -G0 -St0.125i -V >> location_map3.ps

The actual file plotted is volcano_locations.xy. psxy uses many of the same arguments discussed earlier for "pscoast". For example, the map projection and region of interest must be specified. Often, this region of interest is the same as used in previous commands, and the range does not need to be included again. Note that the volcano locations are overlayed on an existing plot (so the -O argument is used) and more postsrcipt will be added (so the -K argument is used). -P indicates that the figure is plotted in portrait (not landscape) orientation; -G0 indicates that the symbols are drawn in black. Numerous different symbols can be plotted. The symbol type is specified using the -S argument. For a complete list of symbol types, you can type psxy on the command line. In this case triangles are plotted, indicated by the lower case t, and the triangles are 0.125 inchs on a side - this is their actual size on the plot - obviously not referenced to the map coordinates.

The data used is located in a separate file called "volcano_locations.xy". View the contents of this file (for example save it and use the "more" command to list the file contents. The file was created in xemacs by typing in the latitude and longitude of active volcanoes in Central America. The source of this data was the book: Volcanoes of the World, by Simkin and Seibert. Note the format of the data. Each pair of points is on one line, with a space between the latitude and longitude. This is a typical file format. Note that comments can be added to the file, just like in the script itself. It is very important to add these comments in order to keep track of the contents of the file. Without adding this kind of comment to a data file - its value is often lost.

Also note that the "psxy" command normally expects data in an "x,y" or "long lat" format. This data file gives the values in the opposite order "lat long". The argument -: is used to specify that the order is in "lat long".

There are volcanoes in the data file that plot outside the range specified by -R; these data do not plot

Take a minute to actually look at the volcano locations. Note that along the volcanic arc, active volcanoes are distributed in unique segments. For example, a clear segment break occurs between the nothernmost volcano in Costa Rica, and the southernmost volcano in Nicaragua. Not only is the volcanic arc offset across the segment boundary, but the actual trend of the arc changes. Other, more subtle segmentation occurs in the arc. Dick Stoiber, Bill Rose, and Chuck Drake first proposed segmentation of the Central American arc in about 1970. They related this segmentation to variations in the angle of subduction of the Cocos Plate along the arc. This, they suggested, caused variation in distance behind the ocean trench that partial melting was initiated, ultimately controlling the volcano locations. ALthough their ideas have been refined considerably, the basic idea is accepted today. Note that Stoiber and Rose had to work very hard in the late 1960's to prepare a map of volcano locations that is so easily created now using GMT.The file in GMT format gvp.xy contains all the volcanoes currently in the Smithsonian Volcanoes of the World catalog, in Long / Lat format.

At this point, try saving the script under a different name (using the "mv" command) and modifying this part of the script. Change the symbol type and size. Try zooming in on sections of the plot using new map region (-R) corrdinates and search for additional segmentation in the volcanic arc.



Highlighting a Particular Feature

Masaya volcano is the focus of ongoing work in volcanic hazards at USF and so is highlighted on this example map. The same commands psxy and pstext are used to create this highlight. Altogether, three gmt commands are used. The first:

psxy -R -JM -O -K -P -G255/0/0 -St0.25i -W0.5 -V < < EOF>> location_map3.ps

-86.16 11.984

EOF

plots the red triangle on the map. -G255/0/0 is used to color the interior of the triangle red. -St0.25i is used to specify that the symbol is a triangle and is larger (0.25 inches) than the symbols plotted earlier. -W0.5 is used to outline the red triabgle using a black pen line. In this case, the data (map location of the volcano) are not read from a file, but contained in the script itself.

The next bit draws a thin line between the volcano location and the area where the text label will be drawn:

psxy -R -JM -O -K -P -W5.0 -V < < EOF>> location_map3.ps

-86.16 11.984

-87 10.0

EOF

To draw the line, the -S argument is not used at all, because the default symbol is a solid line. The weight (thickness) of the line is specified using the -W5.0 argument. The data indicate where the endpoints of the line are located.

The last thing to accomplish in drawing this highlight is the text label:

pstext -R -JM -G0 -O -K -P < < EOF >> location_map3.ps

-90 9.5 24 0 14 BL Volc\337n Masaya

EOF

This text has the same format as text that was plotted eariler. In this case, a different font (14) and font size (24) was used. Also, a special character sequence (\337) was used to plot an accent over the "a". A complete list of these kinds of character sequences is available in the gmt cookbook



Outlining a Study Area

Complicated outlines (polygons) are easily drawn on maps in gmt using the psxy command. On this figure, a simple polygonal study area is outlined. But complicated areas (details like the coastlines themselves) are plotted in exactly this manner. Again, the outline is drawn with a thick line, a thinner line is drwn to the label, and the label is drawn:

psxy -R -JM -O -K -P -W10.0 -V < < EOF>> location_map3.ps

-86.5 11.5

-86.5 12.5

-85.8 12.5

-85.3 11.5

-86.5 11.5

EOF

psxy -R -JM -O -K -P -W5.0 -V < < EOF>> location_map3.ps

-83 12.5

-85.5 12.0

EOF

pstext -R -JM -G0 -O -K -P < < EOF >> location_map3.ps

-83.5 12.75 24 0 14 BL Study Area

EOF

At this point, try creating a file containing points that outline an area on this location map. Save the file and plot the new outline on the map by modifying the script (do not forget to change the name of the script!).



Plotting the North Arrow

North arrows are kind of strange. On a location map like this one, it is really redundant to put on a north arrow at all, since latitude and longitude are already specified. But, many people are highly critical of any map that does not have a north arrow, regardless of whether it is redundant. So include one on your location maps! Again, the same commands are used to draw the north arrow, taking advantage of special character sets:

pstext -R -JM -G0 -O -K -P < < EOF >> location_map3.ps

-89 8 24 0 14 BL N

EOF


pstext -R -JM -G0 -O -P < < EOF >> location_map3.ps

-88.5 7 36 90 34 BL \343

EOF

font 34 is the ZafDingbats font, with many useful symbols. Other possible north arrows are: \324,\331,\344, \352, \362, \363, \370. Try experimenting with some of these alternative symbols.



Adding the Scale

The map scale is a crucial bit of information on the location map. Without the scale, the map is really incomplete. The scale is specified as an argument in the gmt command "pscoasts" The argument, -L, requires thelocation of the scale, the length of the scale, and the latitude at which the scale is estimated.



Assignment 3
Once again, modify your location maps to include the features described in this lesson. Outline a study area, add points of interest, include north arrows and scales. Save the files as jpegs in your directory and name them assign3_map1.jpg and assign3_map2.jpg, add these new maps to your Word document.

Chuck Connor
Last modified: Thu Jan 12 10:49:48 EST 2006
---------------------------------------------------------------------------------
将代码改成为dos批处理:
REM lesson3
REM #################### Draw the Basic Map  ########################
pscoast -R-90/-80/6/15 -JM6i -B2 -N1 -Df -Lf-85/7/12/500 -W -G180/180/180 -V -P -K -U"XXQ"> location_map3.ps
REM ################ Add Text For the Country Names #################
echo -85.5 12.5 18 30 26 BL Nicaragua | pstext -R -JM -G0 -O -K -P >> location_map3.ps
echo -83.5 10.0 18 30 26 BL Costa Rica | pstext -R -JM -G0 -O -K >> location_map3.ps
REM ############### Plot Volcanoes ################################
psxy volcano_locations.xy -: -R -JM -O -K -P -G0 -St0.125i -V >> location_map3.ps
REM ############## Highlight Masaya Volcano #########################
echo -86.16 11.984 | psxy -R -JM -O -K -P -G255/0/0 -St0.25i -W0.5 -V >> location_map3.ps
psxy line.d -R -JM -O -K -P  -W5.0 -V >> location_map3.ps
echo -90 9.5 24  0 14 BL Volc\337n Masaya | pstext -R -JM -G0 -O -K -P  >> location_map3.ps
REM #########  Show a Study Area  ##########################
psxy study.d -R -JM -O -K -P  -W10.0 -V >> location_map3.ps
psxy sl.d -R -JM -O -K -P -W5.0 -V >> location_map3.ps
echo -83.5 12.75 24 0 14 BL Study Area | pstext -R -JM -G0 -O -K -P >> location_map3.ps
REM ############# North Arrow ##############################
echo -89 8 24  0 14 BL N | pstext -R -JM -G0 -O -K -P  >> location_map3.ps
echo -88.5 7 36  90 34 BL \343 | pstext -R -JM -G0 -O  -P>> location_map3.ps
del .gmt*
效果图:

2.jpg
批处理中的相关数据:
-----------------------------------------------
volcano_locations.xy
#volcano locations in Central America
14.473 -90.880
14.465 -90.743
14.381 -90.601
14.33 -90.4
14.156 90.407
14.03 -90.1
14.3 -90.0
14.12 -89.73
14.33 -89.87
14.4 -89.78
14.42 -89.68
14.55 -89.63
14.83 -89.55
14.65 -89.35
13.891 -89.786
14.05 -89.63
14.27 -89.47
13.853 -89.630
13.813 -89.633
13.87 -89.55
13.736 -89.287
13.9 -89.12
13.672 -89.053
13.623 -88.852
13.72 -88.77
13.45 -88.53
13.497 -88.503
13.47 -88.47
13.48 -88.32
13.431 -88.272
13.277 -87.853
13.22 -87.765
13.27 -87.63
13.33 -87.63
14.98 -87.98
16.10 -86.90
12.98 -87.57
12.702 -87.004
12.63 -86.845
12.55 -86.75
12.506 -86.702
12.495 -86.688
12.423 -86.540
12.242 -86.342
11.984 -86.161
11.92 -86.03
11.826 -85.968
11.73 -85.82
11.538 -85.623
11.446 -85.515
12.68 -83.92
10.98 -85.473
10.830 -85.324
10.748 -85.153
10.673 -85.015
10.472 -85.07
10.463 -84.703
10.32 -84.66
10.42 -84.31
10.3 -84.366
10.2 -84.233
10.135 -84.1
9.979 -83.853
10.03 -83.77
8.8 -82.558
8.523 -80.910

-----------------------------------------------------------------------------------------
line.d
-86.16 11.984
-87 10.0

------------------------------------------------------------------------------------------
study.d
-86.5 11.5
-86.5 12.5
-85.8 12.5
-85.3 11.5
-86.5 11.5

-------------------------------------------------------------------------------------------
sl.d
-83 12.5
-85.5 12.0

=========================================================
有个疑问:
linux代码可以这么写
psxy -R -JM -O -K -P  -W5.0 -V <<EOF>> location_map3.ps
-86.16 11.984
-87 10.0
EOF



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|物探论坛 ( 鄂ICP备12002012号 微信号:iwutan )

GMT+8, 2024-4-30 02:18 , Processed in 0.081493 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表