GunRunMaps/GIS Base Map/convert_extents.py

39 lines
798 B
Python

#!/usr/bin/python
import ogr, osr
points = [
[ 18.372, -33.927 ],
[ 18.382, -33.921 ],
[ 18.400, -33.909 ],
[ 18.424, -33.893 ],
[ 18.419, -33.897 ],
[ 18.417, -33.898 ],
]
# Spatial Reference System
inputEPSG = 3857
outputEPSG = 22234
for row in points:
# create a geometry from coordinates
point = ogr.Geometry(ogr.wkbPoint)
point.AddPoint(row[1], row[0])
# create coordinate transformation
inSpatialRef = osr.SpatialReference()
inSpatialRef.ImportFromEPSG(inputEPSG)
outSpatialRef = osr.SpatialReference()
outSpatialRef.ImportFromEPSG(outputEPSG)
coordTransform = osr.CoordinateTransformation(inSpatialRef, outSpatialRef)
# transform point
point.Transform(coordTransform)
# print point in output EPSG
print row[0], row[1], "\t\t", point.GetX(), point.GetY()