# Isolating a country with topographic data

**URL:** <https://forum.generic-mapping-tools.org/t/isolating-a-country-with-topographic-data/2800>\
**Category:** PyGMT Q&A\
**Created:** [April 12, 2022, 7:04pm UTC](https://forum.generic-mapping-tools.org/t/isolating-a-country-with-topographic-data/2800 "2022-04-12T19:04:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spagettnet](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/spagettnet/32/2165_2.png) [@spagettnet](https://forum.generic-mapping-tools.org/u/spagettnet)\
**Post date:** [April 12, 2022, 7:04pm UTC](https://forum.generic-mapping-tools.org/t/isolating-a-country-with-topographic-data/2800/1 "2022-04-12T19:04:58Z")

</div>

First time working with map data, so pardon failures in terminology.

I looked through this forum/the internet and I couldn’t find this usage of GMT, through I’m sure it has been done. Sorry if this is a duplicate post…

I am trying to create a map consisting of just the country outline with elevation data inside. (ie Elevation data inside the Romania border, just transparent (or white) outside).

Below is my best attempt, but notice there is some extra land included near the bottom left. Also, I’d like this to be flexible for any country, so I don’t want to have to figure out which country codes to white-out with the `dcw` option every time I want to make one of these maps.

```auto
import pygmt
fig = pygmt.Figure()

# Load sample earth relief data
region = "RO+r1"
fig.basemap(region=region, projection="M3i", frame=True)

grid = pygmt.datasets.load_earth_relief(resolution="30s", region=region,)
fig = pygmt.Figure()
fig.grdimage(grid=grid, projection="M3i")

#fig.grdcontour(grid=grid)
fig.coast(
    region=region,
    water='white',
    dcw="SK,XK,MD,BG,UA,HU,RS+gWhite"
)
fig.show()

```

 ![](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/0/0fc4f5c188be12eabd3f01e9707bef0b6a718f57.jpeg)

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [April 12, 2022, 9:18pm UTC](https://forum.generic-mapping-tools.org/t/isolating-a-country-with-topographic-data/2800/2 "2022-04-12T21:18:39Z")

</div>

With pure gmt it is :

```auto
gmt begin test png
gmt coast -ERO+c -JM10c
gmt grdimage @earth_relief_01m
gmt coast -Q
gmt end show

```

I assume all the steps are the same in pygmt somehow.

1. Use `coast` to **clip** the country you want
2. Use `grdimage` to plot the topography (_@earth\_relief\_XX_)
3. Quit the clip

So instead of plotting a rectangular region and white-out all countries, plot only `region="RO"`

 ![test](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/5/5c1e5cb5682178b426d980a9da6ac83df1865f02.png)

---

<div class="post-metadata">

**Author:** ![spagettnet](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/spagettnet/32/2165_2.png) [@spagettnet](https://forum.generic-mapping-tools.org/u/spagettnet)\
**Post date:** [April 12, 2022, 10:05pm UTC](https://forum.generic-mapping-tools.org/t/isolating-a-country-with-topographic-data/2800/3 "2022-04-12T22:05:21Z")

</div>

Great! Just what I needed.
