Is there a way to perform cluster analysis on a selection of a layer in CARTO? For example, if had data points throughout the U.S., and I wanted to know cluster of points in San Francisco, could I feasibly do (pseudo-SQL ahead):
SELECT ST_ClusterWithin(geom) FROM table
WHERE city = "San Francisco"
Or am I better off just splitting layers by city and then performing analysis on each layer in CARTO? I realize this option may not be ideal for ease of updating data across the layers. Any help is appreciate, thank you.
You can use the Filter by column value
to extract a selection of your table and then perform the cluster analysis on that analysis node. You can even drag out the original dataset source to create a layer and perform again your analysis on another selection.
+---------+
| dataset |
+------------+---------+----------+
| |
+-----------v------------+ +-------------v--------+
| name = "San Francisco" | | name = "New York" |
+-----------+------------+ +-------------+--------+
| |
| |
+----------v---------+ +-----------v-------+
| cluster analysis | | cluster analysis |
+--------------------+ +-------------------+