Previous topic


Next topic


This Page


The proj module provides support for coordinate reference system transformation and geometry reprojection.

class geoscript.proj.Projection

A cartographic projection or coordinate reference system.

proj is a string that identifies the coordinate reference system (eg. an epsg code):

>>> prj = Projection('epsg:4326')

Alternatively proj may be specified as a well known text string:

>>> wkt = 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
>>> prj = Projection(wkt)

The extent for this projection as a Bounds object. If unknown this method returns None.


The string identifying the projection

transform(obj, dest)

Transforms an object from this projection to a specified destination projection.

obj is a Geometry object to transform.

dest is the destination Projection to transform to.

>>> proj = Projection('epsg:4326')
>>> dest = Projection('epsg:3005')
>>> import geom
>>> p1 = geom.Point(-125, 50)
>>> p2 = proj.transform(p1, dest)
>>> p2.round()
POINT (1071693 554290)

obj may also be specified as a single coordinate list or tuple. dest may also be specified as a string identifying the destination projection.

>>> proj = Projection('epsg:4326')
>>> p1 = (-125, 50)
>>> p2 = proj.transform(p1, 'epsg:3005')
>>> [round(x) for x in p2]
[1071693.0, 554290.0]

The well known text string representing the projection

geoscript.proj.transform(obj, src, dst)

Reprojects an object from a source projection to a target projection.

>>> import geom 
>>> p1 = geom.Point(-125, 50)
>>> p2 = transform(p1, 'epsg:4326', 'epsg:3005')
>>> p2.round()
POINT (1071693 554290)

Iterator over all defined projections:

for p in proj.projections():

This function returns Projection objects.