I did something similar a few years back with LINESTRINGs. I had a large 3D linear dataset that I was constantly fine-tuning and adjusting the Z component of. Rather than always modifying the stored geometry (which was a real pain since just rebuilding the index took a couple of hours), I extracted the Z components out as a double[] into a separate table that I could update as needed. I wrote a very simple plpgsql function that merged the 3 ordinate back into the geometry for viewing purposes, but this allowed me to do a bunch of analysis on the Z array directly with other simple plpgsql functions, like min/max z values, min/max slope, std deviation, waterfall detection algorithms, smoothed elevation algorithms, etc.

Although it's old, the merging function might be of some use to you, it went something like:
CREATE OR REPLACE FUNCTION adddimension(geometry, double precision[])
  RETURNS geometry AS
'SELECT makeline(
   makepoint(
     x(pointn($1, index)),
     y(pointn($1, index)),
     $2[index]))
 FROM
   (select generate_series(1, numpoints($1)) AS index,
   $1 as the_geom) foo'
  LANGUAGE 'sql' VOLATILE;


Which yields results like:

select asewkt(
  adddimension(
    'LINESTRING(1 1, 2 2)'::geometry,
    ARRAY[3, 4]
  )
)

         asewkt
-------------------------
 LINESTRING(1 1 3,2 2 4)
(1 row)


Cheers,
Kevin


On 4/19/2010 2:19 PM, Chris English wrote:
Hello,

I've been wrestling around with 3D and have gotten my table/geom to x,y,z
so that

SELECT ST_AsEwkt(the_geom) FROM <table>
LIMIT 1;

returns
"MULTIPOLYGON(((611630.148961496 690526.520745486 0,611619.960661661 690507.134957485 0, 611545.79119058 690545.364867903 0,611556.435198162 690565.595798574 0,611630.148961496 690526.520745486 0)))"

In another column are the values I'd like to use for Z, or calculate Z from.

And then brain death. What sort of statement would I be using to update the Z part of the XYZ, as a calculated result
from another column.

Any help or suggestions greatly appreciated.

Chris


_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to