npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

arc

v1.0.0

Published

draw great circle arcs

Downloads

1,466,910

Readme

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

Installation

npm install arc

Quick Start

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

TypeScript

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);

Browser (ESM)

<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>

API Reference

Basic Usage

1. Define coordinates

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

2. Create a GreatCircle

const gc = new GreatCircle(start, end, { name: 'Seattle to DC' });

3. Generate the arc

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)

TypeScript Support

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

Output Formats

Raw Arc Object

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
    }
  ]
}

GeoJSON Format

const geojson = line.json();
// Returns:
{
  type: 'Feature',
  geometry: {
    type: 'LineString',
    coordinates: [[-122, 48], [-112.06162, 47.724167], ...]
  },
  properties: { name: 'Seattle to DC' }
}

WKT Format

const wkt = line.wkt();
// Returns:
'LINESTRING(-122 48,-112.061619 47.724167,-102.384043 46.608131,...)'

Dateline Crossing

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

Examples

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

Used in Turf.js

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

License

This project is licensed under the BSD license. See LICENSE.md for details.