This project has moved and is read-only. For the latest updates, please go here.

Mixing Geometry and Shape Layer doesn't work?

Topics: Algorithms, SharpMap Project, WinForms Controls
Feb 10, 2010 at 12:07 PM


I'm just a newbee with SharpMap and need a little help. I've some GIS-Polygon-data. I parse this data into in own layer with GeometryFeatureProvider like this


GeometryFeatureProvider provider = new GeometryFeatureProvider(GeometryFromWKT.Parse("MULTIPOLYGON(....)));
VectorLayer own = new VectorLayer("own");
own.DataSource = provider;

oki, this work's great I see a polygon. Then I tried to use the Countries-Layer from the WinFormSamples:

VectorLayer layCountries = new VectorLayer("Countries");
 layCountries.DataSource = new ShapeFile("GeoData/World/countries.shp", true);
layCountries.Style.Fill = new SolidBrush(Color.Green);
layCountries.Style.Outline = Pens.Black;
layCountries.Style.EnableOutline = true;
layCountries.SRID = 4326;

and this works fine, I see a world map.


BUT, if I use both layers, I see nothing!! Does anyone know what's wrong?




Feb 10, 2010 at 12:43 PM

It sounds like you have a mismatch between the spatial reference systems. If you know both are the same then you need to set the srids to match. Otherwise you need to set appropriate Coordinate systems on the layers. hth jd

Feb 10, 2010 at 12:52 PM

thank's that sounds like a possible reason. I don't know what coordinate-system is used. Is it possible to identify it ? Here are the first coordinates of the Multipolygon:

7546.1879833346 52887.1269688453,7538.80595830772 52889.2330166453,


Can you give me help?


Thank you


Feb 10, 2010 at 1:15 PM

I cannot tell which coordinate system that is but it is definately a projected coordinate system. Have a look on for systems that are used in the area that the data you have comes from. hth jd


Feb 10, 2010 at 1:34 PM

Thank's you for the help, I've seachred the data-space on the GIS-Server and found taht the EPSG is 4230. But how can i made a transformaiton to 4326 ? Is it simple an addtion to latidude and lonitude?

Feb 10, 2010 at 2:21 PM

see cheers jd


Feb 10, 2010 at 4:45 PM

Dear Johndiss,

thank you for the help, but in the version I've donwload (v0.9) are the following classes not present (and some other classes).


Because of this, I try sharp map v2 with wpf controls. There I've all the needed classes to create the transformation. (Yes I know its WPF, but I prefer it) But still no gemoetry-object is rendered.

Do you have a working copy with the tansformation classes, or can you help me to fix in the sharp map control?

I would be very happy, if we find a solution.

Feb 10, 2010 at 4:52 PM

Those classes come from ProjNet which is in the externalreferences directory. cheers jd


Feb 10, 2010 at 5:25 PM

Yes I found the classes *happy*, but I get the exception "Only 2 dimensions are supported for points". I use the following code for the transformation:


            CoordinateSystemFactory fac = new CoordinateSystemFactory();
            ICoordinateSystem sourceCoorindate = fac.CreateFromWkt("GEOGCS[\"ED50\",DATUM[\"European_Datum_1950\",SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]],AUTHORITY[\"EPSG\",\"6230\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4230\"]]");
            ICoordinateSystem targetCoordintate = fac.CreateFromWkt("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]");
            CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
            ICoordinateTransformation transform = ctFac.CreateFromCoordinateSystems(sourceCoorindate, targetCoordintate);
            own.CoordinateTransformation = transform;


Do you have another idea? The Strings for the method CreateFromWkt are copied from the SRID.csv file in the SharpMap-project file.




Feb 12, 2010 at 7:44 AM

Dear johndiss,

I’ve found the problem. The Polygon-Coordinates are totally incorrect. I don’t know why (have no access to the system) but they are incorrect. If I use the polygon directly from the GIS-Server, all is correct.

Thank you for the help.