matplotlib / matplotlib/basemap

Polar Projection PDF Issue

Open
#256 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
817
Forks
395
PR merge metrics
No merged PRs in 30d

Description

Python 3.4
Conda 3.18.3
Matplotlib 1.5.1
basemap 1.0.7
Adobe Reader XI

Trying to plot a polar projection with a custom shapefile results in an error when opening the PDF in Adobe Reader.

I am creating two orthographic projections (a southern and northern hemisphere).

```
basemaps.append(Basemap(projection='ortho', lon_0=270, lat_0=90., resolution='c', ax=axes[0]))
basemaps.append(Basemap(projection='ortho', lon_0=90, lat_0=-90., resolution='c', ax=axes[1]))
```

I then draw a full world shapefile on each projection:

```
basemap.readshapefile('Earth', 'globe')
...
plt.savefig('amaps.pdf')
```

Everything works fine here and both basemaps display with the proper lines and shapes drawn. However, when downloading the PDF and displaying it in Adobe Acrobat, you will get something like this:
[amap.pdf](https://github.com/matplotlib/matplotlib/files/99791/amap.pdf) (which looks fine if you view it in your browser, but try downloading it and opening it with Adobe Reader). We've determined that the problem arises when the coastline includes lon, lat pairs in the opposite hemisphere from the hemisphere that it is to be drawn in. So if you are drawing the southern hemisphere, you cannot read a shapefile that has lon, lat points in the norther hemisphere, and vise-versa.

Our workaround required creating two separate shapefiles, one for the northern hemisphere and one for the southern. So now it looks like this:

```
# drawing northern hemisphere
if polar and idx == 0:
basemap.readshapefile('Earth_north', 'nh')
elif polar and idx == 1:
# drawing southern hemisphere
basemap.readshapefile('Earth_south', 'sh')
# drawing all other projections
else:
basemap.readshapefile('Earth', 'globe')
```

This works fine but shouldn't be necessary.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with Basemap.readshapefile and plt.savefig using the supplied orthographic projection snippets and PDF. Inspect the shapefile handling and PDF output path for geometries crossing hemispheres. Done means one full-world shapefile renders correctly in both hemispheres when the PDF is opened in Adobe Reader.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.