Assembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public static class GeodesicUtilities |
Visual Basic (Declaration) |
---|
Public NotInheritable Class GeodesicUtilities |
Remarks
The Polyline.Length and Polygon.Area properties use the units of the inherited CoordinateSystem property to determine the units of the returned length or area, for example length in meters or area in square meters.
If a Geometry has a geographic coordinate system (which has angular units), measurements based on this Geometry, for example length, area, and distances, are not coherent values; 1 degree of latitude varies slightly, and 1 degree of longitude varies greatly between the equator and the poles. For example, if you were to compare the Length of two polylines representing two roads in different locations on the earth to find out which was the shorter distance to drive, you would need to get distance in linear units in order to get a comparable measurement and find out which one is really the shortest; a distance in angular units could be misleading.
For this reason, Geometries with geographic coordinate systems (which use angular units) will throw an exception from the Length and Area properties. The GeodesicUtilties class offers an alternative way to get measurements, returning the measurement in the linear units of your choice.
Note that for convenience, the GeodesicUtilities class can also now be used with geometries that have linear units.
Examples
// Create a Polygon with a projected coordinate system. IEnumerable<ESRI.ArcGISExplorer.Geometry.Point> bngPoints = new ESRI.ArcGISExplorer.Geometry.Point[] { new ESRI.ArcGISExplorer.Geometry.Point(326872.482358681, 673940.581779784), new ESRI.ArcGISExplorer.Geometry.Point(326937.296501129, 673957.506541019), new ESRI.ArcGISExplorer.Geometry.Point(326953.836608697, 673895.000320552), new ESRI.ArcGISExplorer.Geometry.Point(326889.407119913, 673876.536944667), new ESRI.ArcGISExplorer.Geometry.Point(326887.099197928, 673887.307247264), new ESRI.ArcGISExplorer.Geometry.Point(326897.677173697, 673890.769130243), new ESRI.ArcGISExplorer.Geometry.Point(326884.791275943, 673934.23499432), new ESRI.ArcGISExplorer.Geometry.Point(326874.597953836, 673932.311725998), new ESRI.ArcGISExplorer.Geometry.Point(326872.482358681, 673940.581779784) }; Polygon bngPolygon = new Polygon(bngPoints, CoordinateSystem.ProjectedCoordinateSystems.NationalGrids.Europe.BritishNationalGrid); // For geometries with projected coordinate systems, the Area can be retrieved directly. // British national grid uses Meters as its unit. double bngArea = bngPolygon.Area; // Project the polygon to create a geometry with a geographic coordinate system. Polygon wgs84Polygon = (Polygon)GeometryOperations.Project(bngPolygon, CoordinateSystem.GeographicCoordinateSystems.World.WGS1984, new GeographicTransformation(1195)); // Use GeodesicUtilities to get Area for a geometry with a geographic coordinate system, // which has angular units double wgs84Area = GeodesicUtilities.Area(wgs84Polygon, Unit.Area.SquareMeters);
' Create a Polygon with a projected coordinate system. Dim bngPoints As IEnumerable(Of ESRI.ArcGISExplorer.Geometry.Point) = New ESRI.ArcGISExplorer.Geometry.Point() { _ New ESRI.ArcGISExplorer.Geometry.Point(326872.482358681, 673940.581779784), _ New ESRI.ArcGISExplorer.Geometry.Point(326937.296501129, 673957.506541019), _ New ESRI.ArcGISExplorer.Geometry.Point(326953.836608697, 673895.000320552), _ New ESRI.ArcGISExplorer.Geometry.Point(326889.407119913, 673876.536944667), _ New ESRI.ArcGISExplorer.Geometry.Point(326887.099197928, 673887.307247264), _ New ESRI.ArcGISExplorer.Geometry.Point(326897.677173697, 673890.769130243), _ New ESRI.ArcGISExplorer.Geometry.Point(326884.791275943, 673934.23499432), _ New ESRI.ArcGISExplorer.Geometry.Point(326874.597953836, 673932.311725998), _ New ESRI.ArcGISExplorer.Geometry.Point(326872.482358681, 673940.581779784)} Dim bngPolygon As Polygon = New Polygon(bngPoints, _ CoordinateSystem.ProjectedCoordinateSystems.NationalGrids.Europe.BritishNationalGrid) ' For geometries with projected coordinate systems, the Area can be retrieved directly. ' British national grid uses Meters as its unit. Dim bngArea As Double = bngPolygon.Area ' Project the polygon to create a geometry with a geographic coordinate system. Dim wgs84Polygon As Polygon = DirectCast(GeometryOperations.Project(bngPolygon, _ CoordinateSystem.GeographicCoordinateSystems.World.WGS1984, New GeographicTransformation(1195)), Polygon) ' Use GeodesicUtilities to get Area for a geometry with a geographic coordinate system, ' which has angular units Dim wgs84Area As Double = GeodesicUtilities.Area(wgs84Polygon, Unit.Area.SquareMeters)