[postgis-users] Buffer Function

Will Muir will at mtintouch.net
Wed May 2 16:44:38 PDT 2007


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



More information about the postgis-users mailing list