query-1754a466d8c9a6c2fc38a17c79508852
CitiesHello, I need a DB of all the cities in the world, an alternative to geonames org and since wikipedia seems to have a page of all the cities, I guess I could use this site. So im trying to learn the query, and made this query for all the cities of italy but the result is only 150 rows instead of 7000, so am i doing anything wrong ? The query:
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?cityLabel ?city ?official_name ?located_in_the_administrative_territorial_entity ?country WHERE {
?city (wdt:P31/wdt:P279*) wd:Q515.
FILTER (?country = wd:Q38)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
OPTIONAL { ?city wdt:P1448 ?official_name. }
OPTIONAL { ?city wdt:P131 ?located_in_the_administrative_territorial_entity. }
OPTIONAL { ?city wdt:P17 ?country. }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?city"):::projected
v1("?country"):::projected
v4("?located_in_the_administrative_territorial_entity"):::projected
v3("?official_name"):::projected
a1((" "))
c6(["bd:serviceParam"]):::iri
c4(["wd:Q515"]):::iri
c8(["en"]):::literal
f0[["?country = 'wd:Q38'"]]
f0 --> v1
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c4
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c8
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P1448".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P131".-> v4
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P17".-> v1
end