[postgis-users] How to use ST_Affine

Dylan Beaudette dylan.beaudette at gmail.com
Thu Jan 17 07:03:21 PST 2008


On Thursday 17 January 2008 12:20:47 am Frank Durstewitz wrote:
> Hi Dylan,

Hi Frank

> thanks for your answer. I have 2 problems:
> a) i do know nothing about R and GRASS

time to start going over some tutorials and manuals...

> b) the "transformation" has to run on the server (just php and
> postgres/postgis)

ok. it is possible to use R via a web-form or CGI. it is also possible to 
build a custom CGI around R using the shared libraries.

> If i remember correctly, there is a PostGres-package which does R. Can i
> install this extension and use R in PostGres to get the matrix as
> mentioned on http://casoilresource.lawr.ucdavis.edu/drupal/node/433?

If you get the R interpreter for postgres working that should get you started. 
I do not have any experience with that, so I cannot offer any comentary.

> Kind regards and sorry for my dumb questions ;-) I still learning.

No problem. Keep trying and post back to the list with progress.

Dylan

> Frank
>
> Dylan Beaudette schrieb:
> > On Wednesday 16 January 2008 09:09:01 am Frank Durstewitz wrote:
> >> Hi,
> >>
> >> i wonder how i would use ST_Affine. I found a small note how to use
> >> (with R), but that's over my mind.
> >>
> >> I want to shift the coordinates of some points. On a map i show the
> >> points, then i select at least 3 of them to move them manually to the
> >> correct coordinates and use the new coordinates as reference for the
> >> shift. So i have 3 "old" coordinates and 3 "new" cordinates. But i don't
> >> know what goes where...
> >>
> >> Can someone please explain what to do?
> >>
> >> Regards, Frank
> >
> > Hi Frank,
> >
> > Was it this page (http://casoilresource.lawr.ucdavis.edu/drupal/node/433)
> > which caused the confusion?
> >
> > I was recently confronted with the same problem: I knew the locations
> > of 'good' and 'bad' coordinates (control points) but did not know how to
> > compute the transformation matrix, which ST_Affine() wants.
> >
> > There are two approaches:
> >
> > 1. use R to 'fit' the transformation
> > 2. use GRASS and v.transform to 'fit' the transformation
> >
> > Both approaches can be used to compute and print the transformation
> > matrix based on a set of control points.
> >
> > If you use R, the trick is interpreting the format of the transformation
> > matrix:
> >
> > use the coef() function and transpose the results:
> >
> > t(coef(l))
> >
> > ... and the format will be :
> >
> >  xoff a b
> >  yoff d e
> >
> >
> > put the resulting numbers into the order that postgis wants:
> > ST_Affine(geom, a, b, d, e, xoff, yoff)
> >
> >
> > If you use GRASS and v.transform, be sure to include the '-m' flag, and
> > the transformation matrix will be printed, along with a note on the
> > format.
> >
> >
> > As the linked page suggests this approach works well when there is a
> > systematic shift in coordinates which can be modeled by an affine
> > transform.
> >
> > Cheers,
> >
> > Dylan





-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341



More information about the postgis-users mailing list