query-e43420580e0840eb7cdeba5fd976c7a0
tinyurl.com/zfwxj4nBut that did no good either. Does anyone have a way to do this? The following is an example of what I'm trying to do. If you comment out the last BIND, the query runs; however the POINT( ) strings cannot be plotted on a map. On the other hand, trying to cast from string to coords makes the query fail.
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?string ?count ?sample ?sampleLabel WHERE {
{
SELECT ?int_lat ?int_lon (COUNT(DISTINCT ?item) AS ?count) (SAMPLE(?item) AS ?sample) (SAMPLE(?string) AS ?string) WHERE {
?item wdt:P3616 [].
?item p:P625/psv:P625 ?coords .
?coords wikibase:geoLatitude ?lat .
?coords wikibase:geoLongitude ?long .
BIND(floor(?lat) AS ?int_lat) .
BIND(floor(?long) AS ?int_lon) .
BIND(CONCAT("Point(",str(?int_lon)," ",str(?int_lat),")") AS ?string) .
BIND(geo:wktLiteral(?string) AS ?int_coords)
} GROUP BY ?int_lat ?int_lon
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
ORDER BY DESC (?count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?coords")
v10("?count"):::projected
v9("?int_coords")
v6("?int_lat")
v7("?int_lon")
v2("?item")
v4("?lat")
v5("?long")
v10("?sample"):::projected
v11("?string"):::projected
a1((" "))
a2((" "))
c7(["bd:serviceParam"]):::iri
c9(["en"]):::literal
v2 --"p:direct/P3616"--> a1
v2 --"p:P625"--> a2
a2 --"p:statement/value/P625"--> v3
v3 --"wikibase:geoLatitude"--> v4
v3 --"wikibase:geoLongitude"--> v5
bind0[/"numeric-floor(?lat)"/]
v4 --o bind0
bind0 --as--o v6
bind1[/"numeric-floor(?long)"/]
v5 --o bind1
bind1 --as--o v7
bind2[/"concat('Point(',str(?int_lon),' ',str(?int_lat),')')"/]
v7 --o bind2
v6 --o bind2
bind2 --as--o v11
bind3[/"http://www.opengis.net/ont/geosparql#wktLiteral(?string)"/]
v11 --o bind3
bind3 --as--o v9
bind7[/"count(?item)"/]
v2 --o bind7
bind7 --as--o v10
bind8[/"sample(?item)"/]
v2 --o bind8
bind8 --as--o v10
bind9[/"sample(?string)"/]
v11 --o bind9
bind9 --as--o v11
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end