[postgis-users] Buffer Function

Nicolas Ribot nicky666 at gmail.com
Wed May 2 23:58:41 PDT 2007


Hi Will,

The error means that the geometric type returned by the buffer
function does not correspond to the type declared in addGeometryColumn
(polygon).
Buffer can return multipolygons or even other geometric type.
You can set the geometric column type to be GEOMETRY or MULTIPOLYGON
and see if it works.

Nicolas

On 5/3/07, Will Muir <will at mtintouch.net> wrote:
> Hello, I am a somewhat newbie to sql in general, and I am having some
> troubles with the buffer() function.   I am trying to build a table
> using the buffer function, with an "insert select" from a table that
> was built using shp2pgsql.   The table schematics are as follows.
>
>          CREATE TABLE spray_buffer (gid INT4 PRIMARY KEY,"name" VARCHAR(32));
>          SELECT AddGeometryColumn
> ('','spray_buffer','the_geom','-1','POLYGON',2);
>
> When I run the following insert statement,
>
>         INSERT INTO "spray_buffer" (gid,"name",the_geom) SELECT
> gid,"name",buffer("the_geom" \
>         ,27.432) FROM "spray" WHERE "name" = 'ACTIVE LOG #3';
>
> I get the following error,
>         ERROR:  new row for relation "spray_buffer" violates check
> constraint "enforce_geotype_the_geom"
> .
> Running SELECT version(); returns the following,
>
>         PostgreSQL 8.2.4 on powerpc-apple-darwin8.9.0, compiled by GCC
> powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc.
> build 5247)
>
> and running SELECT postgis_version(); returns,
>
>                     postgis_version
>         ---------------------------------------
>         1.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
>
> I am trying to view the results in Qgis, when I use the Qgis buffer
> plugin I also get a similar error in my log files.  I realize that
> the problem is  most likely with declaring the gid as a primary key,
> but without that Qgis does not recognize the table.  If it would help
> I could post the relevant snippets from the logs.  Any help that
> someone could offer would be appreciated.
>
> Thanks,
> Will
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list