[postgis-users] Calculate z value based on attribute field
Gis Mage
gismage at gmail.com
Thu Apr 21 08:32:51 PDT 2011
Hello again!
Doing as proposed I get an error.
wizbase=# select
addgeometrycolumn('public','allhousefinal','the_geom3d',4326,'MULTIPOLYGON',3);
addgeometrycolumn
---------------------------------------------------------------------
public.allhousefinal.the_geom3d SRID:4326 TYPE:MULTIPOLYGON DIMS:3
(1 row)
wizbase=# update allhousefinal set the_geom3d = st_union(the_geom,
st_setsrid(st_makepoint(st_x(st_pointonsurface(the_geom)),st_y(st_pointonsurface(the_geom)),
result_hig*3),st_srid(the_geom)));
ERROR: new row for relation "allhousefinal" violates check constraint
"enforce_geotype_the_geom3d"
As you can see the geometry type is MULTIPOLYGON, so I think the problem is
somewhere around st_makepoint.
Can you please help me out?
Nikolai
Re: [postgis-users] Calculate z value based on attribute
field
To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
Message-ID: <20110419175447.GG13611 at keybit.net>
Content-Type: text/plain; charset=us-ascii
On Tue, Apr 19, 2011 at 01:45:48PM -0400, Stephen Woodbridge wrote:
> 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);
A geometry type agnostic way would be to union whatever you have
with a 3d point known to be contained in it. GEOS would then use
the only Z value to fill up an elevation grid used to elevate
the resulting geometry:
-- untested query
update mytable set geom3d = st_union(the_geom,
st_setsrid(st_makepoint(
st_x(st_pointonsurface(the_geom)),
st_y(st_pointonsurface(the_geom)),
z_column), st_srid(the_geom)));
--strk;
() Free GIS & Flash consultant/developer
/\ http://strk.keybit.net/services.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110421/03b6c1f8/attachment.html>
More information about the postgis-users
mailing list