coast¶
Plot continents, countries, shorelines, rivers, and borders
Synopsis¶
gmt coast -Jparameters -Rregion [ -Amin_area[/min_level/max_level][+a[g|i][s|S]][+l|r][+ppercent] ] [ -B[p|s]parameters ] [ -Cfill[+l|r] ] [ -Dresolution[+f] ] [ -Edcw ] [ -Fbox ] [ -G[fill] ] [ -Iriver[/pen] ] [ -Jz|Zparameters ] [ -Lscalebar ] [ -M ] [ -Nborder[/pen] ] [ -Q ] [ -S[fill] ] [ -Trose ] [ -U[stamp] ] [ -V[level] ] [ -W[level/]pen ] [ -X[a|c|f|r][xshift] ] [ -Y[a|c|f|r][yshift] ] [ -bobinary ] [ -pflags ] [ -ttransp ] [ --PAR=value ]
Note: No space is allowed between the option flag and the associated arguments.
Description¶
Plots grayshaded, colored, or textured land-masses [or water-masses] on maps and [optionally] draws coastlines, rivers, and political boundaries. Alternatively, it can (1) issue clip paths that will contain all land or all water areas, or (2) dump the data to an ASCII table. The data files come in 5 different resolutions: (f)ull, (h)igh, (i)ntermediate, (l)ow, and (c)rude. The full resolution files amount to more than 55 Mb of data and provide great detail; for maps of larger geographical extent it is more economical to use one of the other resolutions. If the user selects to paint the land-areas and does not specify fill of water-areas then the latter will be transparent (i.e., earlier graphics drawn in those areas will not be overwritten). Likewise, if the water-areas are painted and no land fill is set then the land-areas will be transparent. A map projection must be supplied.
Required Arguments¶
- -Jparameters
Specify the projection. (See full description) (See cookbook summary) (See projections table).
-Rwest/east/south/north[/zmin/zmax][+r][+uunit]
Specify the region of interest. Not required when -E is used. The region may be specified in one of six ways:
-Rwest/east/south/north[+uunit]. This is the standard way to specify geographic regions when using map projections where meridians and parallels are rectilinear. The coordinates may be specified in decimal degrees or in [±]dd:mm[:ss.xxx][W|E|S|N] format. Optionally, append +uunit to specify a region in projected units (e.g., UTM meters) where west/east/south/north are Cartesian projected coordinates compatible with the chosen projection (-J) and unit is an allowable distance unit; we inversely project to determine the actual rectangular geographic region.
-Rwest/south/east/north+r. This form is useful for map projections that are oblique, making meridians and parallels poor choices for map boundaries. Here, we instead specify the lower left corner and upper right corner geographic coordinates, followed by the modifier +r. This form guarantees a rectangular map even though lines of equal longitude and latitude are not straight lines.
-Rg or -Rd. These forms can be used to quickly specify the global domain (0/360 for -Rg and -180/+180 for -Rd in longitude, with -90/+90 in latitude).
-Rcode1,code2,…[+e|r|Rincs]. This indirectly supplies the region by consulting the DCW (Digital Chart of the World) database and derives the bounding regions for one or more countries given by the codes. Simply append one or more comma-separated countries using the two-character ISO 3166-1 alpha-2 convention. To select a state within a country (if available), append .state, e.g, US.TX for Texas. To specify a whole continent, prepend = to any of the continent codes AF (Africa), AN (Antarctica), AS (Asia), EU (Europe), OC (Oceania), NA (North America), or SA (South America). The following modifiers can be appended:
+r to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no adjustment]. For example, -RFR+r1 will select the national bounding box of France rounded to nearest integer degree.
+R to extend the region outward by adding the amounts specified by inc, xinc/yinc, or winc/einc/sinc/ninc [default is no extension].
+e to adjust the region boundaries to be multiples of the steps indicated by inc, xinc/yinc, or winc/einc/sinc/ninc, while ensuring that the bounding box extends by at least 0.25 times the increment [default is no adjustment].
-Rjustifylon0/lat0/nx/ny, where justify is a 2-character combination of L|C|R (for left, center, or right) and T|M|B (for top, middle, or bottom) (e.g., BL for lower left). The two character code justify indicates which point on a rectangular region region the lon0/lat0 coordinates refer to and the grid dimensions nx and ny are used with grid spacings given via -I to create the corresponding region. This method can be used when creating grids. For example, -RCM25/25/50/50 specifies a 50x50 grid centered on 25,25.
-Rgridfile. This will copy the domain settings found for the grid in specified file. Note that depending on the nature of the calling module, this mechanism will also set grid spacing and possibly the grid registration (see Grid registration: The -r option).
For perspective view -p, optionally append /zmin/zmax. (more …)
Optional Arguments¶
- -Amin_area[/min_level/max_level][+a[g|i][s|S]][+l|r][+ppercent]
Features with an area smaller than min_area in km^2 or of hierarchical level that is lower than min_level or higher than max_level will not be plotted [Default is 0/0/4 (all features)]. Level 2 (lakes) contains regular lakes and wide river bodies which we normally include as lakes; append +r to just get river-lakes or +l to just get regular lakes. Append +ppercent to exclude polygons whose percentage area of the corresponding full-resolution feature is less than percent. Use +a to control special aspects of the Antarctica coastline: By default (or add i) we select the ice shelf boundary as the coastline for Antarctica; alternatively, add g to select the ice grounding line instead. For expert users who wish to utilize their own Antarctica (with islands) coastline you can add s to skip all GSHHG features below 60S. In contrast, you can add S to instead skip all features north of 60S. See GSHHG INFORMATION below for more details.
- -B[p|s]parameters
Set map boundary frame and axes attributes. (See full description) (See cookbook information).
- -Cfill[+l|+r] (more …)
Set the shade, color, or pattern for lakes and river-lakes [Default is the fill chosen for “wet” areas (-S)]. Optionally, specify separate fills by appending +l for lakes or +r for river-lakes, repeating the -C option as needed.
- -Dresolution[+f]
Select the resolution of the data set to use ((f)ull, (h)igh, (i)ntermediate, (l)ow, and (c)rude). The resolution drops off by 80% between data sets. Append +f to automatically select a lower resolution should the one requested not be available [abort if not found]. Alternatively, choose (a)uto to automatically select the best resolution given the chosen map scale. [Default is l in classic mode and a in modern mode].
- -Ecode1,code2,…[+l|L][+gfill][+ppen][+z]
Select painting or dumping country polygons from the Digital Chart of the World. This is another dataset independent of GSHHG and hence the -A and -D options do not apply. Append one or more comma-separated countries using the 2-character ISO 3166-1 alpha-2 convention. To select a state of a country (if available), append .state, e.g, US.TX for Texas. To specify a whole continent, prepend = to any of the continent codes AF (Africa), AN (Antarctica), AS (Asia), EU (Europe), OC (Oceania), NA (North America), or SA (South America). Append +l to just list the countries and their codes [no data extraction or plotting takes place]. Use +L to see states/territories for Argentina, Australia, Brazil, Canada, China, India, Russia and the US. Finally, you can append +l|+L to -E=continent to only list countries in that continent; repeat if more than one continent is requested. Append +ppen to draw polygon outlines [no outline] and +gfill to fill them [no fill]. One of +p|g must be specified unless -M is in effect, in which case only one -E option can be given; append +z to place the country code in the segment headers via -Zcode settings. Otherwise, you may repeat -E to give different groups of items their own pen/fill settings. If neither -J nor -M are set then we just print the -Rwesn string.
-F[l|t][+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]][+s[[dx/dy/][shade]]]
Without further options, draws a rectangular border around any map scale (-L) or map rose (-T) using MAP_FRAME_PEN. Used in combination with -L or -T. Append l for map scale or t for map rose to specify which plot embellisment the -F parameters should be applied to [default uses the same panel parameters for all selected map embellishments]. The following modifiers can be appended to -F, with additional explanation and examples provided in the The background panel cookbook section:
+cclearance where clearance is either gap, xgap/ygap, or lgap/rgap/bgap/tgap and gap gives a uniform clearance, xgap/ygap gives separate clearances in the x- and y- directions, and lgap/rgap/bgap/tgap gives individual clearances between the map embellishment and the border for each side.
+gfill to fill the box with a color specified by fill [default is no fill].
+i[[gap/]pen] to draw a secondary, inner border as well. Optionally, specify the gap between the inner and outer border and the pen for the inner border [default is a uniform gap between borders of 2p and the MAP_DEFAULT_PEN].
+ppen to specify different pen attributes.
+r[radius] to draw rounded rectangular borders instead with a corner radius set by radius (append units) [defaults is 6p].
+s[[dx/dy/][shade]] to draw an offset background shaded region. Here, dx/dy indicates the shift relative to the foreground frame [default is 4p/-4p] and shade sets the fill style to use for shading [default is gray50].
- -G[fill] (more …)
Select filling or clipping of “dry” areas. Append the shade, color, or pattern; or give no argument for clipping [Default is no fill].
- -Iriver[/pen]
Draw rivers. Specify the type of rivers and [optionally] append pen attributes [Default pen: width = default, color = black, style = solid].
Choose from the list of river types below; repeat option -I as often as necessary.
0 = Double-lined rivers (river-lakes)
1 = Permanent major rivers
2 = Additional major rivers
3 = Additional rivers
4 = Minor rivers
5 = Intermittent rivers - major
6 = Intermittent rivers - additional
7 = Intermittent rivers - minor
8 = Major canals
9 = Minor canals
10 = Irrigation canals
You can also choose from several preconfigured river groups:
a = All rivers and canals (0-10)
A = All rivers and canals except river-lakes (1-10)
r = All permanent rivers (0-4)
R = All permanent rivers except river-lakes (1-4)
i = All intermittent rivers (5-7)
c = All canals (8-10)
-L[g|j|J|n|x]refpoint+wlength[e|f|k|M|n|u][+aalign][+c[[slon/]slat]][+f][+jjustify][+l[label]][+odx[/dy]][+u][+v]
Draw a simple map scale at the location defined by the reference (refpoint) and anchor point (set by +odx[/dy] and/or +jjustify). Give the reference point on the map for the rose using one of four coordinate systems:
Append glon/lat for map coordinates. Requires both -R and -J to be set.
Append jcode or Jcode for setting the refpoint via a 2-char justification code that refers to the (invisible) projected map bounding box. Requires both -R and -J to be set.
Append nxn/yn for normalized bounding box coordinates (0-1). Requires both -R and -J to be set.
Append xx/y for plot coordinates (append cm, inch, or ppoint).
The following modifiers can be appended to -L (+w is required), with additional explanation and examples provided in the Placing map scales cookbook section. For Cartesian projectsion, the modifiers +c and +f are not allowed and no units should be appended in +w.
+wlength to set scale length in km, or append unit from e|f|k|M|n|u.
+aalign to change the label alignment (choose among l(eft), r(ight), t(op), and b(ottom)) [default is t(op)].
+c[[slon/]slat]] to control where on a geographic map the scale applies. Map scale is calculated for latitude slat (optionally supply longitude slon for oblique projections [default is central meridian]). If +c is not given we default to the location of the refpoint. If +c is given with no arguments then we select the scale origin to be the middle of the map.
+f to get a “fancy” scale [default is plain].
+jjustify to set the justification anchor point, where justify is a 2-character justification code that is a combination of a horizontal (L, C, or R) and a vertical (T, M, or B) code. Note: If j is used to set the reference point then justify defaults to the same as refpoint; if J is used then justify defaults to the mirror opposite of refpoint; if g, n, or x is used to set the reference point then justify defaults to MC.
+l[label] to add a scale label. If label is not provided, we use the distance unit provided in +w [default is k(m)]. The label alignment is set by +a [default is t(op)]. Requires +f.
+odx[/dy] to offset the anchor point by dx and optionally dy (if different than dx).
+u to append the unit set by +w to all distance annotations along the scale (for the plain scale, +u will instead select the unit to be appended to the distance length).
+v to get a vertical rather than a horizontal Cartesian scale.
Note: Use FONT_LABEL to change the label font and FONT_ANNOT_PRIMARY to change the annotation font. The height of the map scale is controlled by MAP_SCALE_HEIGHT, and the pen thickness is set by MAP_TICK_PEN_PRIMARY. Optionally, use -F to place a panel behind the scale.
- -M
Dump a single multisegment ASCII (or binary, see -bo) file to standard output. No plotting occurs. Specify one of -E, -I, -N or -W. Note: If -M is used with -E then -R or the +r modifier to -E are not required as we automatically determine the region given the selected geographic entities. If using -W and you want just certain levels (1-4) then use the full syntax -Wlevel/pen and repeat for each level (pen is not used but required to parse the level correctly).
- -Nborder[/pen]
Draw political boundaries. Specify the type of boundary and [optionally] append pen attributes [Default pen: width = default, color = black, style = solid].
Choose from the list of boundaries below. Repeat option -N as often as necessary.
1 = National boundaries
2 = State boundaries within the Americas
3 = Marine boundaries
a = All boundaries (1-3)
- -Q
Mark end of existing clip path. No projection information is needed. Also supply -X and -Y settings if you have moved since the clip started.
- -S[fill] (more …)
Select filling or clipping of “wet” areas. Append the shade, color, or pattern; or give no argument for clipping [Default is no fill].
-Td[g|j|J|n|x]refpoint+wwidth[+f[level]][+jjustify][+l[w,e,s,n]][+odx[/dy]]
Draw a map directional rose on the map at the location defined by the reference (refpoint) and anchor point (set by +odx[/dy] and/or +jjustify). Give the reference point on the map for the rose using one of four coordinate systems:
Append glon/lat for map coordinates. Requires both -R and -J to be set.
Append jcode or Jcode for setting the refpoint via a 2-char justification code that refers to the (invisible) projected map bounding box. Requires both -R and -J to be set.
Append nxn/yn for normalized bounding box coordinates (0-1). Requires both -R and -J to be set.
Append xx/y for plot coordinates (append cm, inch, or ppoint).
The following modifiers can be appended to -Td (+w is required), with additional explanation and examples provided in the Placing directional map roses cookbook section. Optionally, use -F to place a panel behind the directional rose.
+wwidth to set the width of the rose in plot coordinates (append inch, cm, or points).
+f[level] to get a “fancy” rose, and optionally specify the level of fanciness. Level 1 draws the two principal E-W, N-S orientations, 2 adds the two intermediate NW-SE and NE-SW orientations, while 3 adds the eight minor orientations WNW-ESE, NNW-SSE, NNE-SSW, and ENE-WSW [default is 1].
+jjustify to set the justification anchor point, where justify is a 2-character justification code that is a combination of a horizontal (L, C, or R) and a vertical (T, M, or B) code. Note: If j is used to set the reference point then justify defaults to the same as refpoint; if J is used then justify defaults to the mirror opposite of refpoint; if g, n, or x is used to set the reference point then justify defaults to MC.
+l[w,e,s,n] to label the cardinal points W,E,S,N. Optionally, append your own four comma-separated strings to override the default. Skip a specific label by leaving it blank.
+odx[/dy] to offset the anchor point by dx and optionally dy (if different than dx).
-Tm[g|j|J|n|x]refpoint+wwidth[+ddec[/dlabel]]][+ipen][+jjustify][+l[w,e,s,n]][+ppen][+tints][+odx[/dy]]
Draw a map magnetic rose on the map at the location defined by the reference (refpoint) and anchor point (set by +odx[/dy] and/or +jjustify). Give the reference point on the map for the rose using one of four coordinate systems:
Append glon/lat for map coordinates. Requires both -R and -J to be set.
Append jcode or Jcode for setting the refpoint via a 2-char justification code that refers to the (invisible) projected map bounding box. Requires both -R and -J to be set.
Append nxn/yn for normalized bounding box coordinates (0-1). Requires both -R and -J to be set.
Append xx/y for plot coordinates (append cm, inch, or ppoint).
The following modifiers can be appended to -Tm (+w is required), with additional explanation and examples provided in the Placing magnetic map roses cookbook section. Optionally, use -F to place a panel behind the magnetic rose.
+wwidth to set the width of the rose in plot coordinates (append inch, cm, or points).
+ddec[/dlabel] to assign the magnetic declination and set dlabel, which is a label for the magnetic compass needle (omit dlabel to format a label from dec, or give - to bypass labeling). With +d, both directions to geographic and magnetic north are plotted [default is geographic only].
+ipen to draw the outline of the inner circle in the specified pen.
+jjustify to set the justification anchor point, where justify is a 2-character justification code that is a combination of a horizontal (L, C, or R) and a vertical (T, M, or B) code. Note: If j is used to set the reference point then justify defaults to the same as refpoint; if J is used then justify defaults to the mirror opposite of refpoint; if g, n, or x is used to set the reference point then justify defaults to MC.
+l[w,e,s,n] to label the cardinal points W,E,S,N and append your own four comma-separated strings to override the default. Skip a specific label by leaving it blank. If the north label is * then a north star is plotted instead of the north label.
+ppen to draw the outline of the outer circle in the specified pen.
+tints to specify the annotation and two tick interval levels for the geographic and magnetic directions by providing three slash-separated intervals. Specify separate intervals by appending three slash-separated geographic intervals followed by three slash-separated magnetic intervals [default is 30/5/1]
+odx[/dy] to offset the anchor point by dx and optionally dy (if different than dx).
- -U[label|+c][+jjust][+odx/dy]
Draw GMT time stamp logo on plot. (See full description) (See cookbook information).
- -V[level]
Select verbosity level [w]. (See full description) (See cookbook information).
- -W[level/]pen (more …)
Draw shorelines [Default is no shorelines]. Append pen attributes [Defaults: width = default, color = black, style = solid] which apply to all four levels. To set the pen for each level differently, prepend level/, where level is 1-4 and represent coastline, lakeshore, island-in-lake shore, and lake-in-island-in-lake shore. Repeat -W as needed. When specific level pens are set, those not listed will not be drawn [Default draws all levels; but see -A].
- -X[a|c|f|r][xshift]
Shift plot origin. (See full description) (See cookbook information).
- -Y[a|c|f|r][yshift]
Shift plot origin. (See full description) (See cookbook information).
- -bo[ncols][type] (more …)
Select native binary output.
- -p[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0] (more …)
Select perspective view.
- -ttransp[/transp2] (more …)
Set transparency level(s) in percent.
- -^ or just -
Print a short message about the syntax of the command, then exit (NOTE: on Windows just use -).
- -+ or just +
Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.
- -? or no arguments
Print a complete usage (help) message, including the explanation of all options, then exit.
- --PAR=value
Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.
Examples¶
Note: Since many GMT plot examples are very short (i.e., one module call between the gmt begin and gmt end commands), we will often present them using the quick modern mode GMT Modern Mode One-line Commands syntax, which simplifies such short scripts.
To plot a green Africa with white outline on blue background, with permanent major rivers in thick blue pen, additional major rivers in thin blue pen, and national borders as dashed lines on a Mercator map at scale 0.1 inch/degree, use:
gmt coast -R-30/30/-40/40 -Jm0.1i -B5 -I1/1p,blue -N1/0.25p,- \
-I2/0.25p,blue -W0.25p,white -Ggreen -Sblue -pdf africa
To plot Iceland using the lava pattern (# 28) at 100 dots per inch, on a Mercator map at scale 1 cm/degree, run:
gmt coast -RIS+r1 -Jm1c -B -Wthin -Gp28+r100 -pdf iceland
To initiate a clip path for Africa so that the subsequent colorimage of gridded topography is only seen over land, using a Mercator map at scale 0.1 inch/degree, use:
gmt begin
gmt coast -R-30/30/-40/40 -Jm0.1i -B -G
gmt grdimage @earth_relief_05m
gmt coast -Q
gmt end show
To plot Great Britain, Italy, and France in blue with a red outline and Spain, Portugal and Greece in yellow (no outline), and pick up the plot domain from the extents of these countries, use:
gmt coast -JM6i -Baf -EGB,IT,FR+gblue+p0.25p,red -EES,PT,GR+gyellow -pdf map
To extract a high-resolution coastline data table for Iceland to be used in your analysis, try:
gmt coast -RIS -Dh -W -M > iceland.txt
coast will first look for coastline files in directory $GMT_SHAREDIR/coast If the desired file is not found, it will look for the file $GMT_SHAREDIR/coastline.conf. This file may contain any number of records that each holds the full pathname of an alternative directory. Comment lines (#) and blank lines are allowed. The desired file is then sought for in the alternate directories.
GSHHG Information¶
The coastline database is GSHHG (formerly GSHHS) which is compiled from three sources: World Vector Shorelines (WVS, not including Antarctica), CIA World Data Bank II (WDBII), and Atlas of the Cryosphere (AC, for Antarctica only). Apart from Antarctica, all level-1 polygons (ocean-land boundary) are derived from the more accurate WVS while all higher level polygons (level 2-4, representing land/lake, lake/island-in-lake, and island-in-lake/lake-in-island-in-lake boundaries) are taken from WDBII. The Antarctica coastlines come in two flavors: ice-front or grounding line, selectable via the -A option. Much processing has taken place to convert WVS, WDBII, and AC data into usable form for GMT: assembling closed polygons from line segments, checking for duplicates, and correcting for crossings between polygons. The area of each polygon has been determined so that the user may choose not to draw features smaller than a minimum area (see -A); one may also limit the highest hierarchical level of polygons to be included (4 is the maximum). The 4 lower-resolution databases were derived from the full resolution database using the Douglas-Peucker line-simplification algorithm. The classification of rivers and borders follow that of the WDBII. See The Global Self-consistent, Hierarchical, High-resolution Geography Database (GSHHG) for further details.
Bugs¶
The options to fill (-C -G -S) may not always work if the Azimuthal equidistant projection is chosen (-Je|E). If the antipole of the projection is in the oceans it will most likely work. If not, try to avoid using projection center coordinates that are even multiples of the coastline bin size (1, 2, 5, 10, and 20 degrees for f, h, i, l, c, respectively). This projection is not supported for clipping.
The political borders are for the most part 1970s-style but have been updated to reflect more recent border rearrangements in Europe and elsewhere. Let us know if you find something out of date.
The full-resolution coastlines are also from a digitizing effort in the 1970-80s and it is difficult to assess the accuracy. Users who zoom in close enough may find that the GSHHG coastline is not matching other data, e.g., satellite images, more recent coastline data, etc. We are aware of such mismatches but cannot undertake band-aid solutions each time this occurs.
Some users will not be satisfied with what they find for the Antarctic shoreline. In Antarctica, the boundary between ice and ocean varies seasonally and inter-annually. There are some areas of permanent shelf ice. In addition to these time-varying ice-ocean boundaries, there are also shelf ice grounding lines where ice goes from floating on the sea to sitting on land, and lines delimiting areas of rock outcrop. For consistency’s sake, we have used the World Vector Shoreline throughout the world, as described in The Global Self-consistent, Hierarchical, High-resolution Geography Database (GSHHG). Users who need specific boundaries in Antarctica should get the Antarctic Digital Database, prepared by the British Antarctic Survey, Scott Polar Research Institute, World Conservation Monitoring Centre, under the auspices of the Scientific Committee on Antarctic Research. This data base contains various kinds of limiting lines for Antarctica and is available on CD-ROM. It is published by the Scientific Committee on Antarctic Research, Scott Polar Research Institute, Lensfield Road, Cambridge CB2 1ER, United Kingdom.