query-a323debd39b7352b487eeda70236e6d3
Query to return latitudes and longitudes for places in Paris
SELECT (COUNT(?a) AS ?count) (MIN(?lat) AS ?min_lat) (MIN(?long) AS ?min_long) (MAX(?lat) AS ?max_lat) (MAX(?long) AS ?max_long) WHERE { ?a wdt:P131+ wd:Q90 . # administrative territorial entity = Paris
?a p:P625 ?statement . # coordinate-location statement ?statement psv:P625 ?coordinate_node . ?coordinate_node wikibase:geoLatitude ?lat . ?coordinate_node wikibase:geoLongitude ?long .
{ SELECT ?a (COUNT(?a) AS ?count_stmt) WHERE { ?a wdt:P131+ wd:Q90 . ?a p:P625 ?statement } GROUP BY ?a HAVING (?count_stmt < 2) }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } }
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Query to return latitudes and longitudes for places in Paris
SELECT (COUNT(?a) AS ?count) (MIN(?lat) AS ?min_lat) (MIN(?long) AS ?min_long) (MAX(?lat) AS ?max_lat) (MAX(?long) AS ?max_long) WHERE {
?a wdt:P131+ wd:Q90 . # administrative territorial entity = Paris
?a p:P625 ?statement . # coordinate-location statement
?statement psv:P625 ?coordinate_node .
?coordinate_node wikibase:geoLatitude ?lat .
?coordinate_node wikibase:geoLongitude ?long .
{
SELECT ?a (COUNT(?a) AS ?count_stmt) WHERE {
?a wdt:P131+ wd:Q90 .
?a p:P625 ?statement
} GROUP BY ?a HAVING (?count_stmt < 2)
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?a"):::projected
v3("?coordinate_node")
v7("?count")
v7("?count_stmt")
v4("?lat"):::projected
v5("?long"):::projected
v10("?max_lat")
v11("?max_long")
v8("?min_lat")
v9("?min_long")
v2("?statement")
c2(["wd:Q90"]):::iri
c9(["bd:serviceParam"]):::iri
c11(["en"]):::literal
v1 --"p:direct/P131"--> c2
v1 --"p:P625"--> v2
v2 --"p:statement/value/P625"--> v3
v3 --"wikibase:geoLatitude"--> v4
v3 --"wikibase:geoLongitude"--> v5
f0[["?count_stmt < '2^^xsd:integer'"]]
f0 --> v7
v1 --"p:direct/P131"--> c2
v1 --"p:P625"--> v2
bind2[/"count(?a)"/]
v1 --o bind2
bind2 --as--o v7
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end
bind8[/"count(?a)"/]
v1 --o bind8
bind8 --as--o v7
bind9[/"min(?lat)"/]
v4 --o bind9
bind9 --as--o v8
bind10[/"min(?long)"/]
v5 --o bind10
bind10 --as--o v9
bind11[/"max(?lat)"/]
v4 --o bind11
bind11 --as--o v10
bind12[/"max(?long)"/]
v5 --o bind12
bind12 --as--o v11