I'm trying to plot a sector of the world in basemap using an orthographic projection and I would like to have a shadedrelief background.

If I don't use shadedrelief everything works fine:

import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

m = Basemap(projection='ortho',lon_0 = 0, lat_0 = 40,
        llcrnrx=-3000000, llcrnry=1000000, urcrnrx=3000000, urcrnry=7000000, 
        resolution = 'l')


# draw parallels and meridians.

Orthographic projection without shadedrelief background

However, when I add the command m.shadedrelief() (after removing the m.drawmapboundary and the m.fillcontinents commands) I get the following graph: Orthographic projection with shadedrelief background

Apparently the problem is that the background is not restricted to the bounding box I set in the basemap command. I tried also with other backgrounds (e.g. bluemarble) but they have the same problem.

Does anyone know how to fix this? I searched online but I didn't found anything unfortunately.


Got the same issue.

my only answer is : get the data from return of bluemarble and crop the data array

im = basemap.bluemarble() data = im.get_array()

modify the data to make it correspond to your need and push it back to the image


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.