How to use the @turf/triangle-grid function in @turf/triangle-grid

To help you get started, we’ve selected a few @turf/triangle-grid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Turfjs / turf / packages / turf-interpolate / index.js View on Github external
switch (gridType) {
    case 'point':
    case 'points':
        grid = poinGrid(box, cellSize, {units: units, bboxIsMask: true});
        break;
    case 'square':
    case 'squares':
        grid = squareGrid(box, cellSize, {units: units});
        break;
    case 'hex':
    case 'hexes':
        grid = hexGrid(box, cellSize, {units: units});
        break;
    case 'triangle':
    case 'triangles':
        grid = triangleGrid(box, cellSize, {units: units});
        break;
    default:
        throw new Error('invalid gridType');
    }
    var results = [];
    featureEach(grid, function (gridFeature) {
        var zw = 0;
        var sw = 0;
        // calculate the distance from each input point to the grid points
        featureEach(points, function (point) {
            var gridPoint = (gridType === 'point') ? gridFeature : centroid(gridFeature);
            var d = distance(gridPoint, point, units);
            var zValue;
            // property has priority for zValue, fallbacks to 3rd coordinate from geometry
            if (property !== undefined) zValue = point.properties[property];
            if (zValue === undefined) zValue = point.geometry.coordinates[2];

@turf/triangle-grid

turf triangle-grid module

MIT
Latest version published 5 months ago

Package Health Score

94 / 100
Full package analysis

Popular @turf/triangle-grid functions