# 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 - primary_system1
xt2 =  secondary_system2 - primary_system2
xt3 =  secondary_system3 - primary_system3
xt4 =  secondary_system4 - primary_system4

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

...and so on for y and z axis

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

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

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

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? – dassouki Jan 15 '12 at 17:26
• I would like to perform something like site calibration, where parameters for secondary system are unknown as it is local system. – daikini Jan 15 '12 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). – whuber Jan 16 '12 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. – MerseyViking Jan 19 '12 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. – whuber Jan 19 '12 at 14:40

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.
• 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 '12 at 22:39