|
2 | 2 | 2. Create a contour map
|
3 | 3 | =======================
|
4 | 4 |
|
5 |
| -This tutorial page covers the basics of creating a figure of the Earth |
6 |
| -relief, using a remote dataset hosted by GMT, using the method |
7 |
| -:meth:`pygmt.datasets.load_earth_relief`. It will use the |
8 |
| -:meth:`pygmt.Figure.grdimage`, :meth:`pygmt.Figure.grdcontour`, |
9 |
| -:meth:`pygmt.Figure.colorbar`, and :meth:`pygmt.Figure.coast` methods for |
10 |
| -plotting. |
| 5 | +This tutorial page covers the basics of creating a figure of the Earth relief, using a |
| 6 | +remote dataset hosted by GMT, using the method :meth:`pygmt.datasets.load_earth_relief`. |
| 7 | +It will use the :meth:`pygmt.Figure.grdimage`, :meth:`pygmt.Figure.grdcontour`, |
| 8 | +:meth:`pygmt.Figure.colorbar`, and :meth:`pygmt.Figure.coast` methods for plotting. |
11 | 9 | """
|
12 | 10 |
|
13 | 11 | # %%
|
|
17 | 15 | # Loading the Earth relief dataset
|
18 | 16 | # --------------------------------
|
19 | 17 | #
|
20 |
| -# The first step is to use :meth:`pygmt.datasets.load_earth_relief`. |
21 |
| -# The ``resolution`` parameter sets the resolution of the remote grid file, |
22 |
| -# which will affect the resolution of the plot made later in the tutorial. |
23 |
| -# The ``registration`` parameter determines the grid registration. |
| 18 | +# The first step is to use :meth:`pygmt.datasets.load_earth_relief`. The ``resolution`` |
| 19 | +# parameter sets the resolution of the remote grid file, which will affect the |
| 20 | +# resolution of the plot made later in the tutorial. The ``registration`` parameter |
| 21 | +# determines the grid registration. |
24 | 22 | #
|
25 |
| -# This grid region covers the islands of Guam and Rota in the western Pacific |
26 |
| -# Ocean. |
| 23 | +# This grid region covers the islands of Guam and Rota in the western Pacific Ocean. |
27 | 24 |
|
28 | 25 | grid = pygmt.datasets.load_earth_relief(
|
29 | 26 | resolution="30s", region=[144.5, 145.5, 13, 14.5], registration="gridline"
|
|
34 | 31 | # Plotting Earth relief
|
35 | 32 | # ---------------------
|
36 | 33 | #
|
37 |
| -# To plot Earth relief data, the method :meth:`pygmt.Figure.grdimage` can be |
38 |
| -# used to plot a color-coded figure to display the topography and bathymetry |
39 |
| -# in the grid file. The ``grid`` parameter accepts the input grid, which in |
40 |
| -# this case is the remote file downloaded in the previous step. If the |
41 |
| -# ``region`` parameter is not set, the region boundaries of the input grid are |
42 |
| -# used. |
| 34 | +# To plot Earth relief data, the method :meth:`pygmt.Figure.grdimage` can be used to |
| 35 | +# plot a color-coded figure to display the topography and bathymetry in the grid file. |
| 36 | +# The ``grid`` parameter accepts the input grid, which in this case is the remote file |
| 37 | +# downloaded in the previous step. If the ``region`` parameter is not set, the region |
| 38 | +# boundaries of the input grid are used. |
43 | 39 | #
|
44 |
| -# The ``cmap`` parameter sets the color palette table (CPT) used for portraying |
45 |
| -# the Earth relief. The :meth:`pygmt.Figure.grdimage` method uses the input |
46 |
| -# grid to relate the Earth relief values to a specific color within the CPT. |
47 |
| -# In this case, the CPT "oleron" is used; a full list of CPTs can be found |
48 |
| -# at :gmt-docs:`reference/cpts.html`. |
| 40 | +# The ``cmap`` parameter sets the color palette table (CPT) used for portraying the |
| 41 | +# Earth relief. The :meth:`pygmt.Figure.grdimage` method uses the input grid to relate |
| 42 | +# the Earth relief values to a specific color within the CPT. In this case, the CPT |
| 43 | +# "oleron" is used; a full list of CPTs can be found at :gmt-docs:`reference/cpts.html`. |
49 | 44 |
|
50 | 45 | fig = pygmt.Figure()
|
51 | 46 | fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron")
|
|
56 | 51 | # Adding a colorbar
|
57 | 52 | # -----------------
|
58 | 53 | #
|
59 |
| -# To show how the plotted colors relate to the Earth relief, a colorbar can be |
60 |
| -# added using the :meth:`pygmt.Figure.colorbar` method. |
| 54 | +# To show how the plotted colors relate to the Earth relief, a colorbar can be added |
| 55 | +# using the :meth:`pygmt.Figure.colorbar` method. |
61 | 56 | #
|
62 |
| -# To control the annotation and labels on the colorbar, a list is passed to |
63 |
| -# the ``frame`` parameter. The value beginning with ``"a"`` sets the interval |
64 |
| -# for the annotation on the colorbar, in this case every 1,000 meters. To set |
65 |
| -# the label for an axis on the colorbar, the argument begins with either |
66 |
| -# ``"x+l"`` (x-axis) or ``"y+l"`` (y-axis), followed by the intended label. |
| 57 | +# To control the annotation and labels on the colorbar, a list is passed to the |
| 58 | +# ``frame`` parameter. The value beginning with ``"a"`` sets the interval for the |
| 59 | +# annotation on the colorbar, in this case every 1,000 meters. To set the label for an |
| 60 | +# axis on the colorbar, the argument begins with either ``"x+l"`` (x-axis) or ``"y+l"`` |
| 61 | +# (y-axis), followed by the intended label. |
67 | 62 | #
|
68 |
| -# By default, the CPT for the colorbar is the same as the one set |
69 |
| -# in :meth:`pygmt.Figure.grdimage`. |
| 63 | +# By default, the CPT for the colorbar is the same as the one set in |
| 64 | +# :meth:`pygmt.Figure.grdimage`. |
70 | 65 |
|
71 | 66 | fig = pygmt.Figure()
|
72 | 67 | fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron")
|
|
78 | 73 | # Adding contour lines
|
79 | 74 | # --------------------
|
80 | 75 | #
|
81 |
| -# To add contour lines to the color-coded figure, the |
82 |
| -# :meth:`pygmt.Figure.grdcontour` method is used. The ``frame`` and |
83 |
| -# ``projection`` are already set using :meth:`pygmt.Figure.grdimage` and are |
84 |
| -# not needed again. However, the same input for ``grid`` (in this case, the |
85 |
| -# variable named "grid") must be input again. The ``levels`` parameter sets |
86 |
| -# the spacing between adjacent contour lines (in this case, 500 meters). The |
87 |
| -# ``annotation`` parameter annotates the contour lines corresponding to the |
88 |
| -# given interval (in this case, 1,000 meters) with the related values, here |
89 |
| -# elevation or bathymetry. By default, these contour lines are drawn thicker. |
90 |
| -# Optionally, the appearance (thickness, color, style) of the annotated and |
91 |
| -# the not-annotated contour lines can be adjusted (separately) by specifying |
92 |
| -# the desired ``pen``. |
| 76 | +# To add contour lines to the color-coded figure, the :meth:`pygmt.Figure.grdcontour` |
| 77 | +# method is used. The ``frame`` and ``projection`` are already set using |
| 78 | +# :meth:`pygmt.Figure.grdimage` and are not needed again. However, the same input for |
| 79 | +# ``grid`` (in this case, the variable named "grid") must be input again. The ``levels`` |
| 80 | +# parameter sets the spacing between adjacent contour lines (in this case, 500 meters). |
| 81 | +# The ``annotation`` parameter annotates the contour lines corresponding to the given |
| 82 | +# interval (in this case, 1,000 meters) with the related values, here elevation or |
| 83 | +# bathymetry. By default, these contour lines are drawn thicker. Optionally, the |
| 84 | +# appearance (thickness, color, style) of the annotated and the not-annotated contour |
| 85 | +# lines can be adjusted (separately) by specifying the desired ``pen``. |
93 | 86 |
|
94 | 87 | fig = pygmt.Figure()
|
95 | 88 | fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron")
|
|
102 | 95 | # Color in land
|
103 | 96 | # -------------
|
104 | 97 | #
|
105 |
| -# To make it clear where the islands are located, the |
106 |
| -# :meth:`pygmt.Figure.coast` method can be used to color in the landmasses. |
107 |
| -# The ``land`` is colored in as "lightgray", and the ``shorelines`` parameter |
108 |
| -# draws a border around the islands. |
| 98 | +# To make it clear where the islands are located, the :meth:`pygmt.Figure.coast` method |
| 99 | +# can be used to color in the landmasses. The ``land`` is colored in as "lightgray", and |
| 100 | +# the ``shorelines`` parameter draws a border around the islands. |
109 | 101 |
|
110 | 102 | fig = pygmt.Figure()
|
111 | 103 | fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron")
|
|
119 | 111 | # Additional exercises
|
120 | 112 | # --------------------
|
121 | 113 | #
|
122 |
| -# This is the end of the second tutorial. Here are some additional exercises |
123 |
| -# for the concepts that were discussed: |
| 114 | +# This is the end of the second tutorial. Here are some additional exercises for the |
| 115 | +# concepts that were discussed: |
124 | 116 | #
|
125 |
| -# 1. Change the resolution of the grid file to either ``"01m"`` (1 arc-minute, |
126 |
| -# a lower resolution) or ``"15s"`` (15 arc-seconds, a higher resolution). |
127 |
| -# Note that higher resolution grids will have larger file sizes. Available |
128 |
| -# resolutions can be found `here |
129 |
| -# <https://www.generic-mapping-tools.org/ |
130 |
| -# remote-datasets/earth-relief.html#usage>`_. |
| 117 | +# 1. Change the resolution of the grid file to either ``"01m"`` (1 arc-minute, a lower |
| 118 | +# resolution) or ``"15s"`` (15 arc-seconds, a higher resolution). Note that higher |
| 119 | +# resolution grids will have larger file sizes. Available resolutions can be found |
| 120 | +# at :meth:`pygmt.datasets.load_earth_relief`. |
131 | 121 | #
|
132 | 122 | # 2. Create a contour map of the area around Mt. Rainier. A suggestion for the
|
133 | 123 | # ``region`` would be ``[-122, -121, 46.5, 47.5]``. Adjust the
|
134 |
| -# :meth:`pygmt.Figure.grdcontour` and :meth:`pygmt.Figure.colorbar` |
135 |
| -# settings as needed to make the figure look good. |
| 124 | +# :meth:`pygmt.Figure.grdcontour` and :meth:`pygmt.Figure.colorbar` settings as |
| 125 | +# needed to make the figure look good. |
136 | 126 | #
|
137 |
| -# 3. Create a contour map of São Miguel Island in the Azores; a suggested |
138 |
| -# ``region`` is ``[-26, -25, 37.5, 38]``. Instead of coloring in ``land``, |
139 |
| -# set ``water`` to "lightblue" to only display Earth relief information for |
140 |
| -# the land. |
| 127 | +# 3. Create a contour map of São Miguel Island in the Azores; a suggested ``region`` is |
| 128 | +# ``[-26, -25, 37.5, 38]``. Instead of coloring in ``land``, set ``water`` to |
| 129 | +# "lightblue" to only display Earth relief information for the land. |
141 | 130 | #
|
142 | 131 | # 4. Try other CPTs, such as "SCM/fes" or "geo".
|
143 | 132 |
|
|
0 commit comments