[postgis-users] modifying xy coordinates in the geom column

Michael Fuhr mike at fuhr.org
Thu Jun 22 14:19:16 PDT 2006


On Thu, Jun 22, 2006 at 01:46:59PM -0700, Aaron Licker wrote:
> I am trying to offset some point data that has been snapped to some lines.
> Ideally a point that is on a vertical line would get offset in the x direction by 2m and in the y direction by 2m if it has an even address etc.
> i am running a query such as:
>  update sketch_bars set the_geom = geomfromtext('POINT((x(the_geom)+2) (y(the_geom)+2))',32190) where "id" = 458
> 
> but of course i get the 
> 
> ERROR:  parse error - invalid geometry

The string 'POINT((x(the_geom)+2) (y(the_geom)+2))' is being treated
as a literal; you're not getting the interpolation you appear to be
wanting.  Try translate():

UPDATE sketch_bars SET the_geom = translate(the_geom, 2, 2) WHERE id = 458;

Before doing the update you might wish to use translate() in a
SELECT statement to make sure it does what you want.  Or do the
UPDATE in a transaction and make a few queries to check the results,
then commit or roll back.

-- 
Michael Fuhr



More information about the postgis-users mailing list