How do I perform one-step transformation in python?

I would like to perform transformation for this example data set.
I have here four pairs of adjustment points and want to transform given point coordinates from primary system to secondary system according to adjustment.

primary_system1 = (3531820.440, 1174966.736, 5162268.086)
primary_system2 = (3531746.800, 1175275.159, 5162241.325)
primary_system3 = (3532510.182, 1174373.785, 5161954.920)
primary_system4 = (3532495.968, 1175507.195, 5161685.049)

secondary_system1 = (6089665.610, 3591595.470, 148.810)
secondary_system2 = (6089633.900, 3591912.090, 143.120)
secondary_system3 = (6089088.170, 3590826.470, 166.350)
secondary_system4 = (6088672.490, 3591914.630, 147.440)

#transform this point
x = 3532412.323
y = 1175511.432
z = 5161677.111<br>

eventually, how do I compute helmert transformation parameters, shifts, rotations and scale factor?

EDIT
at the moment I try to average translation for x, y and z axis using each of the four pairs of points like:

#x axis
xt1 =  secondary_system1[0] - primary_system1[0]
xt2 =  secondary_system2[0] - primary_system2[0]
xt3 =  secondary_system3[0] - primary_system3[0]
xt4 =  secondary_system4[0] - primary_system4[0]

xt = (xt1+xt2+xt3+xt4)/4    #averaging

...and so on for y and z axis

#y axis
yt1 =  secondary_system1[1] - primary_system1[1]
yt2 =  secondary_system2[1] - primary_system2[1]
yt3 =  secondary_system3[1] - primary_system3[1]
yt4 =  secondary_system4[1] - primary_system4[1]

yt = (yt1+yt2+yt3+yt4)/4    #averaging

#z axis
zt1 =  secondary_system1[2] - primary_system1[2]
zt2 =  secondary_system2[2] - primary_system2[2]
zt3 =  secondary_system3[2] - primary_system3[2]
zt4 =  secondary_system4[2] - primary_system4[2]

zt = (zt1+zt2+zt3+zt4)/4    #averaging

Is it right way?

• Can you use proj4, Gdal, or any other library to do the transformation from ESPG_X to ESPG_Y? Jan 15, 2012 at 17:26
• I would like to perform something like site calibration, where parameters for secondary system are unknown as it is local system. Jan 15, 2012 at 17:35
• The question, as stated, is not answerable: with only four pairs of control points, you cannot hope to estimate seven independent parameters (three shift values, three rotation values, and a scale value). Jan 16, 2012 at 15:11
• @whuber, yes you can. In fact you can do it with two 3-space points and a z-coordinate, according to en.wikipedia.org/wiki/Helmert_transformation. The attachment to this post: mail.scipy.org/pipermail/scipy-user/2010-March/024495.html even provides some Python code that produces the Helmert parameters. Jan 19, 2012 at 10:14
• @Mersey Thank you for that correction! Yes, you and Wikipedia are right: four points determines a rigid reference frame, so there should be a unique Euclidean transformation from one set of four points to another. Jan 19, 2012 at 14:40

There is a python wrapper for the proj4 library. Proj4 is a commonly used library for projecting data from one system to another.

Whatever system you do use, it will most likely take the point information in the form (lon, lat) or (y,x). Just something to be aware of - I've made this mistake in the past.

(I'm not familiar with the helmert transformation part of your question.)

• Yes, I know proj4 module but I am not sure if there's possibility to transform between undefined coordinate systems. Jan 15, 2012 at 22:20
• ah ok. What do you mean transform between undefined coordinate systems? Does a coordinate system not have to have some sort of descriptor, by definition?
– djq
Jan 15, 2012 at 22:39
• I mean that I have no parameters of second coordinate system, only adjustment. Jan 15, 2012 at 22:57
• Not sure if this book is of any help: books.google.com/…
– djq
Jan 16, 2012 at 1:22