Published
Edited
Sep 12, 2022
Fork of Geo
Importers
2 stars
Insert cell
Insert cell
function normalizeWinding(features) {
return normalizeWindingInPlace({ ...features });
}
Insert cell
function featureFilterFeatures(
geo,
allowedFeatures = [
"Point",
"LineString",
"Polygon",
"MultiPoint",
"MultiLineString",
"MultiPolygon"
]
) {
const polys = featureFilter(geo, (f) =>
allowedFeatures.includes(turf.getType(f))
);

return { ...geo, features: polys };
}
Insert cell
function featureMap(geo, fn = (d) => d) {
return turf.featureReduce(geo, (acc, curr, index) => [...acc, fn(curr, index, geo)], []);
}
Insert cell
function featureFilter(geo, fn = (d) => d) {
return turf.featureReduce(
geo,
(acc, curr, index) => {
if (Boolean(fn(curr, index, geo))) {
return [...acc, curr];
}
return acc;
},
[]
);
}
Insert cell
function featureGroupBy(geo, fn = (k) => k) {
const obj = turf.featureReduce(
geo,
(acc, curr, index) => {
const key = fn(curr) || null;

return { ...acc, [key]: [...(acc[key] || []), curr] };
},
{}
);

return new Map(Object.entries(obj));
}
Insert cell
Insert cell
Insert cell
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