[postgis-users] Can I replace all the x and y coordinates of a geometry using PostGIS, Thank you!

Paragon Corporation lr at pcorp.us
Wed Nov 11 10:39:20 PST 2009


Not sure what you are trying to do, but one of the affine functions like
ST_Translate may be what you are looking for.
 
http://www.postgis.org/documentation/manual-1.5SVN/ST_Translate.html
 
That will move all the points in the geometry a specified amount in x,y,z 
 
Leo
 

  _____  

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
ZHANGAIGUO
Sent: Wednesday, November 11, 2009 11:50 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Can I replace all the x and y coordinates of a
geometry using PostGIS, Thank you!


Hello Postgis-users:

I am a student in Fuzhou University, China.
In using PostGIS,
I encountered a problem as fellows:
How can I replace all the x and y coordinates of a geometry?
The geometry may be point, multipoint, linestring, multilinestring, and so
on.
I have tried to use the way as fellows:

CREATE OR REPLACE FUNCTION aigo_coord_offset_basicframe2(geometry, double
precision, double precision)
   RETURNS geometry AS
 $BODY$
 declare i integer; 
 compress geometry; 
geom1 geometry;
 begin
 i:=1;
 geom1:=ST_GeomFromText('LINESTRING(0 0, 0.0001 0.0001)',21460);
 while i<= ST_NumPoints($1) loop
 
geom1:=ST_AddPoint(geom1,ST_MakePoint(int2(ST_X(ST_PointN($1,i))-$2),int2(ST
_Y(ST_PointN($1,i))-$3)));
 i:=i+1;
 end loop;
 geom1:=ST_RemovePoint(geom1,0);
geom1:=ST_RemovePoint(geom1,0);
compress:=geom1;
return compress;
end $BODY$
   LANGUAGE 'plpgsql' VOLATILE
  COST 100;
 ALTER FUNCTION aigo_coord_offset_basicframe2(geometry, double precision,
double precision) OWNER TO post;
 
 The way above is just applied to LINESTRING geometry type,
 and it is inefficient.
 
 Are there any other solutions to accomplish it?
 Thank you!

 Sincerely Yours!
 ZHANG Aiguo


  _____  

Messe nger保护盾2.0,更安全可靠的Messenger聊天! 现在就下载!
<http://im.live.cn/safe/>  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20091111/93cef440/attachment.html>


More information about the postgis-users mailing list