Global

Methods

diamond(stepopt, startopt, widthopt, heightopt, overflowopt) → {object}

Compute a diamond grid.

The diamond() function allows to create a diamond grid in SVG coordinates.

Parameters:
Name Type Attributes Default Description
step number <optional>
50

Step of the grid.

start array <optional>
[0,0]

Positioning coordinates [x,y].

width number <optional>
1000

Width of the grid

height number <optional>
500

Height of the grid

overflow boolean <optional>
true

Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.

Source:
Returns:
  • A GeoJSON FeatureCollection
Type
object
Example
geogrid.diamond({step:30})

dot(stepopt, startopt, widthopt, heightopt, overflowopt) → {object}

Compute a dot grid.

The dot() function allows to create a square grid in SVG coordinates.

Parameters:
Name Type Attributes Default Description
step number <optional>
50

Step of the grid.

start array <optional>
[0,0]

Positioning coordinates [x,y].

width number <optional>
1000

Width of the grid

height number <optional>
500

Height of the grid

overflow boolean <optional>
true

Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.

Source:
Returns:
  • A GeoJSON FeatureCollection
Type
object
Example
geogrid.dot({step:30})

h3()

The h3() function allows to create a hexbin geoJSON grid in geographical coordinates.

The h3() function allows to create a hexbin geoJSON grid in geographical coordinates.

Properties:
Name Type Attributes Default Description
level number <optional>
0

level of the grid. Form 0 (large hexagons) to 4 (small hexagons). See: https://h3geo.org

domain object <optional>

a geoJSON to define an extent

rewind boolen <optional>

to rewind the output

Source:

hexbin(stepopt, startopt, widthopt, heightopt, overflowopt) → {object}

Compute a hexbin grid.

The hexbin() function allows to create a hexbin grid in SVG coordinates.

Parameters:
Name Type Attributes Default Description
step number <optional>
50

Step of the grid.

start array <optional>
[0,0]

Positioning coordinates [x,y].

width number <optional>
1000

Width of the grid

height number <optional>
500

Height of the grid

overflow boolean <optional>
true

Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.

Source:
Returns:
  • A GeoJSON FeatureCollection
Type
object
Example
geogrid.hexbin({step:30})

hexbin(stepopt, startopt, widthopt, heightopt, overflowopt) → {object}

Compute a hexbin grid.

The hexbin() function allows to create a hexbin grid in SVG coordinates.

Parameters:
Name Type Attributes Default Description
step number <optional>
50

Step of the grid.

start array <optional>
[0,0]

Positioning coordinates [x,y].

width number <optional>
1000

Width of the grid

height number <optional>
500

Height of the grid

overflow boolean <optional>
true

Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.

Source:
Returns:
  • A GeoJSON FeatureCollection
Type
object
Example
geogrid.hexbin({step:30})

linestogrid(opts)

Assign lines to a grid and compute weighted sums per cell.

Assign lines to a grid and compute weighted sums per cell. Uses a spatial index to speed up calculations. Optimized and removes cells with count = 0. Supports multiple variables in varField (string or array of strings) Treats undefined or NaN as zero when summing If values is true, stores an array of intersected line properties

Parameters:
Name Type Description
opts object
Properties:
Name Type Attributes Default Description
lines object <optional>

GeoJSON lines to assign

grid object <optional>

GeoJSON grid

var string | Array <optional>

Field(s) to compute weighted sums (optional)

values boolean <optional>
false

Include array of raw lines properties

Source:

pointstogrid(opts)

Assigns points to grid cells and computes sums per cell.

Assigns points to grid cells and computes sums per cell. Supports multiple variables and stores point properties if values=true

Parameters:
Name Type Description
opts object
Properties:
Name Type Attributes Default Description
points object <optional>

GeoJSON points

grid object <optional>

GeoJSON grid (polygons)

var string | Array <optional>

Field(s) for summing values

values boolean <optional>
false

Include array of raw point properties

spherical boolean <optional>
false

Use true if you use a spherical coordinate system

Source:

polygonstogrid(opts)

Assign polygons to a grid and compute weighted sums per cell.

Assign polygons to a grid and compute weighted sums per cell. Supports planar (path.area) or spherical (Turf area) surface calculation. Optimized and removes cells with count = 0. Supports multiple variables in varField (string or array of strings). Treats undefined or NaN as zero when summing. If values is true, stores an array of intersected polygon properties.

Parameters:
Name Type Description
opts object
Properties:
Name Type Attributes Default Description
polygons object <optional>

GeoJSON polygons or multipolygons to assign

grid object <optional>

GeoJSON grid

var string | Array <optional>

Field(s) to compute weighted sums (optional)

values boolean <optional>
false

Include array of raw polygon properties

spherical boolean <optional>
false

Compute areas on the sphere (Turf) instead of planar (D3)

Source:

polygonstogrid()

Répartit des polygones (optionnellement pondérés) sur une grille polygonale.

Répartit des polygones (optionnellement pondérés) sur une grille polygonale.

Properties:
Name Type Attributes Description
polygons object <optional>

GeoJSON de polygones

grid object <optional>

GeoJSON de grille

var string <optional>

Champ de pondération (facultatif)

Source:

project(data, options) → {object}

Projects a GeoJSON FeatureCollection using a D3 projection.

Projects a GeoJSON FeatureCollection using a D3 projection.

Parameters:
Name Type Description
data object

GeoJSON FeatureCollection

options object
Properties:
Name Type Description
options.projection function

D3 projection function (e.g., d3.geoOrthographic(), d3.geoMercator())

Source:
Returns:
  • new GeoJSON FeatureCollection with projected coordinates
Type
object
Example
import { geoOrthographic } from "d3-geo-projection";
const projected = geoproject(world, { projection: geoOrthographic() });

sphere(projection, stepDegopt) → {GeoJSON.FeatureCollection}

Crée un polygone approximatif de la sphère projetée dans le plan SVG et le retourne dans une FeatureCollection

.

Crée un polygone approximatif de la sphère projetée dans le plan SVG et le retourne dans une FeatureCollection

Parameters:
Name Type Attributes Default Description
projection d3.GeoProjection

La projection D3 utilisée pour le SVG

stepDeg number <optional>
5

Pas en degrés pour approximer la sphère

Source:
Returns:
  • FeatureCollection contenant le polygone Turf de la sphère projetée
Type
GeoJSON.FeatureCollection

square(stepopt, startopt, widthopt, heightopt, overflowopt) → {object}

Compute a square grid.

The square() function allows to create a square grid in SVG coordinates.

Parameters:
Name Type Attributes Default Description
step number <optional>
50

Step of the grid.

start array <optional>
[0,0]

Positioning coordinates [x,y].

width number <optional>
1000

Width of the grid

height number <optional>
500

Height of the grid

overflow boolean <optional>
true

Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.

Source:
Returns:
  • A GeoJSON FeatureCollection
Type
object
Example
geogrid.square({step:30})

square_sph(options) → {GeoJSON.FeatureCollection}

Compute a square grid in WGS84 degrees.

Builds a square grid in latitude/longitude degrees, avoids coordinates exactly at ±180 or ±90 to prevent rewind issues.

Parameters:
Name Type Description
options object
Properties
Name Type Attributes Default Description
start Array.<number> <optional>
[-180, -90]

Starting coordinates [lon, lat].

width number <optional>
360

Width of the grid in degrees (longitude span).

height number <optional>
180

Height of the grid in degrees (latitude span).

step number <optional>
1

Step size in degrees.

domain GeoJSON.Feature | GeoJSON.FeatureCollection | GeoJSON.Geometry <optional>

Optional GeoJSON object. Only cells that intersect this domain are kept.

Source:
Returns:

A GeoJSON FeatureCollection of polygons.

Type
GeoJSON.FeatureCollection

stitchmerge()

Takes a GeoJSON and processes each MultiPolygon feature that crosses the antimeridian, converting it into a continuous Polygon feature.

Takes a GeoJSON and processes each MultiPolygon feature that crosses the antimeridian, converting it into a continuous Polygon feature.

Source:

triangle(stepopt, startopt, widthopt, heightopt, overflowopt) → {object}

Compute a triangle grid.

The triangle() function allows to create a triangle grid in SVG coordinates.

Parameters:
Name Type Attributes Default Description
step number <optional>
50

Step of the grid.

start array <optional>
[0,0]

Positioning coordinates [x,y].

width number <optional>
1000

Width of the grid

height number <optional>
500

Height of the grid

overflow boolean <optional>
true

Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.

Source:
Returns:
  • A GeoJSON FeatureCollection
Type
object
Example
geogrid.triangle({step:30})

unstitch()

After Matthieu Viry: https://observablehq.com/@mthh/unstitch

.

After Matthieu Viry: https://observablehq.com/@mthh/unstitch

Source: