GeoScript

Previous topic

WKB

Next topic

feature

This Page

proj

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

class geoscript.proj.Projection(proj)

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')
>>> prj.id
'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)
>>> prj.id
'EPSG:4326'
id

The string identifying the projection

wkt

The well known text string representing the projection

bounds

The valid geographic area for the specified coordinate reference system as a Bounds object. If unknown this method returns None.

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
POINT (1071693.3691932235 554290.3694231863)

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')
>>> p2
(1071693.3691932235, 554290.3694231863)
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
POINT (1071693.3691932235 554290.3694231863)
geoscript.proj.projections()

Iterator over all defined projections:

for p in proj.projections():
   ..

This function returns Projection objects.