Color fill error after reprojection

Open
#1,908 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the issue with the supplied ShapelyFeature examples, comparing PlateCarree and Mollweide projections with filled faces and edges-only rendering. Start by tracing Cartopy's ShapelyFeature and reprojection rendering path; done means the filled geometries display correctly in Mollweide without changing the correct edge rendering.

Written by the indexing model from the issue text.

Description

Hello!
I try to fill them with different colors. If I display the data as it is, in the PlateCarree projection, everything is fine.

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader
from cartopy.feature import ShapelyFeature

ax = plt.axes(projection=ccrs.PlateCarree())
    
CM = ShapelyFeature(Reader('CM/10Ma_CM_v7.shp').geometries(),
                        ccrs.PlateCarree(), facecolor='skyblue', edgecolor='silver', linewidths=0.3, zorder=1)
ax.add_feature(CM)
    
CS = ShapelyFeature(Reader('CS/10Ma_CS_v7.shp').geometries(),
                        ccrs.PlateCarree(), facecolor='tan', edgecolor='black', linewidths=0.3, zorder=2)
ax.add_feature(CS)
    
ax.set_global()

ax.gridlines(zorder=4, linewidth=0.1, color='gray', alpha=0.5, linestyle='--')

plt.show()

Figure_1
Then I want to use the Mollweide projection.
ax = plt.axes(projection=ccrs.Mollweide())
Shallow water begins to occupy the entire space.
Figure_2
At the same time, if I colored only edges (facecolor='none'), edges is displayed normally.

CM = ShapelyFeature(Reader('CM/10Ma_CM_v7.shp').geometries(),
                        ccrs.PlateCarree(), facecolor='none', edgecolor='blue', linewidths=0.3, zorder=1)
ax.add_feature(CM)
    
CS = ShapelyFeature(Reader('CS/10Ma_CS_v7.shp').geometries(),
                        ccrs.PlateCarree(), facecolor='none', edgecolor='red', linewidths=0.3, zorder=2)

Figure_3
At first I thought it was due to a reprojection error. But then, when I saw that the edges were drawn correctly, I decided that it might be exactly the error of the facecolor parameter.

Windows 10, Python 3.9, Cartopy 0.20 by https://www.lfd.uci.edu/~gohlke/pythonlibs/

Dominant language
Python
Stars
1.6k
Forks
399
Avg merge
1d 7h
Merged PRs (30d)
14

Contributor guide

Open the contributing guide

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.

More from SciTools/cartopy

All issues in SciTools/cartopy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.