This project has moved. For the latest updates, please go here.

ERROR: XX000: Operation on two geometries with different SRIDs

Jan 9, 2007 at 8:37 AM
I am using a postgreSQL database and I am trying to create a simple map.

The db table is the following:

CREATE TABLE geodb.countryroads
entityid int8 NOT NULL DEFAULT nextval('countryroadsentityidseq'::regclass),
name varchar(250),
localizedname varchar(250),
layerid int4,
sourceid int4,
countryid varchar(100),
shape geometry,
numberingleftstart int2 DEFAULT 0,
numberingleftstop int2 DEFAULT 0,
numberingrightstart int2 DEFAULT 0,
numberingrightstop int2 DEFAULT 0,
zip varchar(20),
area varchar(200),
CONSTRAINT enforcedimsshape CHECK (ndims(shape) = 2),
CONSTRAINT enforcegeotypeshape CHECK (geometrytype(shape) = 'MULTILINESTRING'::text OR shape IS NULL),
CONSTRAINT enforcesridshape CHECK (srid(shape) = 4326)
ALTER TABLE geodb.countryroads OWNER TO postgres;

The code in C#:
SharpMap.Map myMap = new SharpMap.Map(new Size(400, 300));
myMap.MinimumZoom = 100; //Minimum zoom allowed
myMap.BackColor = Color.White; //Set background
myMap.Center = new SharpMap.Geometries.Point(725000, 6180000); //Set center of map
myMap.Zoom = 1200; //Set zoom level
myMap.Size = new System.Drawing.Size(300, 200); //Set output size

//Add PostGIS layer:
SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer("My layer");
string ConnStr = "DRIVER={PostgreSQL};Server=;Port=5432;UserId=postgres;Password=***;Database=GeoDB;";
myLayer.DataSource = new SharpMap.Data.Providers.PostGIS(ConnStr, "geodb.countryroads", "shape", "entityid");

//myLayer.SRID = 4326;

myLayer.MaxVisible = 40000;

//Render the map
System.Drawing.Image imgMap = myMap.GetMap();

Now, the error I get is "Operation on two geometries with different SRIDs", but when I un-comment the line "myLayer.SRID = 4326;" I get another error saying "Spatial Reference ID cannot by set on a PostGIS table". I suppose it leaves me no choice then! Do you suspect what the problem might be?

PS I am totally new to GIS and maps
Jan 11, 2007 at 11:39 AM
Check out the contents of the geometry_columns table. Specifically:
SELECT * FROM geometry_columns
WHERE f_table_name = 'countryroads'
AND f_geometry_column = 'shape'

If that row doesn't exist, it means you had not created the geometry column using the PostGIS function AddGeometryColumn or you made an incomplete backup/restore operation.

Best regards,
Ricardo Stuven.
Jan 12, 2007 at 12:11 AM
Can you share class SharpMap.Data.Providers.PostGIS to me.
You could upload to here.

Thanh Son
Viet Nam
Jan 22, 2007 at 1:28 PM
Hi, thanx for the reply. This row exists and is as follows:

(where coord_dimension=2 and srid=-1)

So I guess this is not the problem :S