[postgis-devel] Transform function for coordinates

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Fri Nov 18 01:44:28 PST 2005

> -----Original Message-----
> From: postgis-devel-bounces at postgis.refractions.net 
> [mailto:postgis-devel-bounces at postgis.refractions.net] On 
> Behalf Of Jeremy Palmer
> Sent: 18 November 2005 08:20
> To: postgis-devel at postgis.refractions.net
> Subject: [postgis-devel] Transform function for coordinates
> Hi,
> Would it be possible to create a function that transforms x, 
> y values from one srid to another srid?
> The reason I ask is I have a database of nodes, lines and 
> boundaries geometries which are physically translated (-160 
> shift, because or New Zealand data crosses the 180 longitude 
> line) and are stored at a low precision. I also have a table 
> of node coordinates (x, column y column, z
> column) that are stored as double precision coordinates which 
> have both a higher precision that the spatial geometries and 
> are not translated. These coordinates are used for other 
> mathematical operations, and when changed are used to 
> reconstruct the relating spatial geometries.
> The function prototype I was thinking about was: 
> transform(double x, double y, [double z], int srid_in, int srid_out);
> This function would be a convenience and would save me having 
> to construct and translate geometries each time (sometimes 
> have to transforms 100's of millions coordinates)
> Thanks
> Jeremy  

Hi Jeremy,

If you are using PostGIS 1.0 then you should be able to do something like
this which will construct the POINT geometries on the fly:

SELECT transform(setSRID(MakePoint(x, y), <srid_in>), <srid_out>) FROM

Also you may be in interested in that I have been working on a patch in
PostGIS CVS that will dramatically increase the speed on queries such as the
ones given above on large datasets - see the thread "Transform() PROJ4 cache
patch" for some example timings.

Kind regards,


WebBased Ltd
17 Research Way

T: +44 (0)1752 797131
F: +44 (0)1752 791023


This email and any attachments are confidential to the intended recipient
and may also be privileged. If you are not the intended recipient please
delete it from your system and notify the sender. You should not copy it or
use it for any purpose nor disclose or distribute its contents to any other

More information about the postgis-devel mailing list