-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathcountry-centroids.ts
37 lines (35 loc) · 1.21 KB
/
country-centroids.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import * as Plot from "@observablehq/plot";
import * as d3 from "d3";
import {feature} from "topojson-client";
export async function countryCentroids() {
const world = await d3.json<any>("data/countries-110m.json");
const land = feature(world, world.objects.land);
const countries = feature(world, world.objects.countries);
return Plot.plot({
projection: "mercator",
marks: [
Plot.graticule(),
Plot.geo(land, {fill: "#ddd"}),
Plot.geo(countries, {stroke: "#fff"}),
Plot.text(countries, Plot.geoCentroid({fill: "red", text: "id"})),
Plot.text(countries, Plot.centroid({fill: "blue", text: "id"})),
Plot.frame()
]
});
}
export async function countryPois() {
const world = await d3.json<any>("data/countries-110m.json");
const land = feature(world, world.objects.land);
const countries = feature(world, world.objects.countries);
return Plot.plot({
projection: "orthographic",
marks: [
Plot.graticule(),
Plot.geo(land, {fill: "#ddd"}),
Plot.geo(countries, {stroke: "#fff"}),
Plot.text(countries, Plot.geoCentroid({fill: "red", text: "id"})),
Plot.text(countries, Plot.poi({fill: "green", text: "id"})),
Plot.frame()
]
});
}