Geodesic operations

View inWPFUWPFormsiOSAndroid
View on GitHub

Calculate a geodesic path between two points and measure its distance.

Image of geodesic operations

Use case

A geodesic distance provides an accurate, real-world distance between two points. Visualizing flight paths between cities is a common example of a geodesic operation since the flight path between two airports takes into account the curvature of the earth, rather than following the planar path between those points, which appears as a straight line on a projected map.

How to use the sample

Tap anywhere on the map. A line graphic will display the geodesic line between the two points. In addition, text that indicates the geodesic distance between the two points will be updated. Tap elsewhere and a new line will be created.

How it works

  1. A Point is created in New York City and displayed as a Graphic.
  2. When a tap occurs on the MapView, a new Point is obtained from the mouse click. This Point is added as a Graphic.
  3. A Polyline is created with the two Point objects.
  4. GeometryEngine.DensifyGeodetic is executed by passing in the Polyline object, and the returned Geometry is added as a Graphic.
  5. GeometryEngine.LengthGeodetic is executed by passing in the two Point objects, and the returned number is displayed on the screen.

Relevant API

  • GeometryEngine.DensifyGeodetic
  • GeometryEngine.LengthGeodetic

About the data

The Imagery basemap provides the global context for the displayed geodesic line.


densify, distance, geodesic, geodetic

Sample Code

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        <Label  x:Name="ResultsLabel"
                Grid.Row="0" HorizontalTextAlignment="Center"
                TextColor="Red">Tap to set an end point.</Label>
        <forms:MapView Grid.Row="1" x:Name="MyMapView" />