-
Notifications
You must be signed in to change notification settings - Fork 369
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
Oceans (10m resolution) fill the whole plot when using TransverseMercator with central_longitude=15.0 #1613
Comments
Looks similar to behavior seen in #1578 . I appreciate the detailed testing here. Whoever debugs this (maybe me eventually), will probably start needing to go through polygon by polygon to see what's failing and why. Out of curiosity, do you have fiona installed? In #1578, the error was solved/worked-around by installing fiona and relying on that to read in the shapefile data rather than pyshp. |
I've not used fiona before so maybe I got this wrong, but it looks to me like I got the exact same result:
By the way, when I said that I expected the Baltic sea, that was when I had this line included I had removed it from the minimal testcase so with the minimal testcase you would expect to see most of the world instead. Anyway, looking like fiona doesn't help, unless I did something wrong above. |
I don't know if it's of any help, but when trying all possible non-very-distorting projections to find an alternative projection to use, I also reproduced the problem with |
This is a problem for more than the ocean shapefiles. import cartopy.crs as ccrs
import matplotlib.pyplot as plt
latlon_crs_plt = ccrs.PlateCarree()
tranmerc_crs_plt = ccrs.TransverseMercator(central_longitude=0., approx=False)
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(1, 1, 1, projection=tranmerc_crs_plt)
ax.coastlines()
plt.show() produces: import cartopy.crs as ccrs
import matplotlib.pyplot as plt
latlon_crs_plt = ccrs.PlateCarree()
tranmerc_crs_plt = ccrs.TransverseMercator(central_longitude=15., approx=False)
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(1, 1, 1, projection=tranmerc_crs_plt)
ax.coastlines()
plt.show() produces: |
tl;drThere are rings and holes in lat-lon space that transverse Mercator projects to infinity. Geometry coordinates which fall in the rings and holes are projected to infinity. I suspect cartopy improperly handles infinite coordinates when constructing geometries in the projected space. A few things going on here
|
@kdpenner, PRs are certainly welcome! I'm not sure if this helps, but this was a pretty good start of fixing the regions/holes if you want to dig into that code as well. |
@greglucas Sure, I'll look at this. I don't know how generalizable my hack is---I've tuned some of the parameters---though it does look similar to the one in the PR comment. |
Description
When plotting oceans (resolution "10m") with projection TransverseMercator(central_longitude=15.0), the whole plot turns blue.
I have understood that ocean polygons are complicated and upgrading to 0.18 made resolution "50m" work, but "10m" still causes the whole plot to be blue.
I've tested various values for central_longitude. There is no bug for values between 10.0 and 12.0. Everything is blue between 12.5 and 19.0, except for 18.0 that for some reason seems to work. I've also tested approx=False and approx=True and that makes no observable difference.
TransverseMercator(central_longitude=15.0) (with some additional parameters) is the official projection for Sweden which makes that particular value interesting.
Code to reproduce
A minimal testcase:
Expected,
The Baltic Sea, and the North Sea
Actually
Blue
Windows 10
Cartopy version
cartopy.version is '0.18.0'
Installed with anaconda/conda which calls the package 0.18.0
Python version
(base) c:>python --version
Python 3.7.8
The text was updated successfully, but these errors were encountered: