Public
Edited
Oct 3, 2024
2 stars
Insert cell
Insert cell
Insert cell
world = FileAttachment("world.json").json()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
geo = require("geotoolbox@2")
Insert cell
geo
Insert cell
Insert cell
Insert cell
world_light = geo.simplify(world, { k })
Insert cell
Insert cell
Insert cell
union = geo.union(world)
Insert cell
Insert cell
Insert cell
union2 = geo.union(world, { id: "region" })
Insert cell
union2
Insert cell
Insert cell
Insert cell
africa = geo.filter(world, (d) => d.region == "Africa")
Insert cell
buff = geo.buffer(africa, { dist: dist, merge: merge })
Insert cell
viewof dist = Inputs.range([1, 4000], { label: "Distance", step: 100 })
Insert cell
Insert cell
Insert cell
Insert cell
clipworld = geo.clip(world, { clip: buff })
Insert cell
bertin.draw({
params: { projection: "user", width: 800 },
layers: [
{
geojson: clipworld,
fill: "#a63878",
stroke: "white"
},
{
geojson: world,
fill: "#CCC",
stroke: "none"
}
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
turf = require("@turf/turf@6")
Insert cell
turfbuff = turf.buffer(africa, dist2, {
units: "kilometers",
endCapStyle: "round"
})
Insert cell
viewof dist2 = Inputs.range([1, 4000], { label: "Distance", step: 100 })
Insert cell
Insert cell
Insert cell
Paris = turf.point([2.335042434318193, 48.85859730057634])
Insert cell
Shangai = turf.point([121.5685920321606, 31.557068992422167])
Insert cell
distance = Math.round(turf.distance(Paris, Shangai, { units: "kilometers" })) +
" km"
Insert cell
greatCircle = turf.greatCircle(Paris, Shangai, {
properties: { name: "Paris to Shangai" }
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
jsts = require("https://unpkg.com/jsts@2.10.0/dist/jsts.min.js")
Insert cell
Insert cell
usa = ({
type: "FeatureCollection",
features: world.features.filter((d) => d.properties.ISO3 == "USA")
})
Insert cell
Insert cell
reader = new jsts.io.GeoJSONReader()
Insert cell
writer = new jsts.io.GeoJSONWriter()
Insert cell
usajsts = reader.read(usa)
Insert cell
Insert cell
a = usajsts.features[0].geometry
Insert cell
abuff = a.buffer(dist3)
Insert cell
buffer = writer.write(abuff)
Insert cell
viewof dist3 = Inputs.range([-5, 8], {
label: "Distance (unités de la couche)"
})
Insert cell
bertin.draw({
params: { margin: 100 },
layers: [
{
geojson: buffer,
stroke: "#a63878",
strokeWidth: 2,
strokeDasharray: 5,
fill: "none"
},
{ geojson: usa, stroke: "none", fill: "#CCC" }
]
})
Insert cell
Insert cell
bertin = require("bertin")
Insert cell
import {thumbs} from "@neocartocnrs/hello-geotoolbox"
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