Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Marker size based on number of records in cluster #41

Open
rudibroekhuizen opened this issue Nov 25, 2020 · 0 comments
Open

Marker size based on number of records in cluster #41

rudibroekhuizen opened this issue Nov 25, 2020 · 0 comments

Comments

@rudibroekhuizen
Copy link

rudibroekhuizen commented Nov 25, 2020

I am using the trackmap panel in a dashboard to explore a GBIF dataset. Using the following query I can zoom in to streetlevel, and show the number of records in the tooltip for each cluster.

WITH a AS (
SELECT
eventdate AS time,
decimallatitude,
decimallongitude,
geom,
COUNT(*) OVER() AS cnt
FROM explore.gbif
WHERE $__timeFilter(eventdate)
AND decimallatitude >= $minLat
AND decimallatitude <= $maxLat
AND decimallongitude >= $minLon
AND decimallongitude <= $maxLon
), b AS (
SELECT
time,
decimallatitude,
decimallongitude,
ST_ClusterKMeans(geom, LEAST(cnt::integer, 200)) OVER() AS clusters
FROM a
)
SELECT
clusters,
COUNT(clusters) AS tooltip,
AVG(decimallatitude) AS latitude,
AVG(decimallongitude) AS longitude
FROM b
GROUP BY 1
ORDER BY 1;

Is it possible to use the number of records in a cluster to set the size of the marker? Or an option to use circles with sizes depending on the number of records in a cluster, like available in the worldmap panel?

clusters

Maximum zoom using LEAST and COUNT OVER():
maxzoom

@rudibroekhuizen rudibroekhuizen changed the title Tooltip size Marker size based on number of records in cluster Nov 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant