Public
Edited
Sep 19, 2023
Paused
2 forks
Importers
8 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
map([randomPoints, turfConcaveHull, geosConcaveHull])
Insert cell
Insert cell
randomPoints = turf.randomPoint(points, {
bbox: [-11.339436, 36.773405, 15.159588, 57.183437]
})
Insert cell
Insert cell
randomMultipoint = randomPoints.features.reduce(
(multipoint, point) => {
multipoint.coordinates.push(point.geometry.coordinates);
return multipoint;
},
{
type: "MultiPoint",
coordinates: []
}
)
Insert cell
Insert cell
geosConcaveHull = {
const start = performance.now();
// create a GEOS geometry from the GeoJSON so that we can apply GEOS functions to it
const geosGeom = geojsonToGeosGeom(randomMultipoint);
// create the concave hull with the current settings
const geosConcaveHull = geos.GEOSConcaveHull(
geosGeom,
ratio,
allowHoles ? 1 : 0
);
// convert the GEOS geometry to a GeoJSON geometry again
const concaveHullGeoJson = geosGeomToGeojson(geosConcaveHull);
// add style so we can distinguish the GEOS result from turf.js
const styledFeature = {
type: "Feature",
geometry: concaveHullGeoJson,
properties: {
style: {
color: "red",
fillOpacity: 0.2
}
}
};
const end = performance.now();
mutable geosConcaveHullTime = ~~(end - start);
return styledFeature;
}
Insert cell
Insert cell
turfConcaveHull = {
const start = performance.now();
// create the concave hull using turf
const turfConcaveHull = turf.concave(randomPoints);
const end = performance.now();
mutable turfConcaveHullTime = ~~(end - start);
// add style so we can distinguish the turf.js result from GEOS in the map above
turfConcaveHull.properties.style = {
color: "blue",
fillOpacity: 0.2
};
return turfConcaveHull;
}
Insert cell
mutable geosConcaveHullTime = 0
Insert cell
mutable turfConcaveHullTime = 0
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
geos = {
const initGeosJs = (
await import("https://cdn.skypack.dev/geos-wasm@1.1.6?min")
).default;
const geos = await initGeosJs();
return geos;
}
Insert cell
turf = require("@turf/turf")
Insert cell
import { map } from "@chrispahm/map"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more