[postgis-users] Calculate z value based on attribute field

Andrea Peri aperi2007 at gmail.com
Tue Apr 19 15:14:11 PDT 2011


On 4/19/2011 8:52 AM, Gis Mage wrote:
>* Hello list!*>**>* I've got a table in PostGIS with the_geom field with 2 dimensions.*>* I wonder how can I add a z dimension and fill it up with values from*>* attribute field elev (its type is integer) ?*

Hi,
I think you can start from this query .
It dump a geometry in its points. Force in 3D and and add a random value to
it.

select
    id,
    ST_Translate(ST_Force_3D(b.geom),0.0,0.0,(mod (ST_X(geom)::integer,
100)::numeric)+(random()*10)) as geom
from (
           select
             a.id as id,
             (ST_DumpPoints(a.geom)).* as geom
           from
             table_2d as a
)



-- 
-----------------
Andrea Peri
. . . . . . . . .
qwerty àèìòù
-----------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110420/f0711115/attachment.html>


More information about the postgis-users mailing list