Giter Site home page Giter Site logo

urschrei / geojson_d3 Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 2.15 MB

Make RFC 7946 GeoJSON (Multi)Polygons d3-geo-compatible, or vice versa

License: MIT License

Shell 20.71% PowerShell 4.25% Rust 75.04%
geojson d3 gis geometry geometry-processing d3-geo

geojson_d3's Introduction

Linux / macOS Build Status Windows Build status Crates Link

GeoJSON_d3

Introduction

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.

Installation

Install it using cargo install geojson_d3, or download a binary and put it on your $PATH.
This provides the geojson_d3 command.

Use

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.

  • No assumptions are made concerning the existing winding order of Polygon rings:

    • By default, output will be in d3-geo-compliant winding order
    • If -r or --reverse are specified, output will be in RFC 7946 order
  • Processing of nested GeometryCollections is supported, but you shouldn't be using those

  • Empty geometries or collections will be left unaltered

  • Non-(Multi)Polygon geometries are left unaltered

  • All input properties are preserved

Progress

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

Validity

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.

Speed

The included NYC Boroughs file (~69k Points) is processed in ~140 ms on a dual-core 1.8 GHz Intel Core i7.

Binaries

Pre-built binaries are available from releases. Binaries are available for:

  • macOS (x86_64)
  • Linux (x86_64)
  • Windows (x86_64 and i686)

License

MIT

geojson_d3's People

Contributors

urschrei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.