GeoJSON_d3
d3-geo
uses spherical (as opposed to planar) polygons, and expects the rings of input polygons which are smaller than a hemisphere to be oriented in a different order than the GeoJSON RFC 7946 specification, which can lead to unexpected errors. This binary checks the spherical area of RFC 7946-compliant Polygons, converting them to d3-geo
-compliant ring orientation if necessary, or vice-versa.
Install it using cargo install geojson_d3
, or download a binary and put it on your $PATH.
This provides the geojson_d3
command.
geojson_d3
takes one mandatory argument: a file containing valid GeoJSON. Polygon and / or MultiPolygon geometries can be included as a Feature,
or a Geometry
, or aFeatureCollection
or GeometryCollection
. You may mix geometries in a FeatureCollection
or GeometryCollection
.
You may also pass:
- -p
or --pretty
, which will pretty-print the GeoJSON output
- -s
or --stats-only
, which will output the number of labelled polygons, but will not output GeoJSON
- -r
or --reverse
, which will reverse the functionality, producing geometries with rings wound correctly according to RFC 7946.
d3-geo
-compliant winding order-r
or --reverse
are specified, output will be in RFC 7946 orderGeometryCollection
s is supported, but you shouldn't be using thoseIf you aren't piping the output of the command to a file, geojson_d3
will display progress of the parsing and processing steps in the terminal, as well as a final count of the processed (Multi)Polygons.
While the structure of the input GeoJSON is validated, individual geometries are not validated in the DE-9IM sense. If they self-intersect, have open rings etc., results are not guaranteed to be correct.
The included NYC Boroughs
file (~69k Points
) is processed in ~150 ms on a dual-core 1.8 GHz Intel Core i7.
Pre-built binaries are available from releases. Binaries are available for: - macOS (x8664) - Linux (x8664) - Windows (x86_64 and i686)