# [postgis-users] How to do a cartesian projection in PostGIS (1.5)

Martin Davis mbdavis at refractions.net
Mon Feb 22 16:09:34 PST 2010

```I'm not sure of the PostGIS functions you'd use to do this, but
geometrically you could:

For projection onto the Y axis:

- extract the linework of the input geometry
- scale it by (0, 1)
- flatten the resulting mess of linestrings by unioning them

Mutatis mutandis for the X axis.

Kostis Kyzirakos wrote:
> Hi All!
> This may be a naive question, but I am not sure how to do a cartesian
> projection in PostGIS (version 1.5).
> Assume that we have a table MySpatialGeometries(id integer, geo geometry),
> and a tuple with id 10 and geo the rectangle  POLYGON(0 0 0,1 0 0,1 0 1,0 0
> 1,0 0 0).
>
> How may I calculate the cartesian projection of the geometry along the x,y
> or z axis?
>
> For example, how can I make the following calucations:
> 1. project on x-axis (project out y,z), result: Linestring (0 0 0, 1 1 0)
> 2. project on y-axis (project out x,z), result: Point (0 0 0)
> 3. project on x,y axis (project out z), result: Linestring (0 0 0, 1 1 0)
> 4. project on x,z axis (project out y), result: Polygon(0 0 0,1 0 0,1 0 1,0
> 0 1,0 0 0).
> etc.
>
> I think that I can express case 3 using the Force2D function.
> But how can I express the other cases?
>
>
> Cheers,
> Kostis
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>

--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

```