3.0.12 • Published 8 years ago

turf-tag v3.0.12

Weekly downloads
11,349
License
MIT
Repository
github
Last release
8 years ago

turf-tag

build status

turf tag module

turf.tag(points, polygons, polyId, containingPolyId)

Takes a FeatureCollection of Point features and a FeatureCollection of Polygon features and performs a spatial join.

Parameters

parametertypedescription
pointsFeatureCollectiona FeatureCollection of Point features
polygonsFeatureCollectiona FeatureCollection of Polygon features
polyIdStringproperty in polygons to add to joined Point features
containingPolyIdStringproperty in points in which to store joined property from `polygons

Example

var bbox = [0, 0, 50, 50];
// create a triangular grid of polygons
var triangleGrid = turf.tin(turf.grid(bbox, 10));
triangleGrid.features.forEach(function(f) {
  f.properties.fill = '#' +
    (~~(Math.random() * 16)).toString(16) +
    (~~(Math.random() * 16)).toString(16) +
    (~~(Math.random() * 16)).toString(16);
  f.properties.stroke = 0;
  f.properties['fill-opacity'] = 1;
});
var randomPoints = turf.random('point', 30, {
  bbox: bbox
});
var both = turf.featurecollection(
  triangleGrid.features.concat(randomPoints.features));

//=both

var tagged = turf.tag(randomPoints, triangleGrid,
                      'fill', 'marker-color');

//=tagged

Installation

Requires nodejs.

$ npm install turf-tag

Tests

$ npm test
3.0.12

8 years ago

3.0.10

8 years ago

3.0.5

8 years ago

3.0.1

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago