Converting one projection to other in MapXtreme .NET

UPDATED: July 30, 2018

There are a couple ways to transform the projection of a geometry in MapXtreme.NET. First, it is necessary to create MapInfo.Geometry.Coordsys objects to hold the projection information for the 'to' and 'from' coordinate systems:
MapInfo.Geometry.CoordSys coord1 = MapInfo.Engine.Session.Current.CoordSysFactory.CreateCoordSys("EPSG:32748");//UTM WGS84
MapInfo.Geometry.CoordSys coord2 = MapInfo.Engine.Session.Current.CoordSysFactory.CreateCoordSys("EPSG:4326");//LatLong WGS84

The EPSG (European Petroleum Survey Group) codes are one way of sending in projection information into the CoordSysFactory. The CreateCoordSys method is overloaded, affording several options when sending in projection information. The CoordSys objects can be used to convert the data. In these examples, Point objects will be used:

It is possible to convert a Point of one CoordSys to a different CoordSys using either of the following:
  • An overloaded constructor
MapInfo.Geometry.Point pt1 = new MapInfo.Geometry.Point(coord1,-82,105);
MapInfo.Geometry.Point pt2 = new MapInfo.Geometry.Point(coord2, pt1);
  • CopyPoint function of the Point object. Other geometries may have similarly named Copy functions, and all 'FeatureGeometry' objects inherit 'CopyFeatureGeometry' which would be useful if the object type is not known.
Dim pt1 As MapInfo.Geometry.Point = New MapInfo.Geometry.Point(coord1,-82,105)
Dim pt2 As MapInfo.Geometry.Point = pt1.CopyPoint(coord2)
  • Use a MapInfo.Geometry.'CoordinateTransform' object to do the transformation.
MapInfo.Geometry.CoordinateTransform transform1 = new MapInfo.Geometry.CoordinateTransform(coord1,coord2);
MapInfo.Geometry.DPoint dpt1 = transform1.CoordSys1ToCoordSys2(pt1.Centroid);
MapInfo.Geometry.Point pt2 = new MapInfo.Geometry.Point(coord2, dpt1);


Environment Details

Product Feature: Features



  • No Downloads