1.0.1 • Published 9 years ago

turf-max v1.0.1

Weekly downloads
1,434
License
MIT
Repository
github
Last release
9 years ago

turf-max

build status

turf max module

turf.max(polygons, points, inField, outField)

Calculates the maximum value of a field for points within a set of polygons.

Parameters

parametertypedescription
polygonsFeatureCollectiona FeatureCollection of Polygon features
pointsFeatureCollectiona FeatureCollection of Point features
inFieldstringthe field in input data to analyze
outFieldstringthe field in which to store results

Example

var polygons = turf.featurecollection([
  turf.polygon([[
    [101.551437, 3.150114],
    [101.551437, 3.250208],
    [101.742324, 3.250208],
    [101.742324, 3.150114],
    [101.551437, 3.150114]
  ]]),
  turf.polygon([[
    [101.659927, 3.011612],
    [101.659927, 3.143944],
    [101.913986, 3.143944],
    [101.913986, 3.011612],
    [101.659927, 3.011612]
  ]])
]);
var points = turf.featurecollection([
  turf.point([101.56105, 3.213874], {population: 200}),
  turf.point([101.709365, 3.211817], {population: 600}),
  turf.point([101.645507, 3.169311], {population: 100}),
  turf.point([101.708679, 3.071266], {population: 200}),
  turf.point([101.826782, 3.081551], {population: 300})]);

var aggregated = turf.max(
  polygons, points, 'population', 'max');

var result = turf.featurecollection(
  points.features.concat(aggregated.features));

//=result

Installation

Requires nodejs.

$ npm install turf-max

Tests

$ npm test
1.0.1

9 years ago

1.0.0

9 years ago

0.1.2

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago