1.3.2 • Published 10 years ago

turf-erase v1.3.2

Weekly downloads
1,443
License
MIT
Repository
github
Last release
10 years ago

turf-erase

build status

erase features

turf.erase(poly1, poly2)

Finds the difference between two Polygon|polygons by clipping the second polygon from the first.

Parameters

parametertypedescription
poly1Feature.\<Polygon>input Polygon feaure
poly2Feature.\<Polygon>Polygon feature to erase from poly1

Example

var poly1 = {
  "type": "Feature",
  "properties": {
    "fill": "#0f0"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-46.738586, -23.596711],
      [-46.738586, -23.458207],
      [-46.560058, -23.458207],
      [-46.560058, -23.596711],
      [-46.738586, -23.596711]
    ]]
  }
};
var poly2 = {
  "type": "Feature",
  "properties": {
    "fill": "#00f"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-46.650009, -23.631314],
      [-46.650009, -23.5237],
      [-46.509246, -23.5237],
      [-46.509246, -23.631314],
      [-46.650009, -23.631314]
    ]]
  }
};

var erased = turf.erase(poly1, poly2);
erased.properties.fill = '#f00';

var polygons = {
  "type": "FeatureCollection",
  "features": [poly1, poly2]
};

//=polygons

//=erased

Returns Feature.<Polygon>, a Polygon feature showing the area of poly1 excluding the area of poly2

Installation

Requires nodejs.

$ npm install turf-erase

Tests

$ npm test
1.3.2

10 years ago

1.3.1

10 years ago

1.3.0

11 years ago

1.2.0

11 years ago

1.1.0

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.0

11 years ago