Published unlisted
Edited
Apr 1, 2021
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof oxleasWoodGeojson = showGeoJSON(
osmtogeojson(await overpass(oxleasWoodOverpass))
)
Insert cell
Insert cell
viewof oxleasWoodGrid = {
const bb = turf.bbox(oxleasWoodGeojson);
const grid = turf.squareGrid(bb, 10, {
units: 'metres',
mask: oxleasWoodGeojson
});
return showGeoJSON(grid);
}
Insert cell
Insert cell
// CLONE THE PREVIOUS VERSION
oxleasWoodGridFit = ({ ...oxleasWoodGrid })
Insert cell
// MUTATE THE CLONE
(oxleasWoodGridFit.features = oxleasWoodGrid.features.filter(feature =>
turf.booleanWithin(feature, oxleasWoodGeojson.features[0])
))
Insert cell
showGeoJSON(oxleasWoodGridFit)
Insert cell
Insert cell
// CLONE THE PREVIOUS VERSION
oxleasWoodGridFitIDs = ({ ...oxleasWoodGridFit })
Insert cell
// MUTATE THE CLONE - ASSIGN AN ID TO EACH CELL
(oxleasWoodGridFitIDs.features = oxleasWoodGridFit.features.map((el, i) => {
el.properties.id = i;
return el;
}))
Insert cell
// id shows on feature click
showGeoJSON(oxleasWoodGridFitIDs)
Insert cell
Insert cell
Insert cell
Insert cell
samplePercentage = 1
Insert cell
sample = {
const sample = [];
for (
let i = 0;
i <
Math.round((oxleasWoodGridFitIDs.features.length * samplePercentage) / 100);
i++
) {
sample.push(getRandomIntInclusive(0, oxleasWoodGridFit.features.length));
}
return sample;
}
Insert cell
// CLONE THE PREVIOUS VERSION
oxleasWoodGridFitIDsSample = ({ ...oxleasWoodGridFitIDs })
Insert cell
// MUTATE THE CLONE - FILTER OUT CELLS THAT AREN'T IN THE SAMPLE LIST
(oxleasWoodGridFitIDsSample.features = oxleasWoodGridFitIDs.features.filter(
(el, i) => sample.includes(el.properties.id)
))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more