Home

npm jsdeliver license code size

banner

geogrid

geogrid is a JavaScript library that allows you to create regular grids with various patterns on a flat plane or on the globe. In addition, it provides geoprocessing functions to transfer GeoJSON data (points, lines, or polygons) onto these grids.

➡️ Installation

1. Via CDN

Include directly in your HTML:

<script src="https://cdn.jsdelivr.net/npm/geogrid" charset="utf-8"></script>

2. Via npm

Install with npm:

npm install geogrid

Then import in your JavaScript/TypeScript project:

import * as geogrid from "geogrid";

Or

import { pointstogrid, polygonstogrid, linestogrid } from "geogrid";

3. ES Modules

import * as geogrid from "https://cdn.jsdelivr.net/npm/geogrid@0.0.4/+esm";

4. In Observable Notebooks

geogrid = require("geogrid");

➡️ Functions

Planar grids

  • dot - The function create a regular dot grid.
  • hexbin - The function create a regular hexbin grid.
  • random - The function create a random grid.
  • square - The function create a regular square grid.
  • triangle - The function create a regular triangle grid.
  • diamond - The function create a regular diamond grid.

Globe grids

  • h3 - The function create a h3-js global grid.
  • square_sph - The function create a regular square global grid.

Operators

  • pointstogrid - Assigns points to grid cells and computes statistics per cell
  • linesstogrid - Assigns lines to a grid and computes statistics per cell
  • polygonstogrid - Assign polygons to a grid and compute statistics per cell

N.B.: All geometries must be in the same projection.

Helpers

  • project - Allows to project GeoJSON geometries.

➡️ Usage

Find an example here.

➡️ Issues / Feature Requests

Other ideas? => issues

See also https://github.com/LandscapeGeoinformatics/awesome-discrete-global-grid-systems & https://github.com/am2222/webDggrid.