Public
Edited
Oct 17, 2023
1 fork
4 stars
Also listed in…
Political Issues
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Modified Wikimedia: https://upload.wikimedia.org/wikipedia/commons/e/ee/Gun_outline.svg
gun = "M 104 31 L 94.5 41 C 87.838131 48.012493 80.21061 48.523224 70.5 45 C 65.730485 43.269515 60.365376 38.273176 56 42.5 C 51.841622 46.526396 57.770564 49.777478 62 51.5 C 79.34484 58.564032 89.137238 68.757098 85 90 C 80.862762 111.2429 66.50779 108.84144 54 111 C 44.605682 112.62125 35.684815 112.57989 31 117 C 21.691257 125.78278 30.374381 135.57293 37 135 C 67.399774 132.37128 92.804902 155.62922 79 186 L 64 219 L 80 220 L 25 346 L 162 364 L 204 214 C 206.86761 203.75852 220.37594 197.49034 231 197 L 296 194 C 309.47228 193.3782 324.68919 181.28718 327 168 L 331 145 C 332.66023 135.45366 343.31086 126.09689 353 126 L 453 125 L 456 120 L 553 119 C 557.63057 118.95226 558.11925 111.23169 560 107 L 564 98 L 564 42 L 555 31 L 330 31 L 320 42 L 265 42 L 258 31 L 104 31 z"
Insert cell
us_outline = {
let outline = await FileAttachment("outline.json").json();
let polygon = outline.features[0].geometry.coordinates[5];
polygon[0].reverse();

outline.features[0].geometry.type = "Polygon";
outline.features[0].geometry.coordinates = polygon;

let w = 600;
let h = 400;
let projection = d3
.geoMercator()
.reflectX(true)
.fitExtent(
[
[0, 0],
[w, h]
],
outline
);
let path = d3.geoPath().projection(projection);
return path(outline);
}
Insert cell
flubber = require("flubber")
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