Published
Edited
Jan 25, 2021
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
// As seen on https://kuanbutts.com/2020/07/07/subdivide-polygon-with-linestring/
function slicePolyByLine(poly, line) {
const polyAsLine = turf.polygonToLine(poly);
const unionedLines = turf.union(polyAsLine, line);
const polygonized = turf.polygonize(unionedLines);
const keepFromPolygonized = polygonized["features"].filter(ea =>
turf.booleanPointInPolygon(turf.pointOnFeature(ea), poly)
);
return keepFromPolygonized;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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