Skip to content

turf-junkyard/turf-hex-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

turf-hex-grid

build status

turf.hex-grid(bbox, cellWidth, units, triangles)

Takes a bounding box and a cell size in degrees and returns a FeatureCollection of flat-topped hexagons (Polygon features) aligned in an "odd-q" vertical grid as described in Hexagonal Grids.

Parameters

parameter type description
bbox Array.<number> bounding box in [minX, minY, maxX, maxY] order
cellWidth Number width of cell in specified units
units String used in calculating cellWidth ('miles' or 'kilometers')
triangles Boolean generate hexgrid triangles instead of hexagons

Example

var bbox = [-96,31,-84,40];
var cellWidth = 50;
var units = 'miles';

var hexgrid = turf.hexGrid(bbox, cellWidth, units);

//=hexgrid

Returns FeatureCollection.<Polygon>, a hexagonal grid

Installation

Requires nodejs.

$ npm install turf-hex-grid

Tests

$ npm test

About

Generates a hexgrid that covers the specified bbox

Resources

License

Stars

Watchers

Forks

Packages

No packages published