Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2539,6 +2539,33 @@ def transform_points(self, src_crs, x, y, z=None, trap=False):
return result


class WinkelTripel(_WarpedRectangularProjection):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do any of the nan handling here like we are doing in the Robinson projection? i.e. should this subclass Robinson instead if it is similar to that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to generate maps containing maps with no problem. Are there other tests for nans that I would need to do?

"""
A Winkel-Tripel projection.

Compromise modified azimuthal projection that is less distorted
and more area-accurate. It is comparable to the Robinson
projection in both appearance and popularity.

The National Geographic Society uses the Winkel-Tripel projection
for most of the maps they produce.
"""

def __init__(self, central_longitude=0.0, globe=None):
globe = globe or Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS)
proj4_params = [('proj', 'wintri'),
('lon_0', central_longitude),
('lat_0', 0.0)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pass in the lat_0 parameter even if 0 is the default, and does that even work, it looks like it is lat_1 in the documentation: https://proj.org/en/9.4/operations/projections/wintri.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lat_0 is required and lat_1 doesn't work. Maybe this is a typo in proj? I'm also not very familiar with that library so maybe I'm hacking a parameter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think lat_0 is required when I tried this out locally. It looks like it may actually be ignored within proj. lat_1 does work for me and is the first standard parallel. For now, I would just remove the lat_0 from this list. In addition, all of our other _WarpedRectangularProjection subclasses also accept the false_easting and false_northing, so could you pipe those through the initializer as well for consistency with the other classes?

Analysis:
All of these produce a pyproj CRS, but there are differences in the WKT which I think the lat_0 indicates isn't being forwarded because it has a "REMARK" at the end. You can also look at the first standard parallel and the first and second are identical, whereas the third (with lat_1) does have the expected 5.

import pyproj
pyproj.CRS.from_proj4("proj=+wintri").to_wkt()
pyproj.CRS.from_proj4("proj=+wintri +lat_0=5").to_wkt()
pyproj.CRS.from_proj4("proj=+wintri +lat_1=5").to_wkt()
'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ID["EPSG",6326]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Winkel Tripel"],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Latitude of 1st standard parallel",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]]'
'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ID["EPSG",6326]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Winkel Tripel"],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Latitude of 1st standard parallel",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]],REMARK["PROJ CRS string: +proj=wintri +lat_0=5"]]'
'PROJCRS["unknown",BASEGEOGCRS["unknown",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ID["EPSG",6326]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Winkel Tripel"],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Latitude of 1st standard parallel",5,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]]'


super().__init__(proj4_params,
central_longitude,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be indented the same amount as the parentheses, see the other classes in this file for an example.

globe=globe)

@property
def threshold(self):
return 1e4


class InterruptedGoodeHomolosine(Projection):
"""
Composite equal-area projection emphasizing either land or
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/cartopy/tests/mpl/test_mpl_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def test_simple_global():
(ccrs.ObliqueMercator, dict(azimuth=90., central_latitude=-22)),
id='ObliqueMercator_rotated',
),
ccrs.WinkelTripel,
])
@pytest.mark.mpl_image_compare(style='mpl20')
def test_global_map(proj):
Expand Down
Loading