How to project a geometry to a different coordinate system


Summary
This topic shows how to project a geometry from its existing coordinate system to another coordinate system, and when it is most appropriate to do so.

In this topic


To use the code in this topic, add references to ESRI.ArcGISExplorer.dll and ESRI.ArcGISExplorer.Application.dll. Also add the following namespace references via using (C#) or Imports (VB .NET) statements:
  • ESRI.ArcGISExplorer.Geometry

Projecting a geometry

Using the GeometryOperations class, part of the ESRI.ArcGISExplorer.Geometry namespace, you can project a geometry from one coordinate system to another, as shown in the following code example:
[C#]
// Create an initial geometry—this has the WGS84 default coordinate system.
ESRI.ArcGISExplorer.Geometry.Point webMercPt = new
                                   ESRI.ArcGISExplorer.Geometry.Point( - 70.216714, 43.680107); 
                                   //portland, maine

// Create a coordinate system used in that location.
CoordinateSystem maine =
    CoordinateSystem.ProjectedCoordinateSystems.StatePlane.NAD1983Meters.NAD1983Maine2000EastZoneMeters;

// Reproject this point to a new Point object with the Maine coordinate system.
ESRI.ArcGISExplorer.Geometry.Point portlandNad83 = GeometryOperations.Project
    (webMercPt, maine)as ESRI.ArcGISExplorer.Geometry.Point;
[VB.NET]
' Create an initial geometry—this has the WGS84 default coordinate system.
Dim webMercPt As Point = New Point( -70.216714, 43.680107) ' Portland, Maine.

' Create a coordinate system used in that location.
Dim maine As CoordinateSystem = CoordinateSystem.ProjectedCoordinateSystems.StatePlane.NAD1983Meters.NAD1983Maine2000EastZoneMeters

' Reproject this point to a new Point object with the Maine coordinate system.
Dim portlandNad83 As Point = GeometryOperations.Project(webMercPt, maine)

Determining when to project geometries

If a geometry has a different coordinate system to the MapDisplay in which it is drawn, it is automatically reprojected at draw time to display correctly in the MapDisplay. This automatic reprojection applies to the geometries used to draw Graphics, Notes, and MapItems. You do not need to add any code for these items to project correctly.
If you want to export geometries to other systems that require input in certain coordinate systems, you can use the Project method as shown.
Also, if you intend to work exclusively or predominately within a certain coordinate system, it might be beneficial to project geometries for use in Notes and Graphics to that coordinate system; however, remember the following:
  • In 3D mode, the MapDisplay always draws using the Web Mercator Aux Sphere geographic coordinate system. If you switch between this and a 2D mode where you have specified a different coordinate system, automatic reprojection occurs in one or another case.
  • You cannot edit or create FeatureLayers using ArcGIS Explorer; therefore, you can only manually reproject the geometries that then displays in Graphics or Notes.
Often, it is more efficient and simpler to let ArcGIS Explorer handle reprojecting geometries for you; therefore, consider your reasons for reprojecting geometries.

Using geographic transformations

The Project method is overloaded, and can optionally take a specific GeographicTransformation, which is a mathematical model that can increase the accuracy of the transformation of a reprojection. For example, the following illustrations show the same set of road data over a basemap with data in a different coordinate system. The first illustration has no GeographicTransformation applied and the second illustration uses a transformation:
The MapDisplay has GeographicTransformations2D and GeographicTransformations3D properties. Any GeographicTransformations in these collection properties will be used in the automatic reprojection of Graphics or MapItems.
The simplest way to see which transformations are available for a specific dataset is to use the GeographicTransformation.GetTransformations method. For more information, see the GeographicTransformation class topic. 


See Also:

Coordinate system concepts
Geometry namespace overview
GeometryOperations class
CoordinateSystem class
GeographicTransformation class