Public
Edited
Apr 2, 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 = `
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT ?item ?itemLabel ?coord
WHERE {
?item ${wdt}:${filtering_property} ${target};
rdfs:label ?itemLabel;
wdt:P625 ?coord.
FILTER(LANG(?itemLabel) = "${lang}" )
}
`
Insert cell
data = fetch(
`https://qlever.cs.uni-freiburg.de/api/wikidata?query=${encodeURIComponent(
query
)}`,
{
headers: { accept: "application/sparql-results+json" }
}
).then((d) => d.json())
Insert cell
array = data.results.bindings.map((d) => ({
item: d.item.value,
itemLabel: d.itemLabel.value,
coord: d.coord.value
}))
Insert cell
geoarray = geo.coords2geo(
array.filter((d) => d.coord !== undefined),
{
coords: "coord",
reverse: true
}
)
Insert cell
geobuffer = geo.buffer(geoarray, { dist: 400, merge: true })
Insert cell
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
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
filtering_property: "P81",
filtering_target: "Q24088686",
reverse: false,
lang: "en"
};
if (params.has("filtering_property")) {
defaults.filtering_property = params.get("filtering_property");
}
if (params.has("filtering_target")) {
defaults.filtering_target = params.get("filtering_target");
}
if (params.has("lang")) {
defaults.lang = params.get("lang");
}
if (params.has("reverse")) {
defaults.reverse = params.get("reverse");
}
return defaults;
}
Insert cell
get_default()
Insert cell
target = {
if (filtering_target == "") {
return "?target";
} else {
return "wd:" + filtering_target;
}
}
Insert cell
wdt = {
if (reverse == true) {
return "^wdt";
} else {
return "wdt";
}
}
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