# arc

> draw great circle arcs

Latest version **1.0.0** (published 2026-04-13) · BSD license · 0 weekly downloads

## Install

```sh
npm install arc
pnpm add arc
yarn add arc
bun add arc
```

## Health

**Score 55/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-04-13 |
| First published | 2011-11-19 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 58.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 384 |
| Maintainers | springmeyer, jgravois, tmcw |
| Keywords | maps, spherical, globe, rhumb line, crow flies, great circle, typescript |

## Links

- npm: https://www.npmjs.com/package/arc
- Repository: https://github.com/springmeyer/arc.js
- Homepage: https://github.com/springmeyer/arc.js#readme
- Issues: https://github.com/springmeyer/arc.js/issues
- npm.io page: https://npm.io/package/arc

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-04-13
- 1.0.0-beta.1 (beta) — 2026-03-29
- 0.2.0 — 2025-09-23
- 0.1.4 — 2022-11-16
- 0.1.3 — 2022-05-09
- 0.1.2 — 2021-10-13
- 0.1.1 — 2018-06-20
- 0.1.0 — 2014-02-11
- 0.0.3 — 2014-01-24
- 0.0.2 — 2013-06-19
- 0.0.1 — 2011-11-19

## README

# arc.js

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

[**🌍 Try the interactive demo**](https://danespringmeyer.com/arc.js/) - 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](https://edwilliams.org/avform.htm#Intermediate) algorithms

## Installation

```bash
npm install arc
```

## Quick Start

```js
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
```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)
```html
<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):

```js
const start = { x: -122, y: 48 };  // Seattle
const end = { x: -77, y: 39 };     // Washington DC
```

#### 2. Create a GreatCircle
```js
const gc = new GreatCircle(start, end, { name: 'Seattle to DC' });
```

#### 3. Generate the arc
```js
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

```typescript
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:

```js
{
  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
```js
const geojson = line.json();
// Returns:
{
  type: 'Feature',
  geometry: {
    type: 'LineString',
    coordinates: [[-122, 48], [-112.06162, 47.724167], ...]
  },
  properties: { name: 'Seattle to DC' }
}
```

#### WKT Format
```js
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](https://danespringmeyer.com/arc.js/) for sample code showing how to create GeoJSON feature collections from multiple routes.

## Used in Turf.js

arc.js powers the [`greatCircle`](https://turfjs.org/docs/api/greatCircle) function in [Turf.js](https://turfjs.org/), 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](LICENSE) for details.

---
_Source: https://npm.io/package/arc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
