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

Geometry Transformation factory

Topics: Algorithms, SharpMap v0.9 / v1.x
Feb 5, 2014 at 10:00 AM

Is there a way to convert whole geometries between coordinate systems?

I have my transforms defined, but the only way I can see of doing the transform is using the MathTransform.Transform method that takes a coordinate.

Like this:

public IGeometry TransformGeometry(IGeometry geom)
       if (SRID == 0 || CoordinateTransformation == null)
           return geom;

       if (geom.OgcGeometryType == OgcGeometryType.Polygon)
           var tList = new List<Coordinate>();

           geom.Coordinates.ToList().ForEach(x => tList.Add(CoordinateTransformation.MathTransform.Transform(x)));

          return new Polygon(new LinearRing(tList.ToArray()));

       return null;
This is fine as I can just pad it out with the other geometry types, but I can't help but think someone must have written something like this already!


Feb 5, 2014 at 10:58 AM
yes you can find it here:

It should be in the GeoAPI.CoordinateSystems.Transformations namespace
Feb 5, 2014 at 12:55 PM
OK, got it thanks.