Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mollweide projection incorrect ? #2016

Open
PBrockmann opened this issue Mar 22, 2022 · 5 comments
Open

Mollweide projection incorrect ? #2016

PBrockmann opened this issue Mar 22, 2022 · 5 comments

Comments

@PBrockmann
Copy link

PBrockmann commented Mar 22, 2022

I have encountered a problem when drawing polygons from a icosahedral grid with a Mollweide projection only.
image

The same with a Robinson projection.
image

What do I miss ?

I have prepared a notebook with OPeNDAP access to the netcdf file that shows the problem.
https://thredds-su.ipsl.fr/thredds/fileServer/ipsl_thredds/brocksce/gridsCF/cartopy_bug_projection.html
https://thredds-su.ipsl.fr/thredds/fileServer/ipsl_thredds/brocksce/gridsCF/cartopy_bug_projection.ipynb

Tested with cartopy 0.20.2

@greglucas
Copy link
Contributor

There are a lot of open issues relating to Molleweide: https://github.com/SciTools/cartopy/search?q=Mollweide&type=issues
Some of them indicate polygons are getting flipped inside out during the transformation and having issues near the poles. One thought to narrow it down is to try limiting some of your domain and see if that helps at all. Or set alpha=0.5 on the collection to see if you can see through the polygons and see if many are just being covered up by a few.

@PBrockmann
Copy link
Author

Thanks for your interest.
Indeed alpha=0.5 shows that polygons are drawn correctly...
image

Some cells should be not correctly drawn.

@PBrockmann
Copy link
Author

PBrockmann commented Mar 22, 2022

Investigating... I have isolated the polygon that causes the problem. Used add_geometries() to be simpler.

import matplotlib
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
from shapely.geometry.polygon import Polygon

fig = plt.figure(figsize=(20,10))                      
ax1 = plt.subplot(111, projection=ccrs.Mollweide(central_longitude=0))

#==================================
coords = [
(-31, -83),
(-61, -86),
(-180.0, -89.5), 
#(-180.0, -90),
(61, -86)
]
poly = Polygon(coords)

ax1.add_geometries([poly], crs=ccrs.PlateCarree(), facecolor='r', edgecolor='b', alpha=0.2)

ax1.coastlines()
ax1.gridlines()

#==================================
plt.show()

image
Changed with the vertex (-180.0, -89.5) with (-180.0, -90) gives
image

So why is there this overlap when I use (-180.0, -89.5) ?

@greglucas
Copy link
Contributor

It looks like this may be the same issues as #1333 and there does appear to be a PR to fix that: #1334 although I haven't looked at it.

@stephenworsley
Copy link
Contributor

I suspect this may be fixed by OSGeo/PROJ#3082.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants