Coordinate Transformation Problem

Topics: General Topics, SharpMap v0.9 / v1.x, WinForms Controls
Aug 2, 2007 at 6:19 PM
Hello,

I would like to project map data in the manner described in SharpGIS' blog. The data I am using is a shapefile, using the WGS84 coordinate system. Unfortunately, I am running into an exception:

System.Exception was unhandled
  Message="Only 2 dimensions are supported for points"
  Source="SharpMap"
  StackTrace:
       at SharpMap.Geometries.Point..ctor(Double[] point) in ...SharpMap\Geometries\Point.cs:line 66
       at SharpMap.CoordinateSystems.Transformations.GeometryTransform.TransformBox(BoundingBox box, IMathTransform transform) in
         ...SharpMap\CoordinateSystems\Transformations\GeometryTransform.cs:line 42
       at SharpMap.Layers.VectorLayer.Render(Graphics g, Map map, Boolean bQuery) in ...SharpMap\Layers\VectorLayer.cs:line 150
       at SharpMap.Map.GetMap() in ...SharpMap\Map\Map.cs:line 158
...

The WKT strings I am using are:

      CoordinateSystemFactory csFactory = new CoordinateSystemFactory();
      ICoordinateSystem wgs84 = csFactory.CreateFromWkt(
        @"GEOGCS[""Lat Long WGS84"",DATUM[""D_WGS84""," +
        @"SPHEROID[""World_Geodetic_System_of_1984"",6378137.0,298.257222932867]]," +
        @"PRIMEM[""Greenwich"",0.0],UNIT[""Degree"",0.0174532925199433]]" );
      ICoordinateSystem sphMer = csFactory.CreateFromWkt(
        @"PROJCS[""Mercator Spheric"", GEOGCS[""WGS84basedSpheric_GCS""," +
        @"DATUM[""WGS84basedSpheric_Datum"", SPHEROID[""WGS84based_Sphere"", 6378137, 0], TOWGS84[0, 0, 0, 0, 0, 0, 0]]," +
        @"PRIMEM[""Greenwich"", 0, AUTHORITY[""EPSG"", ""8901""]]," +
        @"UNIT[""degree"", 0.0174532925199433, AUTHORITY[""EPSG"", ""9102""]]," +
        @"AXIS[""E"", EAST], AXIS[""N"", NORTH]]," +
        @"PROJECTION[""Mercator""], PARAMETER[""False_Easting"", 0], PARAMETER[""False_Northing"", 0]," +
        @"PARAMETER[""Central_Meridian"", 0], PARAMETER[""Latitude_of_origin"", 0]," +
        @"UNIT[""metre"", 1, AUTHORITY[""EPSG"", ""9001""]], AXIS[""East"", EAST], AXIS[""North"", NORTH]]" );

I then create the coordinate transformation:

      vectorLayer.CoordinateTransformation =
        new CoordinateTransformationFactory().CreateFromCoordinateSystems( wgs84, sphMer );

When the Map's Envelope gets transformed by the VectorLayer, the result is a 3-element double[] (rather than a 2-element double[]). Did I do something wrong in the programming?

Thanks,
Jon
Coordinator
Aug 6, 2007 at 5:05 AM
I note you checked SharpMap v2.0... is this correct?
Aug 6, 2007 at 5:26 AM
Oops, I'm sorry. I meant 1.0, not 2.0.
Mar 24, 2010 at 11:18 AM

I know this thread is a bit old but I'm also having the similar problem. I'm getting the exception "Only 2 dimensions are supported for points".

Anyone got a clue why?