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

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'
bounds

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

id

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]
wkt

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)
geoscript.proj.projections()

Iterator over all defined projections:

for p in proj.projections():
   ..

This function returns Projection objects.