Convert Coordinates between Geographic coordinate system and Projected coordinate system

Projected to Geographic co-ordinate system

IPoint iPoint = new ESRI.ArcGIS.Geometry.Point();
iPoint.X = x;
iPoint.Y = y;
ISpatialReferenceFactory pSpatRefFact = new SpatialReferenceEnvironmentClass();
ISpatialReference pGeoCoordSystem = pSpatRefFact.CreateGeographicCoordinateSystem(4269);//Nad83
// For more esriSRGeoCSType Constants see
//http://edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriGeometry/esriSRGeoCSType.htm
IGeometry2 pGeometry = iPoint as Igeometry2;
pGeometry.SpatialReference = pSpatRefFact.CreateProjectedCoordinateSystem(2278);
//For more esriSRProjCSType Constants see
//http://edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriGeometry/esriSRProjCSType.htm
pGeometry.ProjectEx(pGeoCoordSystem, esriTransformDirection.esriTransformReverse, null, false, 0, 0);
IPoint GCSPoint = pGeometry as IPoint;
double lat = GCSPoint.Y;
double lng = GCSPoint.X;


Geographic to Projected co-ordinate system

ESRI.ArcGIS.Geometry.Point point1 = new ESRI.ArcGIS.Geometry.Point();
point1.X = x;
point1.Y = y;
ISpatialReferenceFactory pSpatRefFact = new SpatialReferenceEnvironmentClass();
ISpatialReference pProjCoordSystem = pSpatRefFact.CreateProjectedCoordinateSystem(53004);
// Mercator
//For more esriSRProjCSType Constants see
//http://edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriGeometry/esriSRProjCSType.htm
//Create a geometry object and project it.
IGeometry2 pGeometry = (IGeometry2)point1;
pGeometry.SpatialReference = pSpatRefFact.CreateGeographicCoordinateSystem(4326); // WGS_1984
// For more esriSRGeoCSType Constants see
//http://edndoc.esri.com/arcobjects/9.1/ComponentHelp/esriGeometry/esriSRGeoCSType.htm
pGeometry.ProjectEx(pProjCoordSystem, esriTransformDirection.esriTransformReverse, null, false, 0, 0);
ESRI.ArcGIS.Geometry.Point PCSPoint = pGeo as ESRI.ArcGIS.Geometry.Point;

0 comments:

The views and content on my site are my own and do not represent those of my employer. All content is provided "AS-IS" with no warranties and confers no rights.