query-f6e60923c6c3d78ce57f21e95b94fe39

rq turtle/ttl

Scatterplot queryThe following query sort of works, but there's odd stuff going on. matches. It compares the main coordinates for a set of items with GB1900 coordinates stored as a qualifier on the GB1900 statement. It then turns the difference into an approximate x-offset (dx) and y-offset (dy) in kilometres, and plots dx and dy on a scatterplot. The idea is to see where the GB1900 points (which represent the start of labels on the map) occur relative to the location of the actual item (represented by the main coordinates?), and to try to surface any outliers. (P9284)GB1900 ID The query is a quality-control query for It does sort-of work, but Is there any way to add more information to the points -- ideally including their Qids, item labels, and a specially-constructed url to link to the OS1900 map. I seem to be getting a rogue point with a very large negative dx value, that doesn't correspond to anything in the table. (Could it be the sum of all the dx,dy values ?)It would also be nice to be able to force the axes to be the same scale.

Use at

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 pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:ScatterChart
#SELECT ?dx ?dy ?item ?itemLabel (?dx * ?dx + ?dy * ?dy AS ?r2)
SELECT ?dx ?dy ?itemLabel 



WHERE {
   {
  SELECT ?item ?gb1900_stmt ?coord_stmt WHERE {
    ?item p:P9284 ?gb1900_stmt .
    ?item wdt:P31 wd:Q489357 .
    ?item p:P625 ?coord_stmt .
  }
}.  
  ?coord_stmt psv:P625/wikibase:geoLatitude  ?wd_lat .
  ?coord_stmt psv:P625/wikibase:geoLongitude ?wd_lon .

  ?gb1900_stmt pqv:P625/wikibase:geoLatitude ?gb_lat .
  ?gb1900_stmt pqv:P625/wikibase:geoLongitude ?gb_lon .
  BIND ( 111.2 * (?gb_lat - ?wd_lat) AS ?dy) .   # one degree of latitude is about 111 km
  BIND (  65.4 * (?gb_lon - ?wd_lon) AS ?dx) .   # one degree of longitude is about 63 km at 54 degrees North. (eg York)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?r2)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?coord_stmt") v10("?dx"):::projected v9("?dy"):::projected v3("?gb1900_stmt") v7("?gb_lat") v8("?gb_lon") v2("?item") v1("?r2") v5("?wd_lat") v6("?wd_lon") a1((" ")) a2((" ")) a3((" ")) a4((" ")) c10(["bd:serviceParam"]):::iri c3(["wd:Q489357"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"p:P9284"--> v3 v2 --"p:direct/P31"--> c3 v2 --"p:P625"--> v4 v4 --"p:statement/value/P625"--> a1 a1 --"wikibase:geoLatitude"--> v5 v4 --"p:statement/value/P625"--> a2 a2 --"wikibase:geoLongitude"--> v6 v3 --"p:qualifier/value/P625"--> a3 a3 --"wikibase:geoLatitude"--> v7 v3 --"p:qualifier/value/P625"--> a4 a4 --"wikibase:geoLongitude"--> v8 bind0[/"'111.2^^xsd:decimal' * ?gb_lat - ?wd_lat"/] v7 --o bind0 v5 --o bind0 bind0 --as--o v9 bind1[/"'65.4^^xsd:decimal' * ?gb_lon - ?wd_lon"/] v8 --o bind1 v6 --o bind1 bind1 --as--o v10 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end