Right, that make perfect sense. You created a geometry column of tile MULTIPOLYGON and you are trying to add a POINT to it!

What is your original geometry type?

if it is a POINT then do

select addgeometrycolumn('public','allhousefinal','the_geom3d',4326,'POINT',3);

if it is a MULTIPOLYGON then you need to change the way you are adding the z to it and do something like:

update allhousefinal set the_geom3d = st_translate(st_force_3d(the_geom), 0, 0, result_hig*3);

I have not tested this so you might have to play with it a little.

-Steve W

On 4/21/2011 11:32 AM, Gis Mage wrote:
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 <[email protected]
<mailto:[email protected]>>
Message-ID: <[email protected]
<mailto:[email protected]>>
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



_______________________________________________
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