hextile
Generate tile representations of polygon objects on map
Usage
Refer to IETF's RFC7946 for accepted format of geojson input.
// alternatively, pass in a bounding box (bbox) input const southWest = 103582 116const northEast = 1041647 148073const bbox = southWest0 southWest1 northEast0 northEast1
Options
/** * @param {('square'|'hexagon')} options.shape - default 'square' * @param * @param * @param {[number, number]} options.center - [lon, lat] of grid origin * @param * @param * @param */
options.shape
options.width
options.tilt
options.center
// used when projecting lonlat to grid coordinates// by default is set to center of geojson's bbox// here we choose a latitude far away from equator// to illustrate the distortion due to Earth's spherical nature
options.projection
By default, we use equirectangular projection (also called the equidistant cylindrical projection) for conversion between lonlat and grid coordinates based on the width and center supplied by options. When area is large and covers a wide range of latitudes (eg. the Africa continent), this projection method may not be ideal. Hence we provide an option to overwrite the default projection method.
projection object should exposes two methods forward and inverse (similar to Proj4js) which will be used internally by the hextile function for conversion between lonlat and grid coordinates.
Output
Output is an array of geojson features each representing one grid tile.
Eg.
CLI
> hextile -h
Usage: hextile [options] <infile> <outfile>
Generate tile representations of polygon objects on map
Options:
-h, --help output usage information
-s --shape <shape> square or hexagon tile
-w --width <metre> set tile width
-t --tilt <deg> rotate tile
-c --center <longitude,latitude> center map at