Geograpy: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 10: | Line 10: | ||
|storemode=property | |storemode=property | ||
}} | }} | ||
= | = Adding city details from Wikidata = | ||
== Query == | |||
<source lang='sparql'> | |||
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 ?city ?cityLabel ?cityPop ?geoNameId ?country ?countryLabel ?countryIsoCode ?countryPopulation | |||
WHERE { | |||
# geoName Identifier | |||
?city wdt:P1566 ?geoNameId. | |||
# instance of human settlement https://www.wikidata.org/wiki/Q486972 | |||
?city wdt:P31/wdt:P279* wd:Q486972 . | |||
# population of city | |||
OPTIONAL { ?city wdt:P1082 ?cityPop.} | |||
# label of the City | |||
?city rdfs:label ?cityLabel filter (lang(?cityLabel) = "en"). | |||
# country this city belongs to | |||
?city wdt:P17 ?country . | |||
# label for the country | |||
?country rdfs:label ?countryLabel filter (lang(?countryLabel) = "en"). | |||
# https://www.wikidata.org/wiki/Property:P297 ISO 3166-1 alpha-2 code | |||
?country wdt:P297 ?countryIsoCode. | |||
# population of country | |||
?country wdt:P1082 ?countryPopulation. | |||
OPTIONAL { | |||
?country wdt:P2132 ?countryGdpPerCapita. | |||
} | |||
} | |||
</source> | |||
Revision as of 06:45, 26 September 2020
OsProject
| OsProject | |
|---|---|
| id | geograpy3 |
| state | |
| owner | somnathrakshit |
| title | geograpy |
| url | https://github.com/somnathrakshit/geograpy3 |
| version | 0.1.15 |
| description | |
| date | 2020/09/26 |
| since | |
| until | |
Adding city details from Wikidata
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 ?city ?cityLabel ?cityPop ?geoNameId ?country ?countryLabel ?countryIsoCode ?countryPopulation
WHERE {
# geoName Identifier
?city wdt:P1566 ?geoNameId.
# instance of human settlement https://www.wikidata.org/wiki/Q486972
?city wdt:P31/wdt:P279* wd:Q486972 .
# population of city
OPTIONAL { ?city wdt:P1082 ?cityPop.}
# label of the City
?city rdfs:label ?cityLabel filter (lang(?cityLabel) = "en").
# country this city belongs to
?city wdt:P17 ?country .
# label for the country
?country rdfs:label ?countryLabel filter (lang(?countryLabel) = "en").
# https://www.wikidata.org/wiki/Property:P297 ISO 3166-1 alpha-2 code
?country wdt:P297 ?countryIsoCode.
# population of country
?country wdt:P1082 ?countryPopulation.
OPTIONAL {
?country wdt:P2132 ?countryGdpPerCapita.
}
}