Public
Edited
Jan 20, 2023
4 forks
19 stars
Insert cell
Insert cell
Insert cell
db.describe()
Insert cell
Insert cell
db
select * from species
Insert cell
Insert cell
db
select * from distributions
Insert cell
Plot.plot({
marks: [
Plot.barX(distributions, Plot.groupY({x: "count"}, {y: "Continent", sort: {y: "x", reverse: true, limit: 10}}))
],
marginLeft: 100,
grid: true
})
Insert cell
Insert cell
db
select
round(Longitude, 1) as Long,
round(Latitude, 1) as Lat,
count(*)::INT as count
from distributions
group by Long,Lat
Insert cell
Insert cell
map = Plot.plot({
projection: "equal-earth",
width: 975,
inset: 1,
insetBottom: 10,
length: { range: [0, 50] },
marks: [
Plot.geo(countries, { fill: "#ddd" }),
Plot.geo(countrymesh, { stroke: "#fff" }),
Plot.spike(bylocation, {
x: "Long",
y: "Lat",
filter: (d) => !(d.Long === 0 && d.Lat === 0), // null island
stroke: "red",
length: "count"
}),
Plot.sphere(),
legendSpike([25, 50, 100, 150], { stroke: "red" })
]
})
Insert cell
Insert cell
db
select * from distributions
join species on distributions."Species.name" = species."Species.name"
where species.Urban = 1
Insert cell
Insert cell
db
select
round(Longitude, 1) as Long,
round(Latitude, 1) as Lat,
count(*)::INT as count
from distributions
join species on distributions."Species.name" = species."Species.name"
where species.Urban = 1
group by Long,Lat
Insert cell
Insert cell
Plot.plot({
projection: "equal-earth",
width: 975,
inset: 1,
length: { range: [0, 50] },
marks: [
Plot.geo(countries, { fill: "#ddd" }),
Plot.geo(countrymesh, { stroke: "#fff" }),
Plot.spike(urbanbylocation, {
x: "Long",
y: "Lat",
filter: d => !(d.Long===0 && d.Lat===0), // null island
stroke: "red",
length: "count",
}),
Plot.sphere(),
legendSpike([1, 2, 3, 4, 5], { stroke: "red" })
]
})
Insert cell
Insert cell
db
select * from landscapes
Insert cell
Plot.plot({
projection: "equal-earth",
inset: 1,
width,
insetBottom: 10,
r: {
range: [1, 30]
},
marks: [
Plot.geo(countries, { fill: "#ddd" }),
Plot.geo(countrymesh, { stroke: "#fff" }),
Plot.dot(landscapes, {
x: "Longitude",
y: "Latitude",
fill: "red",
fillOpacity: .25,
r: "Tree.dens",
stroke: '#fff',
strokeWidth: .1,
}),
Plot.sphere(),
legendBubble([5e4, 10e4, 25e4], { stroke: "red" })
]
})
Insert cell
Insert cell
db
select * from parasites
Insert cell
Insert cell
db = DuckDBClient.of({
species: FileAttachment("Dataset1@1.csv"),
distributions: FileAttachment("Dataset2@2.csv"),
landscapes: FileAttachment("Dataset3@1.csv"),
parasites: { file: FileAttachment("Dataset4@3.csv"), header: true },
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
world = FileAttachment("countries-50m.json").json()
Insert cell
countries = topojson.feature(world, world.objects.countries)
Insert cell
countrymesh = topojson.mesh(world, world.objects.countries, (a, b) => a !== b)
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