Skip to content

Commit 8e9dc47

Browse files
authored
Add region.rst and update index (#18)
1 parent dfa53f9 commit 8e9dc47

File tree

2 files changed

+200
-1
lines changed

2 files changed

+200
-1
lines changed

docs/index.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,11 @@ Basics
105105
:width: 80%
106106
:align: center
107107

108-
:doc:`tutorials/basics/frames`
108+
:doc:`tutorials/basics/frames`
109+
110+
- .. image:: _images/1db761511fa1371a3fa3f01cc3bdc199.png
111+
:target: tutorials/basics/region.html
112+
:width: 80%
113+
:align: center
114+
115+
:doc:`tutorials/basics/region`

docs/tutorials/basics/region.rst

+192
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
Setting the Region
2+
------------------
3+
4+
In this tutorial we are going to explain how to define the geographical region of maps.
5+
This is done trough the ``-R`` parameter .
6+
To do so, we will use the simplest way which is when the boundaries are defined by meridians and parallels.
7+
8+
This tutorial covers the following methods:
9+
10+
* `String of Coordinates`_
11+
* `Global Domain keys`_
12+
* `Codes`_
13+
14+
String of Coordinates
15+
~~~~~~~~~~~~~~~~~~~~~
16+
17+
A string of coordinates can be passed to ``-R``, in the form of xmin/xmax/ymin/ymax.
18+
This is the standard and most customizable way to specify geographic regions.
19+
For example, to make a map that x-range from 85W to 74W and the y-range to 19N to 24N we should use ``-R-85/-74/19/24``
20+
21+
.. gmtplot::
22+
23+
gmt begin region png
24+
gmt basemap -JM12c -Bxafg -Byafg -R-85/-74/19/24
25+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
26+
gmt end show
27+
28+
29+
Global Domain keys
30+
~~~~~~~~~~~~~~~~~~
31+
32+
If you want to make a global map, then you can use one of the following codes
33+
to quickly specify the global domain:
34+
35+
-Rd
36+
===
37+
38+
* ``-Rd``: Centered at the Prime meridian (0º). It sets the region to -180/180/-90/90.
39+
40+
41+
.. gmtplot::
42+
43+
gmt begin region png
44+
gmt basemap -JN12c -Baf -Rd
45+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
46+
gmt end show
47+
48+
49+
-Rg
50+
===
51+
52+
* ``-Rg``: Centered at the antimeridian (180º). It sets the region to 0/360/-90/90.
53+
54+
.. gmtplot::
55+
56+
gmt begin region png
57+
gmt basemap -JN12c -Baf -Rg
58+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
59+
gmt end show
60+
61+
62+
Codes
63+
~~~~~
64+
65+
ISO Codes
66+
=========
67+
68+
If you want to make a map of a country, then you select its region with the two-character ISO-Code.
69+
This indirectly supplies the region by consulting the DCW (`Digital Chart of the World <https://github.com/GenericMappingTools/dcw-gmt?tab=readme-ov-file#dcw-gmt-the-digital-chart-of-the-world-for-gmt>`_) database
70+
and derives the bounding region given by the code.
71+
For example, to make a map of Cuba we should use ``-RCU``.
72+
Note that in this case, the map will have the exact region of the country.
73+
74+
75+
.. gmtplot::
76+
77+
gmt begin region png
78+
gmt basemap -JM12c -Bxaf -Byaf -RCU
79+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
80+
gmt end show
81+
82+
83+
DCW Collection
84+
==============
85+
86+
Alternative, to make a map of another named region (continents, oceans, seas, islands, etc.) NOT include in the ISO codes you can use the
87+
the three-to-five-character codes of `DCW-Collection <https://github.com/GenericMappingTools/dcw-gmt/tree/master?tab=readme-ov-file#dcw-collections>`_. For example, to make a map of the Mediterranean Sea we should use ``-RIHO28``:
88+
89+
90+
.. gmtplot::
91+
92+
gmt begin region png
93+
gmt basemap -JM12c -Bxaf -Byaf -RIHO28
94+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
95+
gmt end show
96+
97+
98+
Many codes
99+
==========
100+
101+
We could use more than one code to get the region that includes all of them.
102+
For example, if we wish to see all Italy and the Mediterranean Sea, then we should use ``-RIHO28,IT``
103+
104+
.. gmtplot::
105+
106+
gmt begin region png
107+
gmt basemap -JM12c -Bxaf -Byaf -RIHO28,IT
108+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
109+
gmt end show
110+
111+
112+
Modifiers
113+
==========
114+
There are 3 modifiers to sligthy change the region encompassed by the codes that can be used.
115+
In the following examples will be used them to modify the exact region of the Mediterranean Sea (-6.0319/36.2093/30.2662/45.7946).
116+
117+
118+
Modifier +R
119+
+++++++++++
120+
121+
If you want to extend 1 degree the region in all directions, then add ``+R1`` to the code.
122+
This will extend the region to ``-7.0319/37.2093/29.2662/46.7946``.
123+
124+
125+
.. gmtplot::
126+
127+
gmt begin region png
128+
gmt basemap -JM12c -Bxaf -Byaf -RIHO28+R1
129+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
130+
gmt end show
131+
132+
133+
Modifier +r
134+
+++++++++++
135+
136+
You can use the ``+r`` modifier if you instead want the region will be rounded to nearest integer degree.
137+
In the following example the region will be extend to ``-7/37/30/46``.
138+
139+
.. gmtplot::
140+
141+
gmt begin region png
142+
gmt basemap -JM12c -Bxaf -Byaf -RIHO28+r1
143+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
144+
gmt end show
145+
146+
147+
Modifier +e
148+
+++++++++++
149+
150+
Finally, the ``+e`` modifier is like ``+r`` and expands the final region boundaries to be multiples of increment.
151+
However, it ensures that the bounding box extends by at least 0.25 times the increment.
152+
In the following example the region will be extend to ``-7/37/30/47``.
153+
154+
155+
.. gmtplot::
156+
157+
gmt begin region png
158+
gmt basemap -JM12c -Bxaf -Byaf -RIHO28+e1
159+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
160+
gmt end show
161+
162+
163+
Custom expansion
164+
++++++++++++++++
165+
166+
In the previous examples, the expansion was uniformly in all directions.
167+
If you want to expand the region differently in each direction, then you could passed four values
168+
(to expands to the west, east, south and north repectively),
169+
For example use the modifier ``+R1/2/3/4`` to expand the Mediterranean Sea map.
170+
171+
.. gmtplot::
172+
173+
gmt begin region png
174+
gmt basemap -JM12c -Bxaf -Byaf -RIHO28+R1/2/3/4
175+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
176+
gmt end show
177+
178+
179+
Shrink region
180+
+++++++++++++
181+
182+
All the above modifiers can be also use to shrink the area. Just use a negative number.
183+
For example use the modifier ``+R-2`` to shrink the Mediterranean Sea map by two degrees.
184+
185+
.. gmtplot::
186+
187+
gmt begin region png
188+
gmt basemap -JM12c -Bxaf -Byaf -RIHO28+R-3
189+
gmt coast -Glightgray -Swhite -W1/0.5p -N1/0.5p -Clightgray
190+
gmt end show
191+
192+

0 commit comments

Comments
 (0)