Public
Edited
Jul 3, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
globalMap = Plot.plot({
color: {
type: "threshold",
scheme: "BuPu",
domain: [0.25, 0.5, 0.75, 0.95, 0.99].map((d) =>
d3.quantile(valuesForLegend, d)
)
},
projection: {
type: "mercator",
domain: circle
},
marks: [
Plot.geo(land, { fill: "lightgrey", stroke: "#aaa", strokeWidth: 0.5 }),
Plot.graticule(),
Plot.geo(circle, {
stroke: "#bbb",
strokeWidth: 1,
strokeDasharray: "5,3"
}),
Plot.dot(
dataWithinRadius,
Plot.hexbin(
{
fill: (g) => d3[aggType](g, (d) => d.activity)
},
{
x: "longitude",
y: "latitude",
fillOpacity: 0.9,
symbol: "hexagon",
stroke: "black",
strokeWidth: 0.5,
strokeOpacity: 0.5,
binWidth: 6,
tip: true
}
)
),
Plot.geo(WISPolygon),
Plot.geo(WOIPolygon),
Plot.geo(EISPolygon)
]
})
Insert cell
Insert cell
viewof dataInBoxes = Inputs.toggle({ label: "Data within defined boxes" })
Insert cell
Plot.plot({
inset: 8,
y: {
type: logscale ? "log" : "linear"
},
grid: true,
color: {
legend: true,
type: "categorical",
scheme: "tableau10"
},
marks: [
Plot.dot(
dataInBoxes
? dataWithinRadius.filter((d) => d.roi != "Elsewhere")
: dataWithinRadius,
{ x: "begPeriod", y: "activity", tip: true, fill: "roi" }
)
]
})
Insert cell
Plot.plot({
width,
marginLeft: 200,
y: {
label: "Region Of Interest"
},
marks: [
Plot.boxX(
dataInBoxes
? dataWithinRadius.filter((d) => d.dataInBoxes != "Elsewhere")
: dataWithinRadius,
{ x: "activity", y: "roi", tip: true, fill: "roi" }
)
]
})
Insert cell
Insert cell
Insert cell
center = [-5,53.5]
Insert cell
circle = d3
.geoCircle()
.center(center)
.radius((kms / (6371 * Math.PI * 2)) * 360)
.precision(10)()
Insert cell
land50m = d3.json("https://unpkg.com/world-atlas@2.0.2/land-50m.json ")
Insert cell
land = topojson.feature(land50m, land50m.objects.land)
Insert cell
params = ({
areaId: "1912,2350,2351,2357,2389,3141,4283,9999",
sampleTypeId: sampleType,
nuclideId: nuclide, // 137Cs
samplingDateFrom: "2010-01-01",
shapeTypeId: 1
})
Insert cell
dataRaw = getMeasurementData(params)
Insert cell
Insert cell
EISPolygon = turf.polygon(
[
[
[-4.5, 52],
[-2.5, 52],
[-2.5, 55.5],
[-4.5, 55.5],
[-4.5, 52]
]
],
{ name: "Eastern region of the Irish Sea" }
)
Insert cell
WOIPolygon = turf.polygon(
[
[
[-12, 51],
[-6.5, 51],
[-6.5, 56],
[-12, 56],
[-12, 51]
]
],
{ name: "West of Ireland" }
)
Insert cell
WISPolygon = turf.polygon(
[
[
[-6.5, 52],
[-4.5, 52],
[-4.5, 55.5],
[-6.5, 55.5],
[-6.5, 52]
]
],
{ name: "Western region of the Irish Sea " }
)
Insert cell
// // Get Region Of Interest
function getROI(point, regions) {
const region = regions.find((region) => {
return turf.booleanPointInPolygon(turf.point(point), region);
});
return region ? region.properties.name : "Elsewhere";
}
Insert cell
data = dataRaw.map((d) => ({
...d,
begPeriod: new Date(d.begPeriod),
roi: getROI([d.longitude, d.latitude], [EISPolygon, WOIPolygon, WISPolygon])
}))
Insert cell
dataWithinRadius = data.filter(
(d) => d3.geoDistance([d.longitude, d.latitude], center) < kms / 6371
)
Insert cell
valuesForLegend = dataWithinRadius.map((d) => d.activity)
Insert cell
Insert cell
import { getMeasurementData, luts } from "@maris-iaea/api"
Insert cell
turf = require("@turf/turf@7")
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