https://github.com/walter426/QgisUtilites/blob/master/QgsUtilities.py
It is a very useful and frequently used light tool to do coordinate transformation from a source CRS(Coordinate Reference System) to a destination CRS.
Code:
from qgis.core import *
def CoorTransformByCrsId(point, crs_id_src, crs_id_des):
crs_src = QgsCoordinateReferenceSystem()
crs_src.createFromSrid(crs_id_src)
crs_des = QgsCoordinateReferenceSystem()
crs_des.createFromSrid(crs_id_des)
transformer = QgsCoordinateTransform(crs_src, crs_des)
pt = transformer.transform(point)
return pt
def CoorTransform(point, crs_src, crs_des):
transformer = QgsCoordinateTransform(crs_src, crs_des)
pt = transformer.transform(point)
return pt
沒有留言:
張貼留言