Skip to content

Commit d9af3e0

Browse files
committed
coast: Make the 'resolution' parameter more Pythonic
1 parent 8b2a74c commit d9af3e0

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

pygmt/src/coast.py

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
coast - Plot land and water.
33
"""
4+
from typing import Literal
45

56
from pygmt.clib import Session
67
from pygmt.exceptions import GMTInvalidInput
@@ -37,7 +38,13 @@
3738
t="transparency",
3839
)
3940
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
40-
def coast(self, **kwargs):
41+
def coast(
42+
self,
43+
resolution: Literal[
44+
"auto", "full", "high", "intermediate", "low", "crude"
45+
] = "auto",
46+
**kwargs,
47+
):
4148
r"""
4249
Plot continents, shorelines, rivers, and borders on maps.
4350
@@ -75,11 +82,19 @@ def coast(self, **kwargs):
7582
parameter. Optionally, specify separate fills by appending
7683
**+l** for lakes or **+r** for river-lakes, and passing multiple
7784
strings in a list.
78-
resolution : str
79-
**f**\|\ **h**\|\ **i**\|\ **l**\|\ **c**.
80-
Select the resolution of the data set to: (**f**\ )ull,
81-
(**h**\ )igh, (**i**\ )ntermediate, (**l**\ )ow,
82-
and (**c**\ )rude.
85+
resolution
86+
Select the resolution of the GSHHG coastline data set to use. The available
87+
resolutions from highest to lowest are:
88+
89+
- ``"full"`` - Full resolution (may be very slow for large regions).
90+
- ``"high"`` - High resolution (may be slow for large regions).
91+
- ``"intermediate"`` - Intermediate resolution.
92+
- ``"low"`` - Low resolution.
93+
- ``"crude"`` - Crude resolution, for tasks that need crude continent outlines
94+
only.
95+
96+
The default is ``"auto"`` to automatically select the best resolution given the
97+
chosen map scale.
8398
land : str
8499
Select filling or clipping of "dry" areas.
85100
rivers : int, str, or list
@@ -226,5 +241,7 @@ def coast(self, **kwargs):
226241
"""At least one of the following parameters must be specified:
227242
lakes, land, water, rivers, borders, dcw, Q, or shorelines"""
228243
)
244+
if kwargs.get("D") is not None:
245+
kwargs["D"] = kwargs["D"][0]
229246
with Session() as lib:
230247
lib.call_module(module="coast", args=build_arg_list(kwargs))

0 commit comments

Comments
 (0)