matplotlib / matplotlib/basemap

Problem using Ortho projection and shadedrelief on a sector of the globe

Open
#429 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
817
Forks
395
PR merge metrics
No merged PRs in 30d

Description

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')

m.drawcoastlines()
m.fillcontinents(color='coral',lake_color='aqua')

# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,420.,60.))
m.drawmapboundary(fill_color='aqua')
```
[![Orthographic projection without shadedrelief background][1]][1]

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][2]][2]

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 I get the same problem.

p.s. This is a copy of a thread that I opened on [stackexchange](https://gis.stackexchange.com/questions/298680/setup-shadedrelief-background-in-basemap-using-a-cropped-orthographic-projection), sorry for the cross-posting!

[1]: https://i.stack.imgur.com/iON27.png
[2]: https://i.stack.imgur.com/oVMAI.png

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the issue's orthographic Basemap example, first without imagery and then with m.shadedrelief(); compare the rendered extent with the llcrnrx, llcrnry, urcrnrx, and urcrnry bounds. Check the shadedrelief and bluemarble entry points and verify that the background is clipped to the requested map region while preserving the existing projection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.