## What is a length and area analysis?

A length and area analysis is the process of calculating the planar or geodesic distance for a line or area for a polygon. To execute the analysis, you can use ArcGIS Maps SDK for JavaScript, ArcGIS Maps SDKs for Native Apps, or ArcGIS API for Python. See the code examples below.

## How to measure length and area

The length of a line and area of a polygon depends on the coordinate system used to define the shape's geometry. For example, if you measure the area of Lake Superior in one coordinate system, and compare the result to an area measurement in another coordinate system, then both results will likely differ because they involve different coordinates.

Since each coordinate system will yield different measurement results, you need to ensure the geometries being measured use a coordinate system that gives you the most accurate results given their locations.

There are two types of length and area calculations you can perform: planar and geodesic.

### Planar measurement

Planar calculations measure all lengths and areas on a flat 2D plane. Therefore all measurements use linear or Euclidean distances. Planar calculations only work for measuring lengths and areas in geometries that have a defined projected coordinate system.

When measuring length, you should ensure the projected coordinate system of the input geometries **preserves distance**. When measuring area, you should ensure the projected coordinate system of the input geometries **preserves area**.

### Geodesic measurement

Geodesic calculations measure all lengths and areas using a spherical model of the earth (i.e. a spheroid). Therefore all measurements use angular units. Geodesic calculations only work for measuring lengths and areas in geometries that have a defined geographic coordinate system.

## Types of length and area operations

Operation | Description | Example |
---|---|---|

Area | Returns the planar or geodesic area for a polygon. | |

Distance | Returns the planar or geodesic distance between two geometries. | |

Length | Returns the planar or geodesic length of a polyline. |

## Code examples

### Calculate geodesic area

This example demonstrates how to calculate the geodesic area of the Bermuda Triangle when defined as a polygon with the Web Mercator Auxiliary Sphere coordinate system.

```
const area = geometryEngine.geodesicArea(polygon, "square-kilometers"); // Area: 1,145,170.28 square kilometers.
console.log("The area of the polygon is " + area.toFixed(2) + " square kilometers.");
```

### Calculate planar area

This example demonstrates how to calculate the planar area of any country in the world. Since the map projects the data to the Equal Earth projection, area is preserved. Therefore, the planar area measurement is most appropriate for this calculation.

```
const area = geometryEngine.planarArea(polygon, "square-kilometers");
```

### Calculate geodesic length

This example shows how to use the client-side geometry engine to calculate the geodesic length of a line projected to the Web Mercator Auxiliary Sphere spatial reference.

```
const length = geometryEngine.geodesicLength(line, "kilometers"); // Length: 932.47 kilometers
console.log("The length of the line is " + length.toFixed(2) + " kilometers.");
```

### Calculate planar length

This example shows how to label linear features with their planar length calculated in an Arcade expression. Arcade provides you with many geometry functions for measuring lengths and areas. You can also use it to perform other client-side spatial analyses.

Using planar length as opposed to geodesic length is appropriate here because the map is rendered in a State Plane coordinate system, which preserves distance and length.

```
labelExpressionInfo: {
expression: `
var l = Length($feature, 'feet')
Text(l, "#,### ft")
`
},
```