Package pyproj

Package pyproj

source code

Cython wrapper to provide python interfaces to PROJ.4 ( functions.

Performs cartographic transformations and geodetic computations.

The Proj class can convert from geographic (longitude,latitude) to native map projection (x,y) coordinates and vice versa, or from one map projection coordinate system directly to another. The module variable pj_list is a dictionary containing all the available projections and their descriptions.

The Geod class can perform forward and inverse geodetic, or Great Circle, computations. The forward computation involves determining latitude, longitude and back azimuth of a terminus point given the latitude and longitude of an initial point, plus azimuth and distance. The inverse computation involves determining the forward and back azimuths and distance given the latitudes and longitudes of an initial and terminus point.

Input coordinates can be given as python arrays, lists/tuples, scalars or numpy/Numeric/numarray arrays. Optimized for objects that support the Python buffer protocol (regular python and numpy array objects).


Requirements: python 2.4 or higher.

Example scripts are in 'test' subdirectory of source distribution. The 'test()' function will run the examples in the docstrings.

Contact: Jeffrey Whitaker <

copyright (c) 2006 by Jeffrey Whitaker.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both the copyright notice and this permission notice appear in supporting documentation. THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Version: 1.9.3

performs forward and inverse geodetic, or Great Circle, computations.
performs cartographic transformations (converts from longitude,latitude to native map projection x,y coordinates and vice versa) using proj (
run the examples in the docstrings using the doctest module
source code
transform(p1, p2, x, y, z=None, radians=False)
x2, y2, z2 = transform(p1, p2, x1, y1, z1, radians=False)
source code
  __package__ = 'pyproj'
  pj_ellps = {'APL4.9': {'a': 6378137.0, 'description': 'Appl. P...
  pj_list = {'aea': 'Albers Equal Area', 'aeqd': 'Azimuthal Equi...
  pyproj_datadir = '/Users/jsw/Library/Python/2.7/lib/python/sit...
Function Details

transform(p1, p2, x, y, z=None, radians=False)

source code 

x2, y2, z2 = transform(p1, p2, x1, y1, z1, radians=False)

Transform points between two coordinate systems defined by the Proj instances p1 and p2.

The points x1,y1,z1 in the coordinate system defined by p1 are transformed to x2,y2,z2 in the coordinate system defined by p2.

z1 is optional, if it is not set it is assumed to be zero (and only x2 and y2 are returned).

In addition to converting between cartographic and geographic projection coordinates, this function can take care of datum shifts (which cannot be done using the __call__ method of the Proj instances). It also allows for one of the coordinate systems to be geographic (proj = 'latlong').

If optional keyword 'radians' is True (default is False) and p1 is defined in geographic coordinate (pj.is_latlong() is True), x1,y1 is interpreted as radians instead of the default degrees. Similarly, if p2 is defined in geographic coordinates and radians=True, x2, y2 are returned in radians instead of degrees. if p1.is_latlong() and p2.is_latlong() both are False, the radians keyword has no effect.

x,y and z can be numpy or regular python arrays, python lists/tuples or scalars. Arrays are fastest. For projections in geocentric coordinates, values of x and y are given in meters. z is always meters.

Example usage:

>>> # projection 1: UTM zone 15, grs80 ellipse, NAD83 datum
>>> # (defined by epsg code 26915)
>>> p1 = Proj(init='epsg:26915')
>>> # projection 2: UTM zone 15, clrk66 ellipse, NAD27 datum
>>> p2 = Proj(init='epsg:26715')
>>> # find x,y of Jefferson City, MO.
>>> x1, y1 = p1(-92.199881,38.56694)
>>> # transform this point to projection 2 coordinates.
>>> x2, y2 = transform(p1,p2,x1,y1)
>>> '%9.3f %11.3f' % (x1,y1)
'569704.566 4269024.671'
>>> '%9.3f %11.3f' % (x2,y2)
'569722.342 4268814.027'
>>> '%8.3f %5.3f' % p2(x2,y2,inverse=True)
' -92.200 38.567'
>>> # process 3 points at a time in a tuple
>>> lats = (38.83,39.32,38.75) # Columbia, KC and StL Missouri
>>> lons = (-92.22,-94.72,-90.37)
>>> x1, y1 = p1(lons,lats)
>>> x2, y2 = transform(p1,p2,x1,y1)
>>> xy = x1+y1
>>> '%9.3f %9.3f %9.3f %11.3f %11.3f %11.3f' % xy
'567703.344 351730.944 728553.093 4298200.739 4353698.725 4292319.005'
>>> xy = x2+y2
>>> '%9.3f %9.3f %9.3f %11.3f %11.3f %11.3f' % xy
'567721.149 351747.558 728569.133 4297989.112 4353489.644 4292106.305'
>>> lons, lats = p2(x2,y2,inverse=True)
>>> xy = lons+lats
>>> '%8.3f %8.3f %8.3f %5.3f %5.3f %5.3f' % xy
' -92.220  -94.720  -90.370 38.830 39.320 38.750'
>>> # test datum shifting, installation of extra datum grid files.
>>> p1 = Proj(proj='latlong',datum='WGS84')
>>> x1 = -111.5; y1 = 45.25919444444
>>> p2 = Proj(proj="utm",zone=10,datum='NAD27')
>>> x2, y2 = transform(p1, p2, x1, y1)
>>> "%12.3f %12.3f" % (x2,y2)
' 1402285.991  5076292.423'

Variables Details


{'APL4.9': {'a': 6378137.0,
            'description': 'Appl. Physics. 1965',
            'rf': 298.25},
 'CPM': {'a': 6375738.7,
         'description': 'Comm. des Poids et Mesures 1799',
         'rf': 334.29},
 'GRS67': {'a': 6378160.0,
           'description': 'GRS 67(IUGG 1967)',


{'aea': 'Albers Equal Area',
 'aeqd': 'Azimuthal Equidistant',
 'airy': 'Airy',
 'aitoff': 'Aitoff',
 'alsk': 'Mod. Stererographics of Alaska',
 'apian': 'Apian Globular I',
 'august': 'August Epicycloidal',
 'bacon': 'Bacon Globular',