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()
Assign lines (LineString or MultiLineString) to a grid and compute weighted sums per cell.
Assign lines (LineString or MultiLineString) to a grid and compute weighted sums per cell. MultiLineStrings are treated as a single feature for count and proportional distribution.
- 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() });
safeSegLength()
Returns total segment length of intersection between a line and polygon cell, including case where line is entirely contained in the cell.
Returns total segment length of intersection between a line and polygon cell, including case where line is entirely contained in the cell.
- Source:
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}
Build a global square grid in lon/lat.
Generates a grid of square polygons covering the whole globe in WGS84 coordinates.
- Longitudes: start at -180, add
stepuntil reaching +180 (last cell may be smaller) - Latitudes: start at +90, subtract
stepuntil reaching -90 (last cell may be smaller) - Cells never overlap; borders align exactly
- EPS is used to avoid coordinates exactly at ±180 and ±90 to prevent rewind/topology issues
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
- Source:
Returns:
A FeatureCollection of square 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: