Simon Toogood
Simon Toogood

Reputation: 25

Location of background image incorrect using Cartopy for the Moon

I'm trying to plot a map of the Moon in the AzimuthalEquidistant projection, with a single point at the lat/long of Mare Orientale. When I try to do this the plotted point is directly above Orientale, but the projection should be centred on it.

I got the background image from here: https://astrogeology.usgs.gov/search/map/Moon/LRO/LROC_WAC/Lunar_LRO_LROC-WAC_Mosaic_global_100m_June2013 and I believe it is in the PlateCarree projection.

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

olat = -19.8304 
olon = 264.757

moon = ccrs.Globe(semimajor_axis=1738100, semiminor_axis=1738100, ellipse=None)
pc = ccrs.PlateCarree(globe=moon)
ae = ccrs.AzimuthalEquidistant(olon, olat, globe=moon)

fig = plt.figure()
ax = plt.subplot(111, projection=ae)
bg = Image.open('moon2.jpeg')
plt.imshow(bg, extent=(-180,180,-90,90), transform=pc)
gl = ax.scatter(olon, olat, transform=pc)
ax.set_global()
plt.show()

Incorrect plot of the Moon

Plotting everything in the PlateCarree projection, however, the point and Orientale line up perfectly

enter image description here

I redefined the globe Cartopy uses to be the Moon's ellipsoid, which made no difference and I know the lat/long to be correct as everything lines up when using the PlateCarree projection.

Upvotes: 1

Views: 340

Answers (1)

swatchai
swatchai

Reputation: 18772

Since your code is not complete, I have to use my own for the missing parts. The complete code is as follows.

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

olat = -19.8304 
olon = 264.757

moon = ccrs.Globe(semimajor_axis=1738100, semiminor_axis=1738100, ellipse=None)
pc = ccrs.PlateCarree(globe=moon)
ae = ccrs.AzimuthalEquidistant(olon, olat, globe=moon)

fig = plt.figure()
ax = plt.subplot(111, projection=ae)

image = plt.imread('./images/Moon_LRO_LROC-WAC_Mosaic_global_1024.jpg')

# Use ax.imshow() instead of plt.imshow() to get proper projection
ax.imshow(image, extent=(-180,180,-90,90), transform=pc)

gl = ax.scatter(olon, olat, color="red", transform=pc)
ax.set_global()
plt.show()

The output seems OK now. Therefore, your line of code:

plt.imshow(image, extent=(-180,180,-90,90), transform=pc)

is the error.

moon1

Upvotes: 2

Related Questions