[R] off-topic: affine transformation matrix
Dylan Beaudette
dylan.beaudette at gmail.com
Tue May 29 21:56:57 CEST 2007
Thanks for the prompt and clear reply! The simplicity of the solution may have
been why I initially overlooked this approach...
The results look convincing (http://169.237.35.250/~dylan/temp/affine.png),
now I just need to verify that the output from coef() is in the format that I
need it in.
l <- lm(cbind(nx,ny) ~ x + y, data=g)
coef(l)
nx ny
(Intercept) 6.87938629 5.515261158
x 1.01158806 -0.005449152
y -0.04481893 0.996895878
## convert to format needed for affine() function in postGIS?
t(coef(l))
(Intercept) x y
nx 6.879386 1.011588063 -0.04481893
ny 5.515261 -0.005449152 0.99689588
note that the format that I am looking for looks something like the matrix
defined on this page:
http://www.geom.uiuc.edu/docs/reference/CRC-formulas/node15.html
cheers,
dylan
On Monday 28 May 2007 15:18, Prof Brian Ripley wrote:
> Isn't this just a regression (hopefully with a near-zero error).
>
> coef(lm(cbind(xnew, ynew) ~ xold + yold))
>
> should do what I think you are asking for. (I am not clear which
> direction you want the transformation, so choose 'old' and 'new'
> accordingly.)
>
> On Mon, 28 May 2007, Dylan Beaudette wrote:
> > This may sound like a very naive question, but...
> >
> > give two lists of coordinate pairs (x,y - Cartesian space) is there any
> > simple way to compute the affine transformation matrix in R.
> >
> > I have a set of data which is offset from where i know it should be. I
> > have coordinates of the current data, and matching coordinates of where
> > the data should be. I need to compute the composition of the affine
> > transformation matrix, so that I can apply an affine transform the entire
> > dataset.
> >
> > any ideas?
> >
> > thanks in advance!
--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341
More information about the R-help
mailing list