Public
Edited
Aug 10, 2023
1 fork
Insert cell
Insert cell
Insert cell
sparql = `SELECT ?placeLabel ?population (COUNT(?movie) as ?movieCount)
WHERE {
?movie wdt:P31 wd:Q11424 ; # Instance of: film
wdt:P840 ?place . # Place of setting: P840
?place wdt:P17 wd:Q30 ; # Country: United States of America (Q30)
wdt:P31/wdt:P279* wd:Q515 ;
rdfs:label ?placeLabel ;
wdt:P1082 ?population . # Population: P1082
FILTER(LANG(?placeLabel) = "en")
}
GROUP BY ?placeLabel ?population
ORDER BY DESC(?movieCount)`
Insert cell
query_data = fetch(
` https://query.wikidata.org/sparql?query=${encodeURIComponent(sparql)}`,
{ headers: { accept: "application/sparql-results+json" } }
).then((response) => response.json())
Insert cell
data = query_data.results.bindings
.map((d) => ({
city: d.placeLabel.value,
population: Number(d.population.value),
movies: Number(d.movieCount.value)
}))
.filter((d) => d.movies > 1)
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