[postgis-users] How to use ST_Affine
Dylan Beaudette
dylan.beaudette at gmail.com
Thu Jan 17 13:32:20 PST 2008
On Thursday 17 January 2008 12:26:12 pm Frank Durstewitz wrote:
> Hi Dylan,
Hi Frank. Just a reminder, lets keep the discussion CC-ed to the postgis list
for documentation. I am sure that there will be others interested.
>
> i installed a binary package of R. Seems to be a _very_ powerfull
> language, and i for shure will learn it, because i assume we can do much
> more with our data...
Oh yeah... R is a real gem!
>
> I assume "dylans blog" is yours? If yes, maybe you can help me out:
I can claim responsibility for that. It is more of a way to keep indexed,
searchable notes than anything else....
> Can you send me an example of a file "stan.c_points" with the "good" and
> the "bad" points? I can't figure out what format the points should have...
>
> Kindly regards, Frank
Ah yes. I should have posted that file for others to tinker around with!
See the attachment at the bottom of the post:
http://casoilresource.lawr.ucdavis.edu/drupal/node/433
Note that the control points are interleaved within this file!
Cheers,
Dylan
> Dylan Beaudette schrieb:
> > On Thursday 17 January 2008 08:25:51 am Bruce Rindahl wrote:
> >> Dylan
> >> I thought your tutorial was great. How often do you think something
> >> like this will be used? I am thinking it could be straight forward to
> >> have a "link" table in PostGIS with say the x,y "from" coordinates and
> >> "to" coordinates populated via some interface. Then with the PL/R
> >> package installed use R to not only create the transformation matrix but
> >> then pass the correct values to ST_Affine and then translate the
> >> geometry. Something like
> >>
> >> Select transformation(link_table,the_geom) from my_tiger_set
> >>
> >> which would return a transformed geometry.
> >>
> >> Might be a nice procedure to have.
> >>
> >> Bruce Rindahl
> >
> > Computing an affine transformation matrix seems like a common vector
> > operation to me. It shouldn't be too hard to use the code in v.transform
> > to get a working prototype.
> >
> > Here is a link to the source:
> > http://trac.osgeo.org/grass/browser/grass/trunk/lib/vector/transform/tran
> >sform.c
> >
> > It would be a nice function to have within the context of PostGIS!
> >
> > Cheers,
> >
> > Dylan
> >
> >> -----Original Message-----
> >> From: postgis-users-bounces at postgis.refractions.net
> >> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> >> Dylan Beaudette
> >> Sent: Thursday, January 17, 2008 8:03 AM
> >> To: Frank Durstewitz; PostGIS Mailingliste
> >> Subject: Re: [postgis-users] How to use ST_Affine
> >>
> >> 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