You seem to be looking to conduct an affine transformation between your local coordinate system and a georeferenced coordinate system.
Affine transforms underly all coordinate systems and can be represented by the matrix equation below.
|x_1 y_1 1| |a d| |x'_1 y'_1|
|x_2 y_2 1| |b e| = |x'_2 y'_2|
|x_3 y_3 1| |c f| |x'_3 y'_3|
input transform. output
coords matrix coords
(n x 3) (3 x 2) (n x 2)
However, you have a two-step problem.
- Find the transformation matrix from known pairings of input and output coordinates (your GPS points and their respective locations in your locally-defined grid).
- Use this transformation matrix to georeference your point cloud.
Proj.4 excels at #2: transferring between georeferenced coordinate systems with known transformation matrices. It can't to my knowledge be used to find a transformation matrix from point data. However, you can do the entire thing easily by using some light linear algebra (a least-squares matrix inversion) in Numpy. I've used a version of this class for reducing data from several field studies:
import numpy as N
"""Add a final column of ones to input data"""
arr = N.ones((a.shape,a.shape+1))
arr[:,:-1] = a
def __init__(self, array=None):
self.trans_matrix = array
def transform(self, points):
"""Transform locally projected data using transformation matrix"""
return N.dot(augment(N.array(points)), self.trans_matrix)
def from_tiepoints(cls, fromCoords, toCoords):
"Produce affine transform by ingesting local and georeferenced coordinates for tie points"""
fromCoords = augment(N.array(fromCoordinates))
toCoords = N.array(toCoordinates)
trans_matrix, residuals, rank, sv = N.linalg.lstsq(fromCoords, toCoords)
affine = cls(trans_matrix) # Setup affine transform from transformation matrix
sol = N.dot(fromCoords,affine.array) # Compute model solution
print "Pixel errors:"
print (toCoords - sol)
It can be used as such:
transform = Affine.from_tiepoints(gps_points_local,gps_points_geo)
projected_data = transform.transform(local_point_cloud)
projected_coordinates is now in WGS84, UTM, or whatever coordinate system your recorded by your GPS. A major feature of this method is that it can be used with any number of tie points (3 or more) and gains accuracy the more tie points are used. You're essentially finding the best fit through all of your tie points.