Skip to content

Instantly share code, notes, and snippets.

@wiso
Created November 2, 2021 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wiso/b30c3197503a4cb9ad3d5402ebb27883 to your computer and use it in GitHub Desktop.
Save wiso/b30c3197503a4cb9ad3d5402ebb27883 to your computer and use it in GitHub Desktop.
power_plant_wikidata.sparql
SELECT DISTINCT ?item ?itemLabel ?countryLabel ?capacity_in_Mw ?stateLabel ?coords ?layer
WHERE
{
?item (wdt:P31/(wdt:P279*)) wd:Q159719;
p:P2109 ?stmnode;
wdt:P625 ?coords .
?stmnode psn:P2109 ?valuenode. # normalised value
?valuenode wikibase:quantityAmount ?capacity_in_W.
BIND(?capacity_in_W / "1e6"^^xsd:double AS ?capacity_in_Mw)
OPTIONAL{?item wdt:P17 ?country .}
OPTIONAL{?item wdt:P5817 ?state .}
BIND(
IF(?capacity_in_Mw < 1000, "<1GW",
IF(?capacity_in_Mw < 2000, "1GW-2GW",
IF(?capacity_in_Mw < 5000, "2GW-5GW",
IF(?capacity_in_Mw < 10000, "5GW-10GW",
IF(?capacity_in_Mw < 20000, "15GW-20GW",
">20GW")))))
AS ?layer).
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY DESC(?capacity_in_Mw)
LIMIT 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment