[postgis-users] use of the affine() function
Dylan Beaudette
dylan.beaudette at gmail.com
Tue May 29 12:41:24 PDT 2007
On Monday 28 May 2007 13:51, Martin Davis wrote:
> In order to turn a set of [src, dest] coordinate pairs into an affine
> transformation, you have to solve a system of linear equations. The
> solution is the entries in the require affine transformation matrix. In
> order to fully determine an affine transformation you need 3 control
> points and their images under the transformation.
>
> I don't know if PostGIS has this functionality available, but if you can
> hack Java (so to speak) JTS provides a class called
> AffineTransformationBuilder which can do this.
>
Martin,
Thanks for pointing this out. I was suspecting that solving the affine matrix
equation was the only way to do this. It turns out that there is a simple
way[1] to do this in R, as suggested by Prof Brian Ripley on the R-help
mailing list. I am not completely sure if the resulting matrix is formatted
in the way that the PostGIS affine() function is expecting it.
attached is a sample figure of 'good' (red) and 'bad' (black) control points,
with the affine transformation.
Here is the solution to the affine equation:
nx ny
(Intercept) 4.67820316 5.073777014
x 0.99583870 0.002349727
y 0.01727790 1.002291282
.. i will do some checking and post a complete example once I verify that this
is doing what I think it is doing.
1. the approach involves a multivariate regression:
lm(cbind(nx,ny) ~ x + y, data=g)
where (nx,ny) are the 'good' data, and (x,y) are the 'bad' data.
cheers,
dylan
> Dylan Beaudette wrote:
> > I have a problematic TIGER module - i.e. a single county in Ca is really
> > messed up. I thought that a simple translate() would do the job, but it
> > looks like there is both a translation and rotation involved. I do not
> > really understand the postgis manual entry for the affine function.
> >
> > How would one go about converting a series of coordinate pairs ([good],
> > [bad]) into the terms of the affine transform matrix?
> >
> > thanks,
--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341
-------------- next part --------------
A non-text attachment was scrubbed...
Name: affine.png
Type: image/png
Size: 59320 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070529/34355e19/attachment.png>
More information about the postgis-users
mailing list