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

Stephen Woodbridge woodbri at swoodbridge.com
Tue Apr 19 10:45:48 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) ?

One way would be to add a new geometry column and then populate it, 
maybe something like (untested):

select addgeomtrycolumn('myschema', 'mytable', 'geom3d', 4326, 'POINT', 3);

update mytable set geom3d=setsrid(makepoint(st_x(the_geom), 
st_y(the_geom), z_column::double percision), 4326);


This assumes the data is in srid 4326.

You might want to add an index on this column also.

-Steve W



More information about the postgis-users mailing list