Skip to content

GeoJSON Length Calculator

Calculate the total length of GeoJSON LineStrings in meters and kilometers.

Skip to the tool

Distances here are geodesic, computed along great circles on the WGS 84 ellipsoid. The common shortcut of treating degrees as a flat grid overstates east-west distances away from the equator, because a degree of longitude shrinks as latitude rises while a degree of latitude does not.

Metres, kilometres and miles come back for the whole input, with a per-feature table when there is more than one line to measure. Polygon boundaries count as length; standalone points do not.

How Length Calculation Works

This tool measures the geodesic length of LineString and MultiLineString features in your GeoJSON. It calculates the true distance along the Earth's surface using the WGS 84 ellipsoid, accounting for the curvature of the Earth. Results are shown in meters, kilometers, and miles.

For FeatureCollections containing more than one line, you get the combined total and a per-feature table beneath it. Polygon boundaries are measured too, so a collection of parcels returns their perimeters. The measurement walks each segment between consecutive coordinates, summing the geodesic distance for each pair using Turf.js's length function.

Geodesic vs. Planar Distance

Geodesic distance follows the curvature of the Earth, giving accurate results for any scale. Planar distance treats coordinates as flat x/y values, which introduces significant errors for features that span large distances. This tool always uses geodesic measurement.

For short distances (under a few kilometers), the difference is negligible. For cross-country routes or ocean paths, the geodesic calculation can differ from planar by several percent. A New York to London flight path measured with planar math would be off by hundreds of kilometers compared to the true great-circle distance.

Understanding the Results

The tool reports length in three units simultaneously:

  • Meters: the base SI unit, best for short distances like trails, building perimeters, and city blocks
  • Kilometers: standard for road distances, hiking routes, and infrastructure planning
  • Miles: commonly used in the United States and United Kingdom for road and travel distances

If you need other units such as nautical miles or feet, convert from the meter value. One nautical mile equals 1,852 meters. One foot equals 0.3048 meters.

What Gets Measured in Practice

  • Measuring road or trail distances from route GeoJSON
  • Calculating river or coastline lengths
  • Estimating pipeline or cable run distances
  • Verifying distances from routing API responses
  • Computing total border length between adjacent regions
  • Checking GPS track accuracy by comparing recorded vs. expected distances

Measuring Length in Your Own Code

In JavaScript with Turf.js:

JavaScriptconst km = turf.length(lineFeature, { units: 'kilometers' });
const miles = turf.length(lineFeature, { units: 'miles' });

In Python with Shapely and pyproj:

Pythonfrom shapely.geometry import shape
from pyproj import Geod
geod = Geod(ellps="WGS84")
line = shape(geojson_geometry)
length_m = geod.geometry_length(line)

To measure area instead of length, use the area calculator. To find the center point of a line, try the centroid calculator.