grid-to-matrix
![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)
Takes a Point grid and returns a correspondent matrix of the property
values
Parameters
grid
[FeatureCollection<Point>] grid of pointsoptions.zProperty
[string] the property name in grid
from which the matrix values will be pulled (optional, default elevation
)options.flip
[boolean] returns the matrix upside-down (optional, default false
)options.flags
[boolean] , adding a matrixPosition
array field ([row
, column
]) to its properties, the grid points with coordinates on the matrix (optional, default false
)
Returns
Matrix [Array<Array<<number>>] of the grid
points property
values
Installation
npm
$ npm install grid-to-matrix
browser (ES5)
<script src="https://unpkg.com/grid-to-matrix/grid-to-matrix.min.js"></script>
Quickstart
var pointGrid = require('@turf/point-grid');
var gridToMatrix = require('grid-to-matrix');
var extent = [-70.823364, -33.553984, -70.473175, -33.302986];
var cellSize = 3;
var grid = pointGrid(extent, cellSize);
for (var i = 0; i < grid.features.length; i++) {
grid.features[i].properties.elevation = (Math.random() * 60);
}
gridToMatrix(grid);