Error when adding 2 layers

Topics: SharpMap Project
Apr 25, 2009 at 9:22 AM
I am having a road network layer and a point layer. Both these have geom as SRID=2276. But when I tried to add both layers, I get this error. It works fine for one layer.

ERROR: XX000: Operation on two geometries with different SRIDs

I am adding these layers via POSTGIS. I used several different point datasets all having SRID=2276, via POSTGIS; but I still get the error.
Please suggest me a solution for this.
Apr 27, 2009 at 5:34 AM


I'm also facing the same problem but with a little different input....I'm giving only one layer as input and it's SRID i set at the time of upload in PostgreSQL and i run following query
SELECT district_name, extent(transform(geom, 4326)) as the_extent FROM districts WHERE district_name = 'Lahore' GROUP BY district_name
it returns result very well but before the execution show the output it gives an error. Thanx in advance

Apr 27, 2009 at 8:07 AM
I experienced these problems, too. If I recall correctly it is due to the fact that the postgis provider queries the spatial reference id from 'geometry_columns' table. If the table or view you want to use has not registered its geometry column in that table properly, you'll end up with a spatial reference id of -1 for you postgis provider. If you then perform a spatial query --as you do for every initial draw/zoom/pan operation-- you will get the

ERROR: XX000: Operation on two geometries with different SRIDs

Check SRID property of your postgis datasources and fix geometry_columns table.

Apr 28, 2009 at 12:57 PM
I did add a new coulmn by
SELECT AddGeometryColumn

The SRID, I'm using is 2276.

And then did add the data again. Therefore, SRID can't be -1. But still get the error. I get this error only when I tried to add two layers using sharpmap (Geometry type is different in 2 layers).  Both layers have the same SRID (2276).

Please provide me any suggestions.
Apr 28, 2009 at 7:18 PM
Edited Apr 28, 2009 at 8:13 PM
Hello supunmali,

the construction of your Postgis provider looks something like the first line:
SharpMap.Data.Providers.PostGIS provider = new SharpMap.Data.Providers.PostGIS(ConnStr, "CurrentPointNew", "the_geom", "oid");

System.Diagonostics.Debug.Assert(provider.Srid == 2276);

If the second line throws an assertion for any of your tables, then there is something wrong with the definition of these tables.

Could you post the result of the following query?
Select * from geometry_columns where f_table_name='CurrentPointNew';

Apr 29, 2009 at 1:54 AM
Hi FObermaier ,

result of the query
Select * from geometry_columns where f_table_name='tablename';
first layer-

then the second layer

I get the error when I add the second layer.

Apr 29, 2009 at 8:30 AM
Edited Apr 29, 2009 at 9:56 AM
Hi supunmali,

I think the problem in your case is that you use mixed case in the table called 'CurrentPointNew'.
Could you try renaming it to lowercase ('currentpointnew') and change the entry 'f_table_name' in 'geometry_columns' table accordingly.
(probably your table name is already lowercase and just the names don't match?)

Currently it is better to use lowercase table- and columnnames for use with the postgis provider.

Update: I just added a patch ( #2841 ) which might help you address that problem:

Apr 29, 2009 at 1:17 PM
Thank you very much.

The issue is with using uppercase in the middle. It worked fine when I used lowercase.