Skip to content

Instantly share code, notes, and snippets.

@postspectacular
Last active November 16, 2015 13:19
Show Gist options
  • Save postspectacular/75d7a356680928cc1071 to your computer and use it in GitHub Desktop.
Save postspectacular/75d7a356680928cc1071 to your computer and use it in GitHub Desktop.
thi.ng/fabric heatmap & ONS lat/lon polygon query
;; query spec to compute aggregated heatmap data of all property sales per borough
{:prefixes {"sg" "http://statistics.data.gov.uk/def/statistical-geography#"}
:q [{:where [[?s "rdf:type" "schema:SellAction"]
[?s "schema:price" ?price]
[?s "ws:onsID" ?boroughID]
[?borough "rdfs:label" ?boroughID]
[?borough "sg:officialName" ?name]
[?borough "sg:hasExteriorLatLongPolygon" ?poly]]}]
:aggregate {?num (agg-count ?s)
?avg (agg-avg ?price)
?min (agg-min ?price)
?max (agg-max ?price)
?apoly (agg-collect ?poly)
?aname (agg-collect ?name)}
:group-by ?boroughID
:select [?boroughID ?apoly ?avg ?min ?max ?num ?aname]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment