Without knowing much about what you are trying to analyze, it's difficult to say what an appropriate grouping would be. You might want to simply define something for yourself, e.g. 1-degree (or some even division) lat/long blocks if you want to stick with those coordinates and easily classify them. Whatever you use, I'm sure you're aware that can have an ...
You ST_Union the initial geometries by cid, so the consecutive run can only consider a single (Multi)geometry for clustering [*] - which it naturally fails at.
Insert the atomic rows into kmeans10 instead, then run the consecutive clustering (the second query should work as expected).
[*] Note that the ST_Union window function returns the same union for ...
You can dissolve you layer based on category: Menu Vector / Geoprocessing Tools / Dissolve, select the attribute that contains the category in the optional Dissolve field(s) option.
On the created layer, run Menu Vector / Geometry Tools / Multipart to singleparts. You get a new layer with one feature for each cluster.
On this layer, create an attribute for ...
Run Zonal Statistics As Table (or the QGIS equivalent) on your vector layer to get the min and max per polygon. Select polygons where min is not equal to the max (i.e. these polygons cover multiple raster values). Clip the raster based on these polygons, and then polygonize this clipped raster. Merge the resulting polygons back with the original polygons ...
It most likely uses graph theory. For example there are 2 groups if graph edges are shared boundaries only:
Links computed using Polygon to line.
There is just one group, if both corners and shared boundary are edges of graph:
Links computed using Polygon Neighbours.
I did this with python, pandas, and sklearn:
import pandas as pd
from sklearn.ensemble import IsolationForest
df = pd.read_csv("points.csv")
df["outlier"] = IsolationForest().fit_predict(df[["latitude", "longitude"]])
cleaned_df = df[df["outlier"] != -1]
It is important to additionally report the p-value because Moran's I values are often not standardized and so they are not comparable to each other.
If you were trying to find the Moran's I of some attribute, let's say for example housing price on a block, here's how you would calculate it. First, you make a scatterplot, where each block is represented by a ...