Utility class for projecting geometry.
Object Model
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As Projection |
Example
This example projects two points within a Multipoint from geographic (WGS84) to Robinson. Once projected, the points or Multipoint may be displayed on a map which is set to the destination projection (Robinson in this case), used in a query on data in the destination projection, etc. The code assumes an existing MapView object.
C# | Copy Code |
---|
// Get the connection object from the MapView
ESRI.ArcGIS.ADF.Connection.IMS.IMSServerConnection imsConnection = mapView.MapService.Connection;
// Create a geometry object in decimal degrees (WGS84) - add points to a Multipoint
ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint multiPt = new ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint();
ESRI.ArcGIS.ADF.IMS.Geometry.Point pt1 = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(-110.0, 34.0);
ESRI.ArcGIS.ADF.IMS.Geometry.Point pt2 = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(-75.0, 20.0);
multiPt.Points.Add(pt1);
multiPt.Points.Add(pt2);
// Set spatial reference (degrees/WGS84) of the geometry we will project -- this is required
multiPt.SpatialReference = new ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(4326);
// Set up the destination spatial reference (Robinson)
ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference spRef =
new ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(54030);
// Create an Environment object using machine settings for culture
ESRI.ArcGIS.ADF.IMS.Administration.Environment envir =
new ESRI.ArcGIS.ADF.IMS.Administration.Environment(true);
// Project the geometry to Robinson projection
ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint projectedMultiPt = (ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint)
ESRI.ArcGIS.ADF.IMS.Projection.Projection.Project(multiPt, spRef, imsConnection, envir); |
Visual Basic | Copy Code |
---|
' Get the connection object from the MapView
Dim imsConnection As ESRI.ArcGIS.ADF.Connection.IMS.IMSServerConnection _
= mapView.MapService.Connection
' Create a geometry object in decimal degrees (WGS84) - add points to a Multipoint
Dim multiPt As New ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint()
Dim pt1 As New ESRI.ArcGIS.ADF.IMS.Geometry.Point(-110.0, 34.0)
Dim pt2 As New ESRI.ArcGIS.ADF.IMS.Geometry.Point(-75.0, 20.0)
multiPt.Points.Add(pt1)
multiPt.Points.Add(pt2)
' Set spatial reference (degrees/WGS84) of the geometry we will project -- this is required
multiPt.SpatialReference = New ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(4326)
' Set up the destination spatial reference (Robinson)
Dim spRef As ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference = _
New ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(54030)
' Create an Environment object using machine settings for culture
Dim envir As New ESRI.ArcGIS.ADF.IMS.Administration.Environment(True)
' Project the geometry to Robinson projection
Dim projectedMultiPt As ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint = _
CType (ESRI.ArcGIS.ADF.IMS.Projection.Projection.Project( _
multiPt, spRef, imsConnection, envir), _
ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint) |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also