Goose
Goose

Reputation: 61

Is Cartopy capable of plotting georeferenced data from another planet (e.g., Mars, the Moon)?

I'm working with several data sets from the Moon and Mars (topography, crustal thickness) and was wondering if Cartopy can manipulate these data given the reference ellipsoids are different. Do custom ellipsoids need to be created, or are they built in to Cartopy?

Upvotes: 3

Views: 446

Answers (1)

Goose
Goose

Reputation: 61

I figured out how to do this on my own. Here's the solution I came up with...

Step 1

Import Cartopy...

import cartopy.crs as ccrs

After importing Cartopy and loading your data set, you need to change Cartopy's Globe class such that it does not use the WGS84 ellipse. Simply define new semi-major and semi-minor axes and tell Cartopy to refrain from using a terrestrial ellipse.

img_globe = ccrs.Globe(semimajor_axis = semimajor, semiminor_axis = semiminor, ellipse = None)

Step 2

Next, choose a map projection for plotting and identify your data's format. I decided to plot my data using a Mollweide coordinate system and found my data is defined in the Plate Carree coordinate system. Now we can define the map projection and coordinate system for the data using the new Globe class defined above.

projection = ccrs.Mollweide(globe = img_globe)
data_crs   = ccrs.PlateCarree(globe = img_globe)

Step 3

Lastly, plot your data using standard Matplotlib syntax with two important caveats. First create axes that implement the map projection.

fig = plt.figure(figsize = (6,6))
ax  = plt.axes(projection = projection)

When plotting the data, you have to inform Matplotlib how your data are formatted using the transform argument.

ax.imshow(data, extent = extent, cmap = 'viridis', transform = data_crs)

The end result looks like this...

Mercury's crustal thickness map

Upvotes: 3

Related Questions