@@ -1862,6 +1862,115 @@ def __init__(self):
18621862 self .bounds = [- 5242.32 , 1212512.16 , 1589155.51 , 2706796.21 ]
18631863
18641864
1865+ class HEALPix (Projection ):
1866+ """
1867+ Hierarchical Equal Area isoLatitude Pixelisation (HEALPix) of a 2-sphere is an
1868+ algorithm for pixelisation of the 2-sphere based on subdivision of a distorted
1869+ rhombic dodecahedron. The HEALPix projection is area preserving and can be used
1870+ with a spherical and ellipsoidal model. It was initially developed for mapping
1871+ cosmic background microwave radiation.
1872+
1873+ """
1874+ _wrappable = True
1875+
1876+ def __init__ (self , central_longitude = 0 , globe = None ):
1877+ """
1878+ Parameters
1879+ ----------
1880+ central_longitude: optional
1881+ The true longitude of the central meridian in degrees.
1882+ Defaults to 0.
1883+
1884+ globe: optional
1885+ An instance of :class:`cartopy.crs.Globe`. If omitted, a default
1886+ globe with a spherical radius of 6370997 meters is created.
1887+ """
1888+ proj4_params = [('proj' , 'healpix' ),
1889+ ('lon_0' , central_longitude )]
1890+ super ().__init__ (proj4_params , globe = globe )
1891+ # Defaults to the PROJ sphere with semimajor axis 6370997m
1892+ w = (self .globe .semimajor_axis or 6370997 ) * np .pi
1893+ h = w / 2
1894+ self .bounds = [- w , w , - h , h ]
1895+ self ._threshold = w / 1e4
1896+
1897+ self ._boundary = sgeom .LinearRing (
1898+ [(- w , h / 2 ), (- 3 / 4 * w , h ), (- w / 2 , h / 2 ), (- w / 4 , h ), (0 , h / 2 ),
1899+ (w / 4 , h ), (w / 2 , h / 2 ), (3 / 4 * w , h ), (w , h / 2 ),
1900+ (w , - h / 2 ), (3 / 4 * w , - h ), (w / 2 , - h / 2 ), (w / 4 , - h ), (0 , - h / 2 ),
1901+ (- w / 4 , - h ), (- w / 2 , - h / 2 ), (- 3 / 4 * w , - h ), (- w , - h / 2 ), (- w , h / 2 )])
1902+
1903+ @property
1904+ def boundary (self ):
1905+ return self ._boundary
1906+
1907+
1908+ class RHEALPix (Projection ):
1909+ """
1910+ Also known as rHEALPix in PROJ, this projection is an extension of the
1911+ HEALPix projection to present rectangles, rather than triangles, at the
1912+ north and south poles.
1913+
1914+ Parameters
1915+ ----------
1916+ central_longitude: optional
1917+ The true longitude of the central meridian in degrees.
1918+ Defaults to 0.
1919+ north_square : int
1920+ The position for the north pole square. Must be one of 0, 1, 2 or 3.
1921+ 0 would have the north pole square aligned with the left-most square,
1922+ and 3 would be aligned with the right-most.
1923+ south_square : int
1924+ The position for the south pole square. Must be one of 0, 1, 2 or 3.
1925+ """
1926+ _wrappable = True
1927+
1928+ def __init__ (self , central_longitude = 0 , north_square = 0 , south_square = 0 , globe = None ):
1929+ valid_square_pos = [0 , 1 , 2 , 3 ]
1930+ if north_square not in valid_square_pos :
1931+ raise ValueError (f'north_square must be one of { valid_square_pos } ' )
1932+ if south_square not in valid_square_pos :
1933+ raise ValueError (f'south_square must be one of { valid_square_pos } ' )
1934+
1935+ proj4_params = [('proj' , 'rhealpix' ),
1936+ ('north_square' , north_square ),
1937+ ('south_square' , south_square ),
1938+ ('lon_0' , central_longitude )]
1939+ super ().__init__ (proj4_params )
1940+
1941+ # Defaults to the PROJ sphere with semimajor axis 6370997m
1942+ w = (self .globe .semimajor_axis or 6370997 ) * np .pi
1943+ h = 3 / 4 * w
1944+ box_h = w / 4
1945+ self .bounds = [- w , w , - h , h ]
1946+ self ._threshold = w / 1e4
1947+
1948+ self ._boundary = sgeom .LinearRing ([
1949+ # Left edge
1950+ (- w , box_h ),
1951+ # Cut-out for the north square
1952+ (- w + north_square * w / 2 , box_h ),
1953+ (- w + north_square * w / 2 , h ),
1954+ (- w + (north_square + 1 ) * w / 2 , h ),
1955+ (- w + (north_square + 1 ) * w / 2 , box_h ),
1956+ # Right edge
1957+ (w , box_h ),
1958+ (w , - box_h ),
1959+ # Cut-out for the south square
1960+ (- w + (south_square + 1 ) * w / 2 , - box_h ),
1961+ (- w + (south_square + 1 ) * w / 2 , - h ),
1962+ (- w + south_square * w / 2 , - h ),
1963+ (- w + south_square * w / 2 , - box_h ),
1964+ # Left edge
1965+ (- w , - box_h ),
1966+ (- w , box_h )
1967+ ])
1968+
1969+ @property
1970+ def boundary (self ):
1971+ return self ._boundary
1972+
1973+
18651974class LambertAzimuthalEqualArea (Projection ):
18661975 """
18671976 A Lambert Azimuthal Equal-Area projection.
0 commit comments