Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

springmeyer/arc.js

great circle routes in javascript

springmeyer/arc.js.json
{
"createdAt": "2011-06-10T06:12:40Z",
"defaultBranch": "main",
"description": "great circle routes in javascript",
"fullName": "springmeyer/arc.js",
"homepage": "http://springmeyer.github.io/arc.js/",
"language": "TypeScript",
"name": "arc.js",
"pushedAt": "2026-06-02T15:19:49Z",
"stargazersCount": 384,
"topics": [],
"updatedAt": "2026-06-02T15:23:54Z",
"url": "https://github.com/springmeyer/arc.js"
}

Calculate great circle routes as lines in GeoJSON or WKT format.

🌍 Try the interactive demo - Click to plot great circle arcs on a map!

Features:

  • Full TypeScript support with type definitions
  • Works in Node.js and browsers
  • Generates GeoJSON and WKT output formats
  • Handles dateline crossing automatically
  • Based on Ed Williams’ Aviation Formulary algorithms
Terminal window
npm install arc
import { GreatCircle } from 'arc';
const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39});
const line = gc.Arc(); // npoints is optional, defaults to 100
console.log(line.json()); // GeoJSON output
import { GreatCircle, CoordinatePoint } from 'arc';
const start: CoordinatePoint = { x: -122, y: 48 };
const end: CoordinatePoint = { x: -77, y: 39 };
const gc = new GreatCircle(start, end);
const line = gc.Arc(100);
<script type="module">
import { GreatCircle } from 'https://cdn.skypack.dev/arc@1';
const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39});
const line = gc.Arc();
</script>

Coordinates use x for longitude and y for latitude (both in degrees):

const start = { x: -122, y: 48 }; // Seattle
const end = { x: -77, y: 39 }; // Washington DC
const gc = new GreatCircle(start, end, { name: 'Seattle to DC' });
const line = gc.Arc(); // defaults to 100 points
const line = gc.Arc(500); // or specify a custom value

Parameters:

  • npoints (number, optional): Number of intermediate points (higher = more precise, default: 100)
import { GreatCircle, CoordinatePoint, ArcOptions } from 'arc';
// Define custom properties interface
interface RouteProperties {
name: string;
color?: string;
}
const start: CoordinatePoint = { x: -122, y: 48 };
const end: CoordinatePoint = { x: -77, y: 39 };
const properties: RouteProperties = { name: 'Seattle to DC', color: 'blue' };
const gc = new GreatCircle(start, end, properties);
const line = gc.Arc(); // npoints is optional, defaults to 100
// Fully typed return values
const geojson = line.json(); // GeoJSONFeature
const wkt = line.wkt(); // string

Available Types: CoordinatePoint, ArcOptions, Coord, GreatCircle, Arc, GeoJSONFeature

The generated arc contains intermediate coordinate pairs:

{
properties: { name: 'Seattle to DC' },
geometries: [
{
coords: [
[-122, 48],
[-112.06162, 47.724167],
[-102.384043, 46.608132],
[-93.227189, 44.716217],
[-84.74824, 42.144155],
[-77, 39]
],
length: 6
}
]
}
const geojson = line.json();
// Returns:
{
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [[-122, 48], [-112.06162, 47.724167], ...]
},
properties: { name: 'Seattle to DC' }
}
const wkt = line.wkt();
// Returns:
'LINESTRING(-122 48,-112.061619 47.724167,-102.384043 46.608131,...)'

Routes that cross the international dateline are automatically detected and split into a MultiLineString with exact ±180° boundary points. No configuration is needed.

See the interactive demo for sample code showing how to create GeoJSON feature collections from multiple routes.

arc.js powers the greatCircle function in Turf.js, a popular geospatial JavaScript library. You can use great circle calculations directly through Turf:

This project is licensed under the BSD license. See [LICENSE.md]!(LICENSE) for details.