1

I have imported a shapefile containing point layer into postgis, and the SRID i have chosen was 4326. Now while inserting the values into the table I am getting a 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
5

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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