The projection_wrapper Module

This Python 3.11 module implements a wrapper for map projections.

  • Alexander Raichev (AR), 2013-01-25: Refactored code from release 0.3.

NOTE:

All lengths are measured in meters and all angles are measured in radians unless indicated otherwise. By ‘ellipsoid’ below, I mean an oblate ellipsoid of revolution.

class rhealpixdggs.projection_wrapper.Projection(ellipsoid=<rhealpixdggs.ellipsoids.Ellipsoid object>, proj=None, **kwargs)

Bases: object

Represents a map projection of a given ellipsoid.

INSTANCE ATTRIBUTES:

  • ellipsoid - An ellipsoid (Ellipsoid instance) to project.

  • proj - The name (string) of the map projection, either a valid PROJ.4 projection name or a valid homemade projection name.

  • kwargs - Keyword arguments (dictionary) needed for the projection’s definition, but not for the definition of the ellipsoid. For example, these could be {‘north_square’:1, ‘south_square’: 2} for the rhealpix projection.

EXAMPLES:

>>> from rhealpixdggs.ellipsoids import WGS84_ELLIPSOID
>>> f = Projection(ellipsoid=WGS84_ELLIPSOID, proj='rhealpix', north_square=1, south_square=0)
>>> print(tuple(x.tolist() for x in my_round(f(0, 30), 15)))
(0.0, 3740232.8933662786)
>>> f = Projection(ellipsoid=WGS84_ELLIPSOID, proj='cea')
>>> print(my_round(f(0, 30), 15))
(0.0, 3171259.315518537)

NOTES:

When accessing a homemade map projection assume that it can be called via a function g(a, e), where a is the major radius of the ellipsoid to be projected and e is its eccentricity. The output of g should be a function object of the form f(u, v, radians=False, inverse=False). For example, see the healpix() function in pj_healpix.py.