Public
Edited
Jan 26, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
query = `SELECT ?name ?url ?coord ?badge ?badgeLabel
WHERE {
?url schema:isPartOf <https://${wikipedia}/>;
wikibase:badge ?badge;
schema:about ?item;
schema:name ?name.
?item wdt:P625 ?coord.
?badge rdfs:label ?badgeLabel
FILTER(LANG(?badgeLabel) = "${lang}" )
}`
Insert cell
Insert cell
data = fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query)}`,
{ headers: { accept: "application/sparql-results+json" } }
).then((response) => response.json())
Insert cell
array = data.results.bindings.map((d) => ({
url: d.url.value,
name: d.name.value,
coord: d.coord.value,
badge: d.badge.value,
badgeLabel: d.badgeLabel.value
}))
Insert cell
df = aq
.from(array)
.filter(
(d) =>
(d.badge == "http://www.wikidata.org/entity/Q17437796") |
(d.badge == "http://www.wikidata.org/entity/Q17437798")
)
Insert cell
geoarray = geo.coords2geo(df.objects(), { coords: "coord", reverse: true })
Insert cell
df.dedupe("url").numRows()
Insert cell
df.groupby(["badge", "badgeLabel"]).count().view()
Insert cell
Insert cell
geo = require("geotoolbox@2")
Insert cell
viz = require("geoviz@0.4.4")
Insert cell
d3 = require("d3@7", "d3-geo-projection@4")
Insert cell
Insert cell
Insert cell
import { wikipedias } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
badge: "Q17437796",
wikipedia: "fr.wikipedia.org",
lang: "en"
};
if (params.has("badge")) {
defaults.badge = params.get("badge");
}
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}
if (params.has("lang")) {
defaults.lang = params.get("lang");
}
return defaults;
}
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