Methods
coords2geo()
From now on, use featurecollection
- Deprecated:
- Yes
- Source:
properties/add()
From now on, use derive
- Deprecated:
- Yes
- Source:
properties/head()
From now on, use head
- Deprecated:
- Yes
- Source:
properties/keep()
From now on, use columns
- Deprecated:
- Yes
- Source:
properties/remove()
From now on, use columns
- Deprecated:
- Yes
- Source:
properties/remove()
From now on, use directly geojson.features.map(d => d.properties)
- Deprecated:
- Yes
- Source:
properties/select()
From now on, use filter
- Deprecated:
- Yes
- Source:
properties/subset()
From now on, use filter
- Deprecated:
- Yes
- Source:
properties/tail()
From now on, use tail
- Deprecated:
- Yes
- Source:
aggregate(data, options) → {object|array}
Aggregate geometries (based on topojson). The aggregate()
function allows to merge all geometries of a geoJSON based on their topology. The id
parameter allows to aggregate based on a specific field.
Based on topojson.merge
.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.aggregate(*a geojson*)
autotype(data, options) → {object|array}
The function detects common data types such as numbers, dates and booleans, and convert properties values to the corresponding JavaScript type. Besed on d3.autoType().
Based on d3.autoType
.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | Array | A GeoJSON FeatureCollection or an array of objects |
||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.autotype(*a geojson or an array of objects*)
bbox(data) → {object|array}
Compute a geographic bounding box.
based on Jacob Rus code. See https://observablehq.com/@jrus/sphere-resample
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.bbox(*a geojson*)
border(data, options) → {object|array}
Extract boundaries from a GeoJSON FeatureCollection
Based on topojson.mesh()
and topojson.neighbors()
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||
options |
object | Optional parameters. Properties
|
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.border(*a geojson*, {id: "ISO3"})
(async) buffer(data, options) → {object|array}
Create a buffer
Based on geos.GEOSBuffer()
.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
|||||||||||||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
// A global buffer
await geotoolbox.buffer(*a geojson*, {dist: 50})
// A buffer by feature
await Promise.all(*a geojson*.features.map((d) => geo.buffer(d, { dist: 50 })));
// A buffer by feature based on a field
await Promise.all(*a geojson*.features.map((d) => geo.buffer(d, { dist: d.properties["pop"] / 1000000 })))
centroid(data, options) → {object|array}
Calculates the centroids of geometries.
Based on d3.geoArea()
and d3.geoCentroid()
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
|||||||||||||||
options |
object | Optional parameters. Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
geotoolbox.centroid(*a geojson*, {largest: true})
(async) clip(data, options) → {object|array}
Clip a geometry with another
Based on geos.GEOSIntersection() and geos.GEOSDifference()
.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | data to be clipped. A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
|||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
await geotoolbox.clip(*a geojson*, { clip: *another geojson* })
(async) clipbyrect(data, options) → {object|array}
Intersection optimized for a rectangular clipping polygon. By default, the function cuts off anything that exceeds the Earth's bbox.
Based on geos.GEOSClipByRect()
.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
await geotoolbox.clipbyrect(*a geojson*, {bbox:[50, 50, -50, -50]})
columns(data, options) → {object|array}
Select, rename and reorder properties
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
||||||||||||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.columns(*a geojson or an array of objects*, {keys: ["ISO3","Population"]", rename:["id","pop"]})
combine(data, options) → {object|array}
Get the first n Features. The function sort data and returns the nb first elements. If a field is selected, then the function returns the top values. If the entries are strings, then the alphabetic order is applied.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | An array containig several of GeoJSONs or arrays of objects |
||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.head(*a geojson or an array of objects*)
(async) concavehull(data, options) → {object|array}
Returns a "concave hull" of a geometry. A concave hull is a polygon which contains all the points of the input, but is a better approximation than the convex hull to the area occupied by the input. Frequently used to convert a multi-point into a polygonal area. that contains all the points in the input Geometry.
Based on geos.GEOSConcaveHull()
.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
|||||||||||||||
options |
object | Optional parameters. Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
await geotoolbox.concavehull(*a geojson*, {ratio: 0.5})
contains(g1, g2) → {boolean}
Tests if geometry g2 is completely within g1, but not wholly contained in the boundary of g1.
Based on geos.GEOSContains()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.contains(*a geojson*, *another geojson*)
(async) convexhull(data) → {object|array}
Returns a "convex hull" of a geometry. The smallest convex Geometry that contains all the points in the input Geometry
Based on geos.GEOSConvexHull()
.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
await geotoolbox.convexehull(*a geojson*)
copy(data) → {object|array|object|array}
Deep copy
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
Returns:
-
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
-
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
Example
geotoolbox.copy(*a geojson or an array of objects*)
coveredby(g1, g2) → {boolean}
GEOSCoveredBy. Tests if geometry g1 is covered by g2, which is the case if every point of g1 lies in g2.
Based on geos.GEOSCoveredBy()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.coveredby(*a geojson*, *another geojson*)
covers(g1, g2) → {boolean}
GEOSCovers. Tests if geometry g1 covers g2, which is the case if every point of g2 lies in g1.
Based on geos.GEOSCovers()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.covers(*a geojson*, *another geojson*)
crosses(g1, g2) → {boolean}
GEOSCrosses. Tests if two geometries interiors intersect but their boundaries do not. Most useful for finding line crosses cases.
Based on geos.GEOSCrosses()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.crosses(*a geojson*, *another geojson*)
dedupe(data, options) → {object|array}
Deletes duplicates. Keeps the first element.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
|||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.dedupe(*a geojson or an array of objects*, {key: "ISO3"})
(async) densify(data, options) → {object|array}
Densifies a geometry using a given distance tolerance
Based on geos.GEOSDensify()
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
await geotoolbox.densify(*a geojson*, { dist:0.5 })
derive(data, options) → {object|array}
Add a field to a dataset. The function allows to add a new property
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
||||||||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.derive(*a geojson or an array of objects*, {key: "gdppc", value:"gdp/pop"})
disjoint(g1, g2) → {boolean}
GEOSDisjoint. Tests if two geometries have no point in common.
Based on geos.GEOSDisjoint()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.disjoint(*a geojson*, *another geojson*)
dissolve(data) → {object|array}
Multi part to single part geometries. The disolve()
function allows to convert "MultiPoint", "MultiLineString" or "MultiPolygon" to single "Point", "LineString" or "Polygon". In addition, a __share
field is calculated, representing the surface share of each part.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geome |
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
geotoolbox.dissolve(*a geojson*)
(async) envelope(data) → {object|array}
Returns a "concave hull" of a geometry. A concave hull is a polygon which contains all the points of the input, but is a better approximation than the convex hull to the area occupied by the input. Frequently used to convert a multi-point into a polygonal area. that contains all the points in the input Geometry.
Based on geos.GEOSConcaveHull()
.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
await geotoolbox.envelope(*a geojson*)
equals(g1, g2) → {boolean}
GEOSEquals. Tests if two geometries contain the same set of points in the plane.
Based on geos.GEOSEquals()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.equals(*a geojson*, *another geojson*)
filter(data, options) → {object|array}
Filter a dataset. The functions allows to subset a geoJSON or an array of objects
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
|||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.filter(*a geojson or an array of objects*, {filter: "gdp >= 1000000" })
geolines()
Returns a GeoJSON FeatureCollection with the equator, tropics & polar circles.
- Source:
Example
geotoolbox.geolines(*a geojson*)
groupby(data, options) → {object|array}
This function allows you to group objects according to an identifier. If the input dataset is a geoJSON, then the geometries are grouped using the aggregate function.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
||||||||||||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.groupby(*a geojson or an array of objects*, {keys: ["pop", "gdp", "gdppc"], operators:["sum", "sum", "mean"]})
head(data, options) → {object|array}
Get the first n Features. The function sort data and returns the nb first elements. If a field is selected, then the function returns the top values. If the entries are strings, then the alphabetic order is applied.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
||||||||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.head(*a geojson or an array of objects*)
htmltable(data, options) → {HTMLElement}
View a data table.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | a GeoJSON FeatureCollection or an array of features |
||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A html sortable table.
- Type
- HTMLElement
Example
geottolbox.htmltable(*a geojson*)
(async) info(data)
GeoJSON information. The function gives some informations about a geoJSON (size, number of nodes, type of features, etc)
Parameters:
Name | Type | Description |
---|---|---|
data |
object | A GeoJSON FeatureCollection |
Example
geottolbox.info(*a geojson*)
intersects(g1, g2) → {boolean}
GEOSIntersects. Tests if two geometries intersect.
Based on geos.GEOSIntersects()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.intersects(*a geojson*, *another geojson*)
(async) isvalid(data)
Check validity of a geoJSON.
Based on geos.GEOSisValid()
.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Example
await geotoolbox.isvalid(*a geojson*)
(async) iterate(data, options) → {object|array}
Iterate and apply a function
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
|||||||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
// A simple example. Rename and select fields.
await geo.iterate(*a geojson*, {
func: (d) => ({
...d
properties: { id: d.properties.ISO3, pop: d.properties.population },
})
})
// Another example with a geojson and an async function
await geo.iterate(*a geojson*, {
func: async (d) => ({
...d,
geometry: await geo.buffer(d.geometry, { dist: d.properties.size })
})
join(data, options) → {object|array}
Join datasets using a common identifier.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
array | An array of datsats and/or geoJSONs. The join operation is basend on the first item. |
||||||||||||||||||||||||||||||
options |
object | Options Properties
|
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.join([*a geojson*, *a dataset*], {ids:["ISO3", "id"], all: false)
largestemptycircle(data, options)
Constructs the "largest empty circle" (LEC) for a set of obstacle geometries and within a polygonal boundary, with accuracy to to a specified distance tolerance. The obstacles may be any collection of points, lines and polygons.
Based on geos.GEOSLargestEmptyCircle()
.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | A GeoJSON FeatureCollection. |
||||||||||||||||||||
options |
object | Optional parameters. Properties
|
- Source:
Example
geotoolbox.largestemptycircle()
(async) makevalid(data) → {object|array}
The makevalid()
function repair an invalid geometry. It returns a repaired geometry.
Based on geos.GEOSisValid()
.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
await geotoolbox.makevalid(*a geojson*)
nodes(data) → {object|array}
Retrieve geometry nodes
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.nodes(*a geojson*)
overlaps(g1, g2) → {boolean}
GEOSOverlaps. Tests if two geometries share interiors but are neither within nor contained.
Based on geos.GEOSOverlaps()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.overlaps(*a geojson*, *another geojson*)
removeemptygeom(data) → {object|array}
The function remove all features with undefined geometries.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.removeemptygeom(*a geojson*)
replace(data, options) → {object|array}
Replace substrings. the function allows a string to be replaced by another string in the entire dataset
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
|||||||||||||||||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.replace(*a geojson or an array of objects*, {search: ",", replacement: " " })
resolveemptygeom(data, options) → {object|array}
The function replace all features with undefined geometries by a valid geometry, but without coordinates
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.resolveemptygeom(*a geojson*)
(async) reverse(data, options) → {object|array}
For geometries with coordinate sequences, reverses the order of the sequences. Converts CCW rings to CW. Reverses direction of LineStrings.
Based on geos.GEOSReverse()
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
options |
object | Optional parameters |
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
await geotoolbox.geosreverse(*a geojson*)
rewind(data, options) → {object|array}
Rewind a geoJSON (fil recipe). The function allows to rewind the winding order of a GeoJSON object. The winding order of a polygon is the order in which the vertices are visited by the path that defines the polygon. The winding order of a polygon is significant because it determines the interior of the polygon. The winding order of a polygon is typically either clockwise or counterclockwise.
Based on https://observablehq.com/@fil/rewind
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
geotoolbox.rewind(*a geojson*)
rewind2(data) → {object|array}
Rewind a geoJSON (Mapbox). The function allows to rewind the winding order of a GeoJSON object. The winding order of a polygon is the order in which the vertices are visited by the path that defines the polygon. The winding order of a polygon is significant because it determines the interior of the polygon. The winding order of a polygon is typically either clockwise or counterclockwise.
Adapted from MapBox geojson-rewind code (https://github.com/mapbox/grojson-rewind) under ISC license.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options.outer |
boolean |
<optional> |
false | rewind Rings Outer |
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
geotoolbox.rewind2(*a geojson*)
roundcoordinates(data, options) → {object|array}
Round coordinates. The round()
function allows to round coordinates. This reduces file size and speeds up display.
Based on geojson-precision
.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.roundcoordinates(*a geojson*, {precision: 2})
simplify(data, options) → {object|array}
Simplify geometries. The simplify()
function allows to simplify a geometry using topojson-simplify
library. The parameter k difine the The quantile of the simplification. By default, the generalization level is calculated automatically to ensure smooth map display.
Based on topojson.simplify
.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||||||||||||||
options |
object | Optional parameters Properties
|
- Source:
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.simplify(*a geojson*, {k: 0.1})
sort(data, options) → {object|array}
Sorting data according to a field
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
||||||||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.sort(*a geojson or an array of objects*, {key: "ISO3", ascending: true})
stitch(data) → {object|array}
The stitch()
function returns a shallow copy of the specified GeoJSON object, removing antimeridian and polar cuts, and replacing straight Cartesian line segments with geodesic segments. The input object must have coordinates in longitude and latitude in decimal degrees per RFC 7946. Antimeridian cutting, if needed, can then be re-applied after rotating to the desired projection aspect.
Based on d3.geoStitch()
.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
)
- Type
- object | array
Example
geotoolbox.stitch(*a geojson*)
table(data, options) → {array}
Retrieves the dataset's attribute table (properties). By default, a deep copy is returned.
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
||||||||||
options |
object | Optional parameters Properties
|
Returns:
- An array of objects.
- Type
- array
Example
geotoolbox.table(*a geojson or an array of objects*)
tail(data, options) → {object|array}
Get the last n Features. The function sort data and returns the nb first elements. If a field is selected, then the function returns the top values. If the entries are strings, then the alphabetic order is applied.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection or an array of objects |
||||||||||||||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection or an array of objects. (it depends on what you've set as
data
).
- Type
- object | array
Example
geotoolbox.tail(*a geojson or an array of objects*)
tissot(stepopt)
Generate Tissot's indicatrix.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
step |
number |
<optional> |
20 | The distance between each circle |
Example
geotoolbox.tissot(*a geojson*)
togeojson(data, options)
Retrieve a FeatureCollection. The featurecollection()
function allows to retrieve a FeatureCollection from a
- a topoJSON ✅
- an array of features ✅
- a single feature ✅
- an array of geometries ✅
- a single geometry ✅
- an array of objects with coordinates (points) ✅
- an array coordinates (points) ✅
- a couple of coordinates (points) ✅
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | A GeoJSON FeatureCollection |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object | Optional parameters Properties
|
- Source:
Example
// Array of coordinates
geoclean.togeojson([
[32.33, 45.66],
[10, 10]
])
// A geometry
geoclean.togeojson({
type: "Polygon",
coordinates: [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0]
]
]
})
// An array of objects containing coordinates
geoclean.togeojson(*a JSON*, {lat: "lat", lon: "lon"})
// Data handling
geoclean.togeojson(*a geoJSON*, {
filter: (d) => d.properties.pop2018 >= 200,
properties: ["id", "capital", "pop2018"],
rename: ["code", "name", "pop"
})
touches(g1, g2) → {boolean}
GEOSTouches. Tests if two geometries share boundaries at one or more points, but do not have interior points in common.
Based on geos.GEOSTouches()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.touches(*a geojson*, *another geojson*)
type(x) → {object}
Return the geometry type contained in a GeoJSON FeatureCollection
.Return the geometry type contained in a GeoJSON FeatureCollection
Parameters:
Name | Type | Description |
---|---|---|
x |
object | The GeoJSON FeatureCollection |
- Source:
Returns:
- The number of dimensions of the geometries (1 for punctual, 2 for lineal, 3 for zonal and -1 for composite) and the types of the geometries ("Point", "LineString", "Polygon", "MultiPoint", "MultiLineString", "MultiPolygon")
- Type
- object
(async) union(data, options) → {object|array}
Merge geometries
Based on geos.GEOSUnaryUnion()
.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
data |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
||||||||
options |
object | Optional parameters Properties
|
Returns:
- A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry (it depends on what you've set as
data
).
- Type
- object | array
Example
await geotoolbox.union(*a geojson*)
within(g1, g2) → {boolean}
GEOSWithin. Tests if geometry g1 is completely within g2, but not wholly contained in the boundary of g2.
Based on geos.GEOSWithin()
Parameters:
Name | Type | Description |
---|---|---|
g1 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
g2 |
object | array | A GeoJSON FeatureCollection, an array of features, an array of geometries, a single feature or a single geometry. |
- Source:
Returns:
- A boolean value
- Type
- boolean
Example
geotoolbox.within(*a geojson*, *another geojson*)