# Lunar terrain

**URL:** <https://forum.generic-mapping-tools.org/t/lunar-terrain/5304>\
**Category:** PyGMT Q&A\
**Created:** [September 11, 2024, 3:30pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304 "2024-09-11T15:30:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcalvis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dcalvis](https://forum.generic-mapping-tools.org/u/dcalvis)\
**Post date:** [September 11, 2024, 3:30pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/1 "2024-09-11T15:30:34Z")

</div>

Hello – I am leading a research group of students seeking to model lunar terrain, starting with craters. We were made aware of pygmt, which we have successfully loaded using Anaconda. As a result we have a Jupyter notebook in which the command

import pygmt

works. Now we want to actually draw pictures and pull down lunar elevation data. We have seen

[https://www.pygmt.org/latest/api/generated/pygmt.datasets.load\_moon\_relief.html](https://www.pygmt.org/latest/api/generated/pygmt.datasets.load_moon_relief.html)

but my ignorance of Python is such that I need some explicit code to get us started. Grateful for any pointers!

David Calvis  
Baldwin Wallace University

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [September 11, 2024, 5:59pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/2 "2024-09-11T17:59:28Z")

</div>

[https://www.pygmt.org/latest/tutorials/index.html](https://www.pygmt.org/latest/tutorials/index.html)

---

<div class="post-metadata">

**Author:** ![dcalvis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dcalvis](https://forum.generic-mapping-tools.org/u/dcalvis)\
**Post date:** [September 11, 2024, 6:15pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/3 "2024-09-11T18:15:12Z")

</div>

Very cool, thank you!

---

<div class="post-metadata">

**Author:** ![jjg](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jjg/32/2822_2.png) [@jjg](https://forum.generic-mapping-tools.org/u/jjg)\
**Post date:** [September 11, 2024, 7:56pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/4 "2024-09-11T19:56:37Z")

</div>

An alternative lunar colour-scheme by [Paul Naylor](http://seaviewsensing.com/pub/cpt-city/pn/index.html)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [September 11, 2024, 9:48pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/5 "2024-09-11T21:48:29Z")

</div>

Needs a little tweak on the low end

```auto
julia> grdimage("@moon_relief_01d", cmap="moon.cpt", figname="moon", show=1)

```

 ![moon](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/2/25599768d1694bd6cf8565f9e055c85d4a1d7f54.png)

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [September 11, 2024, 10:36pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/6 "2024-09-11T22:36:01Z")

</div>

Hello @dcalvis,

welcome to the GMT forum 🙂 and great you want to use PyGMT 🚀 !

GMT provides several remote datasets ([Remote datasets — Remote Datasets documentation](https://www.generic-mapping-tools.org/remote-datasets/)), and PyGMT offers functions to load these remote datasets into a xarray.DataArray. For the luna relief, you can use [pygmt.datasets.load\_moon\_relief — PyGMT](https://www.pygmt.org/v0.13.0/api/generated/pygmt.datasets.load_moon_relief.html).

For plotting the grid, your students can follow the PyGMT tutorial [Plotting Earth relief — PyGMT](https://www.pygmt.org/v0.13.0/tutorials/advanced/earth_relief.html). It is actually using the Earth relief, but it should work in the same way for the luna relief grid (there may be some differences regarding the available resolutions of the grid).

---

<div class="post-metadata">

**Author:** ![dcalvis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dcalvis](https://forum.generic-mapping-tools.org/u/dcalvis)\
**Post date:** [September 11, 2024, 11:55pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/7 "2024-09-11T23:55:05Z")

</div>

Thanks to everyone! This is very helpful!

As a followup, how please could I use PyGMT to draw a beautiful, detailed gray-scale relief of the Tycho Crater, for example? I tried it using the coordinates of the crater available at Wikipedia, etc. I tried to reduce the resolution as much as possible. But it did not look good at all; in fact, I could not even recognize the crater. Again, thanks to everyone.

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [September 12, 2024, 8:36am UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/8 "2024-09-12T08:36:08Z")

</div>

I just tried this, and I found that the lunar relief is only available for the east and west sides for resolutions `06m` or lower. I did not find a note in the docs so far (will check this in more detail at a later time).

```python
import pygmt as gmt
from pygmt.datasets import load_moon_relief

region=[-180, 180, -90, 90]
grid = load_moon_relief(region=region, resolution="06m", registration="gridline")

fig = gmt.Figure()
fig.basemap(region=region, projection="N10c", frame=True)
fig.grdimage(grid=grid, cmap="@moon_relief.cpt")
fig.colorbar(frame=True)
fig.plot(x=-11.36, y=-43.31, style="x0.5c", pen="2p,darkorange")
fig.show()

```

 ![luna_06m](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/7/78b9c63527f2fb574f223b0298afa87cd88855ba.jpeg)

```python
region=[-180, 180, -90, 90]
grid = load_moon_relief(region=region, resolution="05m", registration="gridline")

fig = gmt.Figure()
fig.basemap(region=region, projection="N10c", frame=True)
fig.grdimage(grid=grid, cmap="@moon_relief.cpt")
fig.colorbar(frame=True)
fig.plot(x=-11.36, y=-43.31, style="x0.5c", pen="2p,darkorange")
fig.show()

```

 ![luna_05m](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/7/7471f47ce27d6edf529f515fdc0dd215a02da57c.jpeg)

```python
region=[-15, -5, -50, -40]
grid = load_moon_relief(region=region, resolution="06m", registration="gridline")

fig = gmt.Figure()
fig.basemap(region=region, projection="M10c", frame=True)
fig.grdimage(grid=grid, cmap="grayC")
fig.colorbar(frame=True)
fig.plot(x=-11.36, y=-43.31, style="x1c", pen="4p,darkorange")
fig.show()

```

 ![luna_local](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/d/d7d82a57e70d20121a6e06f3bf46e2ef8f88179d.png)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [September 12, 2024, 10:32am UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/9 "2024-09-12T10:32:55Z")

</div>

I cannot reproduce that from julia (and hence from CLI). Tried 06m, 05m and 04m and all run fine.

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [September 12, 2024, 10:47am UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/10 "2024-09-12T10:47:16Z")

</div>

No half-moon issue in pygmt 0.12 **after running the test in CLI**

it seems CLI gmt downloads and blends two halves into one 5-min grid, the western and the eastern. While only the eastern part is present on the half-moon plot.

```auto
gmt grdimage @moon_relief_05m_g -JN10c -BWSen -Ba -C@moon_relief.cpt -png lunar_terrain
grdblend [NOTICE]: Remote data courtesy of GMT data server oceania [http://oceania.generic-mapping-tools.org]

grdblend [NOTICE]: LOLA Moon Relief at 05x05 arc minutes reduced by Gaussian Cartesian filtering (7.1 km fullwidth) [Mazarico et al., 2013].
grdblend [NOTICE]: -> Download 180x180 degree grid tile (moon_relief_05m_g): S90W180
grdblend [NOTICE]: -> Download 180x180 degree grid tile (moon_relief_05m_g): S90E000

```

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [September 12, 2024, 10:49am UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/11 "2024-09-12T10:49:46Z")

</div>

Yes, I am also confused by this. Did not faced such an issue when playing with the new remote datasets some time ago. Will check this in detail later (also if there is something wrong on my side); currently busy with other tasks 🙂. At least good to know that it work with the Julia wrapper.

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [September 12, 2024, 12:31pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/12 "2024-09-12T12:31:55Z")

</div>

@mkononets Under which operating system did you test it? For Linux, your code line gives my a correct plot, but under Windows I still get a plot showing only the east part.

---

<div class="post-metadata">

**Author:** ![dcalvis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dcalvis](https://forum.generic-mapping-tools.org/u/dcalvis)\
**Post date:** [September 12, 2024, 12:46pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/13 "2024-09-12T12:46:03Z")

</div>

Thank you,everyone! Regarding the resolution of the Tycho image, my hope had been that PyGMT would allow us to plot, download, and analyze elevation data for such craters at the resolution of our choice. Originally we were looking at [Orbital Data Explorer - Granular Data System - LRO LOLA RDR Query Tool](https://oderest.rsl.wustl.edu/GDSWeb/GDSLOLARDR.html), but that approach would require us to store tons of data for each crater that we analyze. Also, a single query could result in 10^6 data points, way too much to fit with splines, for example. So we thought that PyGMT could be the answer to all this. However, in the case of Tycho, for example, we’d need better resolution to really dig in and start modeling the surface of the crater. I feel that if we could pull in higher resolution (but not too high!), then we would have the tool that we need. Again I am very grateful for this help.

**Update** I was able to zoom in and apply resolution=“15s”, resulting in this. Not sharp enough yet for our needs, but certainly better. Again thanks everyone.

 ![Untitled](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/1/17e4c49e1692e8bb457e70d30cb230efdd13153f.jpeg)

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [September 12, 2024, 12:51pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/14 "2024-09-12T12:51:18Z")

</div>

Linux, gmt and pygmt in a conda environment.

---

<div class="post-metadata">

**Author:** ![dcalvis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dcalvis](https://forum.generic-mapping-tools.org/u/dcalvis)\
**Post date:** [September 12, 2024, 1:04pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/15 "2024-09-12T13:04:47Z")

</div>

Hello @mkononets Thanks for your contributions. Did I mention that we are running Python in Google Colab? It allows for a level of collaboration and one can install PyGMT in Colab at runtime. That said, would you suggest some other platform? Again thanks.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [September 12, 2024, 1:26pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/16 "2024-09-12T13:26:19Z")

</div>

> [@dcalvis](#):
>
> Not sharp enough yet for our needs, but certainly better.

It will look sharper if you shade illuminate it.

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [September 12, 2024, 2:42pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/17 "2024-09-12T14:42:50Z")

</div>

Thanks @mkononets for this information.

I now tested the other planetary remote datasets (Venus, Mars, and Mercury), and there the plots are complete for resolutions equal or higher than “05m”. I also figured out that it works for pixel registration, but not for gridline registration. Details see [Remote dataset moon relief: Only east side is plotted for resolution \>= "05m" and gridline registration · Issue #8580 · GenericMappingTools/gmt · GitHub](https://github.com/GenericMappingTools/gmt/issues/8580).

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [September 12, 2024, 3:47pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/18 "2024-09-12T15:47:23Z")

</div>

as Joaquim pointed out, that bad grid might get stuck in the local cache

does `gmt clear cache` work both for CLI and for pygmt? Is there any specific mechanism for pygmt?

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [September 12, 2024, 3:51pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/19 "2024-09-12T15:51:41Z")

</div>

> [@dcalvis](#):
>
> we are running Python in Google Colab? It allows for a level of collaboration and one can install PyGMT in Colab at runtime. That said, would you suggest some other platform?

no suggestions on this matter, I have never really used any of these collaboration software.

---

<div class="post-metadata">

**Author:** ![yvonnefroehlich](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yvonnefroehlich/32/5064_2.png) [@yvonnefroehlich](https://forum.generic-mapping-tools.org/u/yvonnefroehlich)\
**Post date:** [September 12, 2024, 8:37pm UTC](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304/20 "2024-09-12T20:37:12Z")

</div>

So, after deleting all downloaded remote dataset data, running “gmt clear cache”, and restarting my laptop, it finally works correctly for me, and the moon relief is plotted completely for all resolutions and both registrations. Thanks for your suggestions and help!

[Next page](https://forum.generic-mapping-tools.org/t/lunar-terrain/5304.md?page=2)
