{"id":23516366,"url":"https://github.com/mfogel/geojson-clipping","last_synced_at":"2025-04-19T16:27:36.477Z","repository":{"id":57249833,"uuid":"123588091","full_name":"mfogel/geojson-clipping","owner":"mfogel","description":"Apply boolean polygon clipping operations (union, intersection, difference, xor) to Polygons \u0026 MultiPolygons in your GeoJSON files.","archived":false,"fork":false,"pushed_at":"2018-04-02T01:51:03.000Z","size":341,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T09:49:37.417Z","etag":null,"topics":["boolean-operations","difference","geojson","intersection","polygon-clipping","union","xor"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfogel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-02T14:19:18.000Z","updated_at":"2023-12-06T03:05:44.000Z","dependencies_parsed_at":"2022-08-24T16:21:59.115Z","dependency_job_id":null,"html_url":"https://github.com/mfogel/geojson-clipping","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfogel%2Fgeojson-clipping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfogel%2Fgeojson-clipping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfogel%2Fgeojson-clipping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfogel%2Fgeojson-clipping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfogel","download_url":"https://codeload.github.com/mfogel/geojson-clipping/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249738286,"owners_count":21318501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boolean-operations","difference","geojson","intersection","polygon-clipping","union","xor"],"created_at":"2024-12-25T15:13:06.215Z","updated_at":"2025-04-19T16:27:36.457Z","avatar_url":"https://github.com/mfogel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# geojson-clipping\n\nApply boolean polygon clipping operations (`union`, `intersection`, `difference`, `xor`) to Polygons \u0026 MultiPolygons in your GeoJSON files.\n\n[![npm version](https://img.shields.io/npm/v/geojson-clipping.svg)](https://www.npmjs.com/package/geojson-clipping)\n[![build status](https://img.shields.io/travis/mfogel/geojson-clipping/master.svg)](https://travis-ci.org/mfogel/geojson-clipping)\n[![test coverage](https://img.shields.io/coveralls/mfogel/geojson-clipping/master.svg)](https://coveralls.io/r/mfogel/geojson-clipping)\n\n## Quickstart\n\n```sh\n$ npm install -g geojson-clipping\n$ cat poly1.geojson poly2.geojson | geojson-clipping union \u003e union.geojson\n```\n\n## Usage\n\n```sh\n$ geojson-clipping union        [-o \u003cpath\u003e] [\u003cpath\u003e ... ]\n$ geojson-clipping intersection [-o \u003cpath\u003e] [\u003cpath\u003e ... ]\n$ geojson-clipping xor          [-o \u003cpath\u003e] [\u003cpath\u003e ... ]\n$ geojson-clipping difference   [-o \u003cpath\u003e] [\u003cpath\u003e ... ] [ -s \u003cpath\u003e ]\n```\n\nInput/output streams:\n\n * `stdin`: Input GeoJSON objects, whitespace separated, may be piped in via `stdin`.\n * `stdout` Output GeoJSON is by default written to `stdout`.\n * `stderr`: Any warnings generated are by default written to `stderr`.\n\n### Input\n\nInput GeoJSON objects may be provided via:\n\n * the positional `\u003cpath\u003e` arguments, each of which may point to any of:\n   * a GeoJSON file\n   * a file with multiple GeoJSON objects in it, whitespace separated (ex: [ndjson](http://ndjson.org/))\n   * a directory, in which case any files with a `.geojson` extension found immediately within it will be used as input\n * `stdin` (objects may optionally be separated by whitespace)\n * the `-s / --subject \u003cpath\u003e` option, for the `difference()` operation only\n\nThe following [GeoJSON object types](https://tools.ietf.org/html/rfc7946#section-3) are acceptable input:\n\n * Polygon\n * MultiPolygon\n * Feature containing Polygon or MultiPolygon\n * FeatureCollection containing an array of acceptable Features\n\nIf a GeoJSON object with a different type is encountered (ex: Point) the offending object will be dropped and a warning will be printed to `stderr`.\n\n### Output\n\nThe computed GeoJSON is by default written to `stdout`, but may be redirected using the `-o / --output \u003cpath\u003e` option. The output GeoJSON will have the following properties:\n\n * it will be a single GeoJSON Feature object with a geometry of type MultiPolygon.\n * the Feature's properties attribute will be set to `null`.\n * if the geometry of resulting from the operation is the empty set (ex: intersection of non-overlapping polygons) then the coordinates of the MultiPolygon will be `[]`.\n * it will have the [qualities guaranteed by polygon-clipping](https://github.com/mfogel/polygon-clipping#output).\n\n## Options\n\n### `-s / --subject \u003cpath\u003e`\n\nValid *only* for `difference()` operation. Invalid for other operations.\n\nUse the file identified by `\u003cpath\u003e` as input GeoJSON, and consider it to be the `subject` in the `difference()` operation. That is to say, all other GeoJSON objects will be subtracted from this GeoJSON object.\n\nIf this option is not supplied, the `subject` will by default be the first GeoJSON object read in from `stdin`.\n\n### `-b / --bboxes`\n\nValid *only* for `difference()` operation. Invalid for other operations.\n\nScan input GeoJSON filenames for pre-computed stringified [bounding boxes](https://tools.ietf.org/html/rfc7946#section-5). If no bounding box is found in the filename, then compute a bounding box from the GeoJSON coordinates. Examples of filenames containing bounding boxes:\n\n* `[-10,-10,10,10].json`\n* `424242.[-58.5314588,-34.705637,-58.3351249,-34.5265535].geojson`\n\nIf a the bounding box of a given GeoJSON object does not overlap the bounding box of the `subject`, that GeoJSON object is dropped from the calculation as it cannot contribute to the end result, resulting in a performance boost. In the case that the bounding box was extracted from the filename, the non-contributing GeoJSON object is dropped *without* reading the file in from disk.\n\n### `-o / --output \u003cpath\u003e`\n\nWrite the output GeoJSON object out to a newly-created file located at `\u003cpath\u003e`.\n\nIf this option is not supplied, the ouput GeoJSON will be written to `stdout`.\n\n### `-i / --id \u003cid\u003e`\n\nAdd to the output GeoJSON object the [Feature id](https://tools.ietf.org/html/rfc7946#section-3.2) `\u003cid\u003e`. If `\u003cid\u003e` can be parsed as a number it will be written into the output GeoJSON as a number, else it will be written out as a string.\n\nIf this option is not supplied, the output GeoJSON will not have a Feature id.\n\n### `-q / --quiet`\n\nSuppress any warnings generated.\n\nIf this option is not supplied, any warnings generated will be written to `stderr`.\n\n### `-h / --help`\n\nDisplay help message and exit.\n\n### `-v / --version`\n\nDisplay version string and exit.\n\n## Examples\n\nEquivalent ways to take the `union` of three GeoJSON objects:\n\n```sh\n$ cat poly1.geojson poly2.geojson poly3.geojson | geojson-clipping union \u003e union.geojson\n$ geojson-clipping union poly1.geojson poly2.geojson poly3.geojson \u003e union.geojson\n$ geojson-clipping union -o union.geojson poly1.geojson poly2.geojson poly3.geojson\n```\n\nEquivalent ways to take the `difference` (aka subtract) a directory full of GeoJSON objects from another GeoJSON object:\n\n```sh\n$ cat subject.geojson | geojson-clipping difference ./directory-with-geojson-files \u003e difference.geojson\n$ geojson-clipping difference -s subject.geojson -o difference.geojson ./directory-with-geojson-files\n```\n\n## Changelog\n\n### 0.3 (2018-04-01)\n\n* Performance improvements\n* enhance `-b / --bboxes` to better support bounding boxes that cross the antimeridian [#4](https://github.com/mfogel/geojson-clipping/issues/4)\n\n### 0.2 (2018-03-09)\n\n* add `-i / --id \u003cid\u003e` option [#3](https://github.com/mfogel/geojson-clipping/issues/3)\n* add `-b / --bboxes` option for `difference()` operation [#2](https://github.com/mfogel/geojson-clipping/issues/2)\n* create output directories as needed [#1](https://github.com/mfogel/geojson-clipping/issues/1)\n\n### 0.1 (2018-03-07)\n\n* Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfogel%2Fgeojson-clipping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfogel%2Fgeojson-clipping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfogel%2Fgeojson-clipping/lists"}