Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am new to Postgis and I have imported a shapefile containing point layer into the postgis, and the SRID i had chosen was 4326. now while inserting the values into the table I am getting problem. My intension is to create a circle around that point using ST_Buffer.

My Table structure is

CREATE TABLE "ankCircle"
(
  gid serial NOT NULL,
  id numeric(10,0),
  geom geometry,
  CONSTRAINT "ankCircle_pkey" PRIMARY KEY (gid),
  CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 2),
  CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'POINT'::text OR geom IS NULL),
  CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 4326)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE "ankCircle" OWNER TO postgres;

Query I am using is

INSERT INTO "ankCircle"(gid, id, geom)
VALUES (1, 1, ST_Buffer(ST_GeomFromText('POINT(100 90)',4326),50, 'quad_segs=8'));

error got

ERROR:  new row for relation "ankCircle" violates check constraint "enforce_geotype_geom"

********** Error **********

ERROR: new row for relation "ankCircle" violates check constraint "enforce_geotype_geom"
SQL state: 23514
share|improve this question

1 Answer 1

up vote 5 down vote accepted

You have a constraint that is preventing the buffer result into being inserted in the table. This the constraint code:

CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'POINT'::text OR geom IS NULL),

The constraint is checking that the geometry type is POINT or is NULL (while ST_Buffer is returning a different geometry type). If that is not intentional you should change that constraint or create a new column (say buffer_geom) with a different constraint or no constraint at all.

share|improve this answer
    
Thanks for your Kind reply ... can you tell me how can i convert from polygon to multipolygon,,, as the return type of the buffer is polygon type and the datatype to be matched in the constraint is multipolygon.... i had tried ST_Dump but was unable to typecast... –  Vicky Sep 1 '11 at 6:17
    
Refer to the PostGIS documentation postgis.refractions.net/documentation HINT: There's a function called ST_Multi –  Sean Sep 1 '11 at 13:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.