pyproj.Proj

Package pyproj :: Class Proj |

# Class Proj

    object --+
             |
       ??.Proj --+
                 |
                Proj

performs cartographic transformations (converts from longitude,latitude to native map projection x,y coordinates and vice versa) using proj (http://trac.osgeo.org/proj/).

A Proj class instance is initialized with proj map projection control parameter key/value pairs. The key/value pairs can either be passed in a dictionary, or as keyword arguments, or as a proj4 string (compatible with the proj command). See http://www.remotesensing.org/geotiff/proj_list for examples of key/value pairs defining different map projections.

Calling a Proj class instance with the arguments lon, lat will convert lon/lat (in degrees) to x/y native map projection coordinates (in meters). If optional keyword 'inverse' is True (default is False), the inverse transformation from x/y to lon/lat is performed. If optional keyword 'radians' is True (default is False) lon/lat are interpreted as radians instead of degrees. If optional keyword 'errcheck' is True (default is False) an exception is raised if the transformation is invalid. If errcheck=False and the transformation is invalid, no exception is raised and 1.e30 is returned. If the optional keyword 'preserve_units' is True, the units in map projection coordinates are not forced to be meters.

Works with numpy and regular python array objects, python sequences and scalars.

Instance Methods
__call__(self, *args, **kw) Calling a Proj class instance with the arguments lon, lat will convert lon/lat (in degrees) to x/y native map projection coordinates (in meters). |
is_geocent(self) returns True if projection in geocentric (x/y) coordinates |
is_latlong(self) returns True if projection in geographic (lon/lat) coordinates |
to_latlong(self) returns an equivalent Proj in the corresponding lon/lat coordinates. |
Inherited from `unreachable.Proj`: `__reduce__` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__init__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Static Methods
a new object with type S, a subtype of T |
__new__(self, projparams=None, preserve_units=False, **kwargs) initialize a Proj class instance. |

Properties
Inherited from `unreachable.Proj`: `proj_version`, `srs` Inherited from `object`: `__class__`

Method Details

### __call__(self, *args, **kw) (Call operator) |
Calling a Proj class instance with the arguments lon, lat will convert lon/lat (in degrees) to x/y native map projection coordinates (in meters). If optional keyword 'inverse' is True (default is False), the inverse transformation from x/y to lon/lat is performed. If optional keyword 'radians' is True (default is False) the units of lon/lat are radians instead of degrees. If optional keyword 'errcheck' is True (default is False) an exception is raised if the transformation is invalid. If errcheck=False and the transformation is invalid, no exception is raised and 1.e30 is returned. Inputs should be doubles (they will be cast to doubles if they are not, causing a slight performance hit). Works with numpy and regular python array objects, python sequences and scalars, but is fastest for array objects.

### __new__(self, projparams=None, preserve_units=False, **kwargs) Static Method |
initialize a Proj class instance. Proj4 projection control parameters must either be given in a dictionary 'projparams' or as keyword arguments. See the proj documentation (http://trac.osgeo.org/proj/) for more information about specifying projection parameters. Example usage:
    >>> from pyproj import Proj
    >>> p = Proj(proj='utm',zone=10,ellps='WGS84') # use kwargs
    >>> x,y = p(-120.108, 34.36116666)
    >>> 'x=%9.3f y=%11.3f' % (x,y)
    'x=765975.641 y=3805993.134'
    >>> 'lon=%8.3f lat=%5.3f' % p(x,y,inverse=True)
    'lon=-120.108 lat=34.361'
    >>> # do 3 cities at a time in a tuple (Fresno, LA, SF)
    >>> lons = (-119.72,-118.40,-122.38)
    >>> lats = (36.77, 33.93, 37.62 )
    >>> x,y = p(lons, lats)
    >>> 'x: %9.3f %9.3f %9.3f' % x
    'x: 792763.863 925321.537 554714.301'
    >>> 'y: %9.3f %9.3f %9.3f' % y
    'y: 4074377.617 3763936.941 4163835.303'
    >>> lons, lats = p(x, y, inverse=True) # inverse transform
    >>> 'lons: %8.3f %8.3f %8.3f' % lons
    'lons: -119.720 -118.400 -122.380'
    >>> 'lats: %8.3f %8.3f %8.3f' % lats
    'lats:   36.770   33.930   37.620'
    >>> p2 = Proj('+proj=utm +zone=10 +ellps=WGS84') # use proj4 string
    >>> x,y = p2(-120.108, 34.36116666)
    >>> 'x=%9.3f y=%11.3f' % (x,y)
    'x=765975.641 y=3805993.134'
    >>> p = Proj(init="epsg:32667")
    >>> 'x=%12.3f y=%12.3f (meters)' % p(-114.057222, 51.045)
    'x=-1783486.760 y= 6193833.196 (meters)'
    >>> p = Proj("+init=epsg:32667",preserve_units=True)
    >>> 'x=%12.3f y=%12.3f (feet)' % p(-114.057222, 51.045)
    'x=-5851322.810 y=20320934.409 (feet)'
    >>> p = Proj(proj='hammer') # hammer proj and inverse
    >>> x,y = p(-30,40)
    >>> 'x=%12.3f y=%12.3f' % (x,y)
    'x=-2711575.083 y= 4395506.619'
    >>> lon,lat = p(x,y,inverse=True)
    >>> 'lon=%9.3f lat=%9.3f (degrees)' % (lon,lat)
    'lon=  -30.000 lat=   40.000 (degrees)'
Returns: a new object with type S, a subtype of T Overrides: object.__new__

### is_geocent(self) |
returns True if projection in geocentric (x/y) coordinates Overrides: unreachable.Proj.is_geocent

### is_latlong(self) |
returns True if projection in geographic (lon/lat) coordinates Overrides: unreachable.Proj.is_latlong

### to_latlong(self) |
returns an equivalent Proj in the corresponding lon/lat coordinates. (see pj_latlong_from_proj() in the Proj.4 C API) Overrides: unreachable.Proj.to_latlong