Package pyproj :: Class Proj

Class Proj

source code

object --+    
         |    
_proj.Proj --+
             |
            Proj

performs cartographic transformations (converts from longitude,latitude to native map projection x,y coordinates and vice versa) using proj (https://github.com/OSGeo/proj.4/wiki).

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).
source code
 
definition_string(self)
Returns formal definition string for projection
source code
 
is_geocent(self)
returns True if projection in geocentric (x/y) coordinates
source code
 
is_latlong(self)
returns True if projection in geographic (lon/lat) coordinates
source code
 
to_latlong(self)
returns an equivalent Proj in the corresponding lon/lat coordinates.
source code

Inherited from _proj.Proj: __reduce__, __repr__, to_latlong_def

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __reduce_ex__, __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.
source code
Properties

Inherited from _proj.Proj: proj_version, srs

Inherited from object: __class__

Method Details

__call__(self, *args, **kw)
(Call operator)

source code 

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

source code 

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 (https://github.com/OSGeo/proj.4/wiki) 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)'
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

definition_string(self)

source code 

Returns formal definition string for projection

>>> Proj('+init=epsg:4326').definition_string()
' +units=m +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0'
>>>
Overrides: _proj.Proj.definition_string

is_geocent(self)

source code 

returns True if projection in geocentric (x/y) coordinates

Overrides: _proj.Proj.is_geocent

is_latlong(self)

source code 

returns True if projection in geographic (lon/lat) coordinates

Overrides: _proj.Proj.is_latlong

to_latlong(self)

source code 

returns an equivalent Proj in the corresponding lon/lat coordinates. (see pj_latlong_from_proj() in the Proj.4 C API)

Overrides: _proj.Proj.to_latlong