<HTML dir=ltr><HEAD><TITLE>Re: [postgis-users] ERROR: new row for relation "x"violates checkconstraint "enforce_geotype_the_geom"</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText49959 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>What does</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>select distinct(geometrytype(multi(geomunion(t1.the_geom, t2.the_geom))))<BR>  from gf_veg1 t1, gf_veg2 t2</FONT></DIV><FONT size=2></FONT></DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr><FONT size=2>return you.  Are you sure both your fields are POLYGONS or MULTIPOLYGONS?</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr><BR></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> postgis-users-bounces@postgis.refractions.net on behalf of Andreas Laggner<BR><B>Sent:</B> Thu 8/9/2007 9:42 AM<BR><B>To:</B> PostGIS Users Discussion<BR><B>Subject:</B> Re: [postgis-users] ERROR: new row for relation "x"violates checkconstraint "enforce_geotype_the_geom"<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Hi Regina,<BR>if i integrate your statement like this:<BR><BR>drop table intersect_gf3;<BR>create table intersect_gf3(gid integer) with oids;<BR>select<BR>addgeometrycolumn('','intersect_gf3','the_geom','31467','MULTIPOLYGON',2);<BR>insert into intersect_gf3<BR>    select t1.gid,multi(intersection(t1.the_geom, t2.the_geom))<BR>    from gf_clc t1, gf_veg1 t2<BR>    where t1.the_geom && t2.the_geom;<BR><BR>i although get the error:<BR>ERROR: new row for relation "intersect_gf3" violates check constraint<BR>"enforce_geotype_the_geom"<BR>SQL Status:23514<BR><BR>hasta luego      Andreas<BR><BR><BR><BR><BR>Obe, Regina schrieb:<BR>> In addition to what Frank mentioned.  Often times Geomunion applied to polygons or multipolygons may return a Polygon rather than a MultiPolygon.<BR>><BR>> To force it into a multipolygon type, wrap a multi call around it.  Something like<BR>><BR>> select t1.gid,multi(geomunion(t1.the_geom, t2.the_geom))<BR>>     from gf_veg1 t1, gf_veg2 t2;<BR>><BR>> -----------------------------------<BR>> Also why are you doing a cartesian join?<BR>><BR>> Hope that helps,<BR>> Regina<BR>><BR>> -----Original Message-----<BR>> From: postgis-users-bounces@postgis.refractions.net [<A href="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>] On Behalf Of Frank Koormann<BR>> Sent: Thursday, August 09, 2007 6:04 AM<BR>> To: PostGIS Users Discussion<BR>> Subject: Re: [postgis-users] ERROR: new row for relation "x" violates checkconstraint "enforce_geotype_the_geom"<BR>><BR>> Hi again,<BR>><BR>> * Andreas Laggner <bloediandi@web.de> [070809 11:21]:<BR>>  <BR>>> i have to delete this constraint in EVERY table i want to write to! I<BR>>> think that is not normal?!<BR>>>    <BR>><BR>> Partly - yes:<BR>><BR>> - AddGeometryColumn creates a contraint according to the geometry type<BR>>   specified to be compliant with OGC.<BR>> - As a consequence you should first check the potential outcome of your<BR>>   geomunion operation before creating the geomcolumn, you might run<BR>>   something like:<BR>><BR>>   select distinct(geometrytype(geomunion(t1.the_geom, t2.the_geom)))<BR>>     from gf_veg1 t1, gf_veg2 t2<BR>>     where t1.the_geom && t2.the_geom;<BR>><BR>> Regards,<BR>><BR>>         Frank<BR>><BR>>  <BR><BR>_______________________________________________<BR>postgis-users mailing list<BR>postgis-users@postgis.refractions.net<BR><A href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR></FONT></P></DIV></BODY></HTML>
<HTML><BODY><P><hr size=1></P>
<P><STRONG>
The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.
</STRONG></P></BODY></HTML>