Home

Awesome

rfc7946-to-d3

Converts polygon winding order between RFC7946 geojson and D3 compatible conventions.

Why

D3 assumes GeoJSON polygon coordinates to be sorted in a clockwise order, while rfc7946 GeoJSON assumes the opposite (counterclockwise or right-hand-rule winding). This difference causes issues for example when calculating bounding boxes or applying projections on such polygons.

This module converts between the two convertions by simply reversing the order of all (multi)polygon linear rings of the given input.

Usage

install:

npm install --save rfc7946-to-d3

api:

A function that takes in rfc7946 geojson and spits out d3 compatible geojson (input is modified in place!).

install:

[sudo] npm install -g rfc7946-to-d3

use:

rfc7946-to-d3 < rfc7946.geojson > d3.geojson

See also