Spatial Statistics Studio
User and methods guide · QGIS 3.40 or later 3.x · 2.3.7
Installation and start
- In QGIS open Plugins → Manage and Install Plugins → Install from ZIP and choose
Spatial_Statistics_Studio_v2.3.7.zip. - If an earlier version is installed under the name Spatial Statistics Lab or Spatial Regression Lab, uninstall it first. Spatial Statistics Studio installs under a new identifier and replaces both.
- The tools are available from the Spatial Statistics Studio toolbar button, from Plugins → Spatial Statistics Studio and from Processing → Toolbox → Spatial Statistics Studio. Menu and toolbox have five groups: Regression, Clustering, Point pattern analysis, Spatial autocorrelation and Multiscale analysis.
- Less frequently needed settings are in the collapsed Advanced Parameters group of each tool. To keep the results, save the layer to a GeoPackage and the report to an HTML file.
- Every tool dialog has a short description on the right. Hover over a parameter for more detail, and the Help button opens this guide.
The interface follows the QGIS language. In Hungarian QGIS all labels, reports and this guide appear in Hungarian, in other languages in English. Field names are the same in every language. The plugin runs in the QGIS Python environment and needs NumPy and SciPy. Clustering needs nothing else. Random Forest needs scikit-learn, XGBoost also needs the xgboost package.
Quick start
- Open a tool from the Spatial Statistics Studio button or the Processing Toolbox. For a first try, GLR / OLS and HDBSCAN are the simplest.
- Set the Input layer to the vector layer you want to analyse.
- For regression choose the field to explain in Dependent variable. The list starts at the first numeric field, often the
fididentifier, so always change it. The tool does not run with the identifier field. Tick the explanatory fields with the … button next to Explanatory variables, and match the Model family to the dependent variable. - For clustering only the point layer is needed. A value of 0 means an automatic setting.
- Click Run. The styled output layer appears on the map. Open the HTML report from the Processing → Results Viewer panel, or in a browser if you gave it a file name.
For local regression models (GWR, MGWR) the Bandwidth setting decides whether the plugin searches for the bandwidth or you set it. A manual value is only used with Manual value. Otherwise a warning is written to the log.
Regression · which model when?
First choose the model family from the type of the dependent variable. Then decide whether you want one relationship for the whole area, local differences in the coefficients, or a model of dependence between neighbouring observations.
| Tool | When to use it | What to look at |
|---|---|---|
| OLS (Gaussian GLR) | A continuous dependent variable, for example surface temperature in °C. The coefficients are shared by the whole study area. | Coefficients, adjusted R², VIF, the residual map and residual Moran's I. |
| Binary logistic GLR | The response is 0 or 1, for example whether a grid cell has a warm night. | Predicted probability, exp(β) as odds ratio and the cross-validation result. |
| Poisson GLR | Non-negative integer counts. With varying observation time, set the number of days as exposure. | Expected count, rate ratio for equal exposure and the overdispersion measures. |
| Negative binomial GLR (NB2) | The Poisson model underestimates the spread of the counts and overdispersion remains after adding explanatory variables. | The dispersion (α) is fixed in the plugin. Check how sensitive the results are to its value. |
| Gaussian GWR | A continuous response, and you want to know where the relationship is stronger or weaker, for example how the link between tree canopy and surface temperature varies in space. | Local coefficients, standard errors, local R² and condition number. One bandwidth is shared by all coefficients. |
| Logistic GWR | A binary response whose relationships may vary in space. Every local neighbourhood needs enough observations of both classes. | Probability map, local coefficients and the stability of the fit. |
| GWPR (Poisson GWR) | Counts whose relationships are expected to differ by area, for example the number of hot days may depend differently on sealed surfaces in different parts of a city. | Local coefficients, share of deviance explained and the bandwidth. Take the exposure into account when reading expected counts. |
| MGWR | A continuous response whose explanatory variables may act at different spatial scales. | The bandwidth of each variable, local coefficients and conditional standard errors. MGWR can give the intercept its own bandwidth. |
| Spatial autoregression (SAR, SEM, SAC) | A continuous response where you want to model dependence between neighbours. SAR models the spatial lag of the dependent variable, SEM the spatial dependence of the errors, SAC both. | The justification of the weights matrix, the LM tests and the spatially filtered residuals. For SAR and SAC also the average direct and indirect impacts. |
| Exploratory OLS | Searching for candidate models among several well-founded variables for a continuous response. | AICc, variables and diagnostics of the models that pass. p-values after a variable search are exploratory. |
| Random Forest | Prediction or classification is the aim and non-linear relationships or interactions are expected. | Spatial cross-validation and variable importance. The error on the training sample alone says little about performance. |
| XGBoost | Comparing predictive performance with other methods, with control over tree depth, learning rate and number of trees. | Compare with Random Forest or GLR on the same spatial folds. |
| Apply a saved GLR model (JSON) | Only in the Processing Toolbox. Needed when a GLR model saved earlier to JSON is applied to another layer without refitting. To predict onto a new layer in the same run, the Prediction layer parameter of the model tool is enough. | Matching variables, units and the range of the new data. |
For a continuous response a practical order is to fit OLS first, then examine the residuals and spatial dependence. GWR and MGWR describe how the coefficients vary in space. SAR, SEM and SAC model different forms of dependence between neighbours. Let the research question and the diagnostics guide the choice together.
Try regression on the urban microclimate sample
Open sample layer (urban microclimate) loads 196 synthetic 500 × 500 m cells in EOV. In the examples below the two explanatory variables are lombkorona_arany (tree canopy share) and burkolt_arany (sealed surface share), both between 0 and 1.
| Tool | Dependent variable | Settings |
|---|---|---|
| OLS | felszini_hom · surface temperature in °C | Choose the Gaussian family in GLR. Queen contiguity works for the residual Moran's I. |
| Poisson GLR | forro_napok · days with a maximum above 35 °C | Set megfigyelt_napok (days observed) as exposure. |
| GWPR | forro_napok | Choose the Poisson family in GWR, set the megfigyelt_napok exposure, an adaptive bisquare kernel, Bandwidth Manual value and a manual bandwidth of 100. |
| Logistic GWR | meleg_ej · 1 if the night minimum was at least 20 °C | Choose the binary logistic model with an adaptive bisquare kernel and a Manual value of 130. |
| MGWR | felszini_hom | Adaptive bisquare kernel. For manual bandwidths choose Manual value and enter 150 65 170, starting with the intercept. For an automatic grid search set a range of 60 to 196 and 8 steps in the Advanced Parameters. |
| Spatial validation | forro_napok | In Poisson GLR set the megfigyelt_napok exposure and use the teruleti_blokk field as your own fold field. |
Main settings of the regression tools
Coordinates and neighbourhoods
- Planar distances are computed in the chosen projected CRS and reported in metres. EOV (
EPSG:23700) works for Hungary. Great-circle distances use WGS84 coordinates. Output geometries keep the CRS of the input layer. - For polygons the distance-based models use the centroid or a point on the surface. Queen contiguity needs a shared boundary point, rook contiguity a shared boundary of positive length.
- Every row of the weights matrix with at least one neighbour sums to 1. Rows of features without neighbours are zero. With symmetric k nearest neighbours a link exists if either feature is among the nearest neighbours of the other.
- Features left out because of a missing value or coordinate stay in the output layer with empty result fields.
Bandwidth and kernel
- A fixed bandwidth is given in metres. With an adaptive bandwidth the distance to the given nearest neighbour sets the local radius, and the observation at the regression point counts as a neighbour. Observations at equal distance get equal weight.
- The bisquare kernel gives zero weight beyond the radius. For the Gaussian and exponential kernels the bandwidth controls how quickly the weight decreases with distance.
- The automatic search uses a grid, or a scan followed by golden-section search. The criterion is the corrected AIC (AICc) or leave-one-out cross-validation. For Gaussian GWR the leave-one-out effect comes from the leverage. For Poisson and logistic GWR the local fit is repeated without the observation, keeping the local radius.
- MGWR selects a bandwidth for every term from the partial residuals and refits with these bandwidths fixed. In the manual list the intercept comes first, followed by the explanatory variables in the order they were selected.
- When the local data are few, a binary response has only one class locally, or the explanatory variables are locally collinear, try a larger bandwidth.
Exposure and diagnostics
- In Poisson and NB2 models the exposure must be positive. Its natural logarithm enters with a fixed coefficient of 1. A unit increase of an explanatory variable multiplies the rate by
exp(β), other variables unchanged. In the logistic modelexp(β)is the odds ratio. - If the Pearson χ² divided by its degrees of freedom is well above 1 in a Poisson model, look for the cause of overdispersion. In NB2 the variance is
μ + αμ²with α set by the user. - For local p-values choose the ENP-based correction, the Benjamini–Hochberg procedure per variable or raw p-values. Coefficients and standard errors are reported in the original units.
- Residual Moran's I shows whether what the model leaves unexplained clusters in space. Turn on a weights matrix to compute it. The report gives the analytical z-score and two-sided p-value, and with a positive number of permutations also the folded permutation pseudo p-value. The Moran filter of exploratory regression uses the analytical p-value, as ArcGIS does.
- Spatial cross-validation holds out spatially contiguous groups. The automatic option forms bands along the main axis of the coordinates. Your own districts or grid blocks can be used through a fold field.
Reading the regression results
The HTML report starts with the summary and the coefficient tables, followed by the meaning of each field and the settings of the run. The name of the new layer holds the model, the dependent variable and the local start time, for example GWR · felszini_hom · 2026-11-28 18:20:05.123. A prediction layer from the same run carries the same time stamp.
| Example field | Meaning |
|---|---|
coef_intercept, coef_lombkorona_arany | The local intercept and the local coefficient of the named variable. |
se_lombkorona_arany, t_lombkorona_arany | Standard error of the coefficient and its t or z statistic. |
p_lombkorona_arany, p_adj_lombkorona_arany, sig_lombkorona_arany | Raw p-value and p-value with the selected correction (equal in raw mode). The significance field is −1 for a significant negative coefficient, +1 for a significant positive one and 0 otherwise. |
bw_m_lombkorona_arany | Local MGWR bandwidth of the coefficient in metres. For adaptive models the report gives the number of neighbours. |
srl_fit, srl_resid | Fitted value and residual. In the logistic model the fitted value is the probability of class 1. |
srl_locfit, srl_cond, srl_bw_m | Local R² in Gaussian GWR or the share of deviance explained in the other GWR models, the condition number of the weighted design matrix and the local bandwidth. |
srl_stdres, srl_cook | Standardised residual and Cook's distance of OLS. |
srl_fold, srl_cvfit | Cross-validation fold and the prediction made with that fold left out. |
Field names are the same in every interface language, so projects and scripts work in any QGIS language. Intercept fields end in intercept. Local field names hold the variable name in lower case without accents, with underscores for spaces and punctuation, and a number for duplicates. The field alias, also shown in the attribute table header, and the HTML report give the full description. Prefer GeoPackage for long field names, because Shapefile cuts them to ten characters.
By default the layer is styled by the residuals, standardised where available. In the Advanced Parameters, Style of the output layer can show the fitted value or a local coefficient instead, and for GWR and MGWR Coefficient to map selects the variable. A GeoPackage output keeps the automatic style.
To predict at new locations choose a prediction layer. Fields with the same name are matched automatically. For other names enter model_field=target_field pairs separated by commas in the field matching of the Advanced Parameters, for example megfigyelt_napok=napok_2025, lombkorona_arany=lombkorona_2025. JSON also works. To map local coefficients on a separate grid, use a target grid and turn on local coefficients only.
Clustering · methods guide
The clustering tools look for spatial concentrations of points from their coordinates alone. They are density-based: a cluster is a dense, connected region of points surrounded by sparser space. The number of clusters is not set in advance, clusters may have any shape (for example stretched along a road), and isolated points are left as noise instead of being forced into a group. This differs from k-means, which assigns every point and assumes roughly round groups of similar size.
Coordinates without standardisation
Clustering uses the coordinates in metres in the analysis CRS and deliberately does not standardise them. Standardisation is needed when clustering attributes because their units differ. Both coordinate axes share the same unit, and standardising would stretch them differently whenever the study area is not square. In an area 20 km wide and 5 km high, east–west distances would shrink to a quarter and cluster shapes would be distorted. Choose a projected CRS that keeps distances, such as EOV (EPSG:23700) in Hungary. For a layer in geographic coordinates either choose a projected CRS in Analysis CRS or set Distance type to great circle. For polygons the centroid or a point on the surface is used.
Which tool when?
| Tool | When to use it | What to look at |
|---|---|---|
| HDBSCAN | The default choice. It finds clusters of different density, needs no distance threshold, and gives every point a membership strength and an outlier score. | The condensed tree, the per-cluster statistics, the membership map and the noise points. |
| OPTICS | When you want to see the cluster structure as a function of distance, or need a DBSCAN-like cut at a given distance. The reachability plot shows nested concentrations well. | Valleys and peaks of the reachability plot. Drag the line on the plot to try different cut distances. |
| Clustering parameter sensitivity | Always, before you interpret or publish clusters. It runs HDBSCAN or OPTICS over a grid of parameters and shows which clusters persist. | How the number of clusters and the noise share change, the agreement with the reference (ARI) and the stability of each point. |
How HDBSCAN works and its parameters
HDBSCAN computes a core distance for every point, the distance to its minimum-samples-th nearest neighbour (the point itself included). The mutual reachability distance of two points is the largest of their distance and their two core distances. This pushes points in sparse areas apart but leaves dense areas unchanged. From these distances a hierarchy is built that describes how the points break apart as the distance threshold shrinks. The hierarchy is simplified with the minimum cluster size (a smaller group splitting off is not a new cluster but points dropping out), and the clusters that persist longest with the most points are selected (excess of mass, EOM).
- Minimum cluster size. The smallest number of points you would still call a cluster. This is the main parameter to think through. 0 gives an automatic value of 1% of the points, at least 5.
- Minimum samples. Controls how conservative the result is. Larger values give smoother clusters and more noise, and separate dense cores better. 0 uses the minimum cluster size. The point itself counts, as in scikit-learn (in the hdbscan Python package the same setting is one smaller).
- Allow a single cluster. Off by default. When on, HDBSCAN may return all points as one cluster if no split is stable.
The results are identical to the HDBSCAN of scikit-learn and of the hdbscan package, which was checked on several parameter combinations during development.
How OPTICS works and cluster extraction
OPTICS uses the same core distance but, instead of a hierarchy, it orders the points so that the points of a dense region follow each other. Every point gets a reachability distance, the distance at which it can be reached from the dense region before it in the order. The reachability plot shows the points in order with the reachability distance as bar height. Valleys are dense clusters, peaks the sparser gaps between them.
- Xi extraction finds clusters from the steep slopes of the plot, so clusters of different density are found. Xi is the minimum relative steepness of a cluster edge. A larger Xi gives fewer, more distinct clusters. Xi can find nested clusters, in which case every point gets the smallest cluster that contains it.
- Cut at a distance cuts the plot at a horizontal line, which gives the same clusters as DBSCAN at that distance. With 0 the 90th percentile of the reachability distances is used as a start.
The order and reachability distances are identical to the OPTICS of scikit-learn with an unlimited search radius.
Output layer and styling
| Field | Meaning |
|---|---|
cluster | Cluster number. 1 is the largest cluster and numbers decrease with size. Noise points are −1. Features without usable geometry are empty. |
cl_member | HDBSCAN membership strength between 0 and 1. How long the point stays in its cluster as the distance threshold shrinks, relative to the most persistent point of the cluster. Near 1 in the core, lower at the edge, 0 for noise. It is not a probability of belonging. |
cl_outlier | GLOSH outlier score between 0 and 1. Compares the density around the point with the highest density of its cluster. Values near 1 mark unusual points, even inside a cluster. |
cl_core_m | Core distance in metres. Smaller values mean denser surroundings, so it can be mapped as a simple local density measure. |
cl_order, cl_reach_m | OPTICS order and reachability distance in metres. The first point of every region has no reachability distance and the field is empty. |
cl_depth, cl_reason | How many nested Xi clusters contain the point, and a plain-language reason why it became a member or noise. With Xi extraction the most common surprise is a noise point right next to a cluster point. Such a point lies inside a larger, enclosing cluster but in none of its sub-clusters, and as in scikit-learn only the innermost clusters get a number. With a larger Xi or minimum cluster size these points usually become members. |
The layer is styled automatically. Clusters get clearly distinct colours, noise points a smaller, lighter grey symbol drawn below the clusters. Other styles are opacity by membership strength (edge points are faint), membership strength itself, the outlier score and, for OPTICS, the reachability distance. The report diagrams use the same cluster colours as the map.
The Cluster hulls output draws a convex polygon for every cluster with its statistics (points, share, area, density, standard distance, and mean and median of the chosen fields). A convex hull shows the extent of a cluster but includes empty space for stretched or curved clusters, so its area and the density derived from it are indicative only.
Reading the report diagrams
Condensed tree (HDBSCAN). The vertical axis is distance on a log scale, the largest at the top. Every bar is a candidate cluster. Moving down, the distance threshold shrinks: the bar narrows as points drop out and splits where a cluster falls apart. Coloured bars are the selected clusters, numbered as in the cluster field. A long, wide bar is a stable cluster. Grey branches below a selected cluster show internal structure that a smaller minimum cluster size could turn into separate clusters. Hover over a bar to see its points, stability and the distance at which it appears.
Reachability plot (OPTICS). A deep, wide valley is a large dense cluster, a narrow valley a small one, and smaller valleys inside a valley are nested concentrations. Click and drag on the plot to draw a horizontal cut line, and the plot recolours the points live by the DBSCAN-like clusters at that distance, with the number of clusters and the noise share. Scroll to zoom along the order, double-click to see all points, and use the button to return to the clusters of the run. The bars under the plot show the hierarchy of the Xi clusters. A coloured bar is a numbered cluster, a dashed grey bar an enclosing cluster. A point with only grey bars under it counts as noise.
After a run started from the plugin menu or from Studio, the QGIS message bar shows an Open report button. For runs started from the Processing Toolbox the report is listed in the Results Viewer.
Descriptive statistics by cluster
The Clusters table of the report gives for every cluster the number and share of points, the centre coordinates, the standard distance (root mean square distance from the centre, a measure of spatial spread), the largest distance from the centre, the convex hull area, the point density and, for HDBSCAN, the mean membership strength and outlier score. Noise points have their own row. Numeric fields chosen in Fields for per-cluster statistics get a table each (valid values, mean, median, standard deviation, minimum, maximum). These fields do not influence the clustering, they only describe the clusters.
Parameter sensitivity
Density-based clusters depend on the parameters, so the result of a single run should not be interpreted on its own. The sensitivity tool runs HDBSCAN over a grid of minimum cluster sizes and minimum samples, or OPTICS over minimum samples and Xi. With empty lists it uses 0.5, 0.75, 1, 1.5, 2 and 3 times the automatic value. The reference setting is always the automatic one, marked with a star in the report.
- The heat-map tables show for every setting the number of clusters, the noise share, the agreement with the reference and the mean stability of the reference clusters. Switch between them with the buttons.
- The adjusted Rand index (ARI) measures the agreement of two partitions. 1 means identical partitions, values near 0 no better than chance. Noise counts as one group.
- Stability (
cl_stable) shows for every point how well its reference cluster mates stay together in other settings (Jaccard overlap averaged over the runs, becoming noise counts as 0).cl_clusteredis the share of runs in which the point is not noise. - A robust cluster keeps a high stability over a broad range of settings. Do not interpret a cluster on its own if it appears only in a narrow band of settings or its stability is below 0.5.
Interpretation
- Population at risk. Point concentrations often reflect where events have more opportunity to happen. Accidents concentrate where traffic is heavy, crimes where many people are present. A density-based cluster is therefore not a concentration of risk. If risk is the question, relate the events to the population at risk, for example as rates on a grid or with Poisson regression and an exposure.
- Statistical significance. HDBSCAN and OPTICS are exploratory, not hypothesis tests. Hot spot or point pattern methods tell whether a concentration is stronger than chance.
- Edge effects. Points at the edge of the study area have fewer neighbours, so clusters there break into noise more easily. Use data that extend beyond the study area where possible.
- Identical coordinates. Points geocoded to the same location (an address or a junction) create artificial concentrations. Check whether they are real repetitions.
- Run time. Both methods take time proportional to the square of the number of points. A few tens of thousands of points take seconds, above 50 000 points a run can take minutes.
Try clustering on the accident sample
Open sample layer (traffic accidents) loads 766 synthetic accident points in EOV. They include a compact and a looser round group, a band stretched along a road, a small and very dense group, a large sparse group and evenly scattered background noise. The attributes are the number of injured (serultek), material damage in thousand HUF (anyagi_kar_eft) and the hour of the accident (ora).
| Tool | Settings | What to observe |
|---|---|---|
| HDBSCAN | All parameters 0. Tick all three fields for per-cluster statistics and request the Cluster hulls output. | The stretched band is one cluster and has the highest mean number of injured among the large clusters. A small, loose group forms from the background noise. Its mean from 8 points is even higher, but the sensitivity analysis shows that this cluster is not reliable. |
| HDBSCAN | Minimum cluster size 15, minimum samples 5, style with opacity by membership strength. | Points are fainter at the cluster edges. The condensed tree shows which cluster has internal structure. |
| OPTICS | All parameters 0, Xi extraction. | The reachability plot has five deep valleys. Xi also returns the smaller concentrations inside the valleys as separate clusters. Dragging the cut line to between 400 and 500 metres gives five large clusters. |
| Parameter sensitivity | HDBSCAN with empty lists. | Smaller parameter values give more clusters, larger minimum samples give a stable five. The small group from the background noise has low stability and should not be interpreted. |
Point pattern analysis
Four tools describe the overall distribution, directional tendency, scale-dependent structure and continuous intensity of a point pattern. Single-part point geometry and a suitable projected CRS are required. Distances are calculated in metres. For the Hungarian sample use EOV (EPSG:23700). Projection choice affects distances and areas.
Average Nearest Neighbor (ANN / NNA)
When to use: To summarise whether points are closer together or farther apart than expected under complete spatial randomness (CSR).
Specify the actual polygon or rectangular observation window. NNI is observed mean nearest-neighbour distance divided by the homogeneous CSR expectation 0.5√(A/n). NNI < 1 suggests clustering; NNI > 1 suggests dispersion. In addition to the analytical z and p values, the tool simulates fixed-count uniform CSR within the same window. Prefer the Monte Carlo p value because the analytical approximation ignores edge effects. The output field nn_dist_m is nearest-neighbour distance in metres; optional links connect neighbours. Coincident points have zero distance.
Standard Deviational Ellipse (SDE)
When to use: To describe mean centre, directional tendency and spread, including comparisons across categories or periods.
Optionally select a strictly positive weight field and a grouping field. Semi-axes are the square roots of the population covariance eigenvalues multiplied by 1, 2 or 3 standard deviations. Azimuth is clockwise from grid north, modulo 180°; it is undefined for circular ellipses. Groups with fewer than three points or collinear locations are skipped. Mean centres are optional separate output. Semi-axes are in metres, area in km², centre coordinates in the projected CRS units. This is not a confidence ellipse; 1σ does not guarantee 68% coverage. Other software may use different SDE scaling conventions. ArcGIS Pro (Directional Distribution) and CrimeStat multiply the axes by √2, so their 1σ ellipse is about 1.41 times larger than here.
Ripley's K / L function
When to use: To identify distance scales where clustering or regularity occurs, rather than only the nearest neighbour.
The rectangular window uses translation edge correction by default, with pair weight A/[(W−|Δx|)(H−|Δy|)]. Maximum radius is limited to half the shorter window side; automatic selection uses one quarter. K(r) is in m², L(r)=√(K(r)/π) in metres. The theoretical homogeneous CSR reference for L(r)−r is zero. Positive values suggest clustering and negative values regularity. The 95% simulation envelope is pointwise, not simultaneous. A global Monte Carlo p value uses the maximum absolute deviation across radii. The report contains the results table and hoverable curves. Limit: 2,500 points per run, 19–999 simulations.
Kernel density estimation (KDE)
When to use: To map continuous spatial event intensity; KDE is not itself a statistical significance test.
Choose fixed or adaptive Gaussian kernel, cell size and optional bandwidth and extent. For automatic bandwidth, the tool compares 0.5, 0.75, 1, 1.5 and 2 times a Scott-type isotropic rule using leave-one-out log likelihood for up to 4,000 points. Above that it uses the rule directly. Adaptive mode uses Abramson-type pilot-density factors clipped to 0.25–4. Optional fixed h/2 and 2h comparison rasters use the same grid and colour scale. Intensity is in events/km², not population-adjusted risk. Kernels are truncated at four bandwidths; boundary mass is not corrected. GeoTIFF output is capped at one million pixels and 250 million estimated kernel-cell operations per raster. Adaptive mode supports up to 20,000 points.
Try it with the traffic accident sample
- Load the traffic accident sample from the toolbar menu. CRS: EPSG:23700.
- NNA and Ripley: use an illustrative EOV rectangle X 731000–740000, Y 96000–106000, not a real observation boundary. Ripley: 2000 m maximum radius, 20 steps, 99 simulations.
- SDE: try grouping by
ora, then without grouping. Only use strictly positive weights. - KDE: 100 m pixels, automatic bandwidth; try the two comparison rasters and adaptive mode.
Important: For NNA and Ripley, the rectangle is appropriate only if it represents the observation window. Irregular administrative boundaries and heterogeneous population or exposure can make homogeneous CSR misleading. Results do not establish causality.
Spatial autocorrelation
Study polygons (NNA and Ripley): choose a polygon layer instead of a rectangle; the polygon overrides the extent. Features are dissolved, holes and multipart areas retained, and transformed into the analysis CRS. All points must lie inside or on its boundary; clip inputs beforehand if necessary. CSR simulations are uniform over the actual polygon, and the NNA analytical expectation uses its true area. For polygon Ripley, edge correction uses reduced sampling (border correction): at each radius r, only centres at least r from any boundary are eligible. K = A × directed neighbour count / [eligible centres × (n−1)]. If no eligible centre remains in any simulation or observed pattern, reduce the maximum radius. This differs from rectangular translation correction. The homogeneous CSR assumption still applies. KDE remains rectangular.
Which tool to use?
| Tool | When and how to interpret |
|---|---|
| Global Moran I | Overall similarity of nearby attribute values. Compare I with E[I]=−1/(n−1). Two kinds of inference are reported, as in GeoDa and PySAL esda. The analytical z-score uses the moments under the randomisation assumption and gives a two-sided normal p-value. The permutation pseudo p-value is folded and one-sided, (M+1)/(R+1) counted in the nearer tail, exactly like the local Moran pseudo p-value, so it never exceeds about 0.5. The Moran scatterplot displays z versus Wz. |
| Global Geary C | Overall local differences. C<1 indicates positive autocorrelation, C>1 negative. The same two kinds of inference are reported as for Moran I. When the analytical and the permutation result disagree, prefer the permutation result for skewed data and small samples. |
| Local Moran I (LISA) | Locate High-High and Low-Low clusters and Low-High and High-Low spatial outliers. The calculation follows GeoDa and PySAL esda. Values are standardised with the sample variance, conditional randomisation keeps the focal value fixed and draws the other values without replacement, and the pseudo p-value is folded and one-sided, (M+1)/(R+1), where M counts permutations at least as extreme in the nearer tail. Cluster codes and colours are those of GeoDa: 0 not significant, 1 High-High, 2 Low-Low, 3 Low-High, 4 High-Low, 5 neighbourless. As in GeoDa, the default map uses p ≤ 0.05 without FDR correction, and FDR or a stricter level can be switched on. With the same weights the results differ from GeoDa only by random permutation error, so use 9999 permutations for stable borderline cases. |
| Getis–Ord Gi* | Locate concentrations of high or low values. Analytical normal z and two-sided p, including the focal feature. Output gi_bin ranges −3 to +3 (90/95/99% thresholds). Not an event-density test. |
| Spatial weights diagnostics | Check neighbour counts, islands and connected components before inference; optional directed CSV includes input feature IDs and weights actually used. |
Weights and settings
Queen: polygons sharing an edge or corner; Rook: shared edge only. Requires valid polygon topology. KNN: choose k less than n; symmetric union optional. Fixed distance: equal weights for neighbours in the band. Inverse distance: 1/d within the band; coincident locations are rejected. Automatic band equals the largest nearest-neighbour distance (if positive). Distances are planar metres between points or polygon centroids, with a projected CRS. Row standardisation divides weights by row sums. Gi* adds a self-weight before standardisation: automatic is 1 for binary weights, median link weight for inverse distance. Missing values are excluded before weights construction; islands must be resolved before inference.
Local tests optionally use Benjamini–Hochberg FDR adjusted p-values, not an exact Esri implementation. With many tests, increase permutations for sufficient p-value resolution. As in esda, one set of random draws is shared by all features, so local Moran handles tens of thousands of features in seconds. Permutation results depend on the random seed and are not identical to analytical ArcGIS statistics.
Try it
Open the synthetic urban microclimate grid from the toolbar, choose a numeric non-ID field and Queen contiguity. Run weights diagnostics, then global Moran and local Moran or Gi*. Compare Rook and KNN and consider how the neighbourhood changes the conclusions. Export the layer as GeoPackage and the report as HTML.
Multiscale grid analysis (MAUP)
Compare spatial patterns of the same point dataset across grid sizes and grid placements. Use this when investigating the sensitivity of hotspots and global autocorrelation to aggregation, for example for urban events.
- Select single points, the actual study polygon and a suitable local projected CRS. Polygons are dissolved; multipart areas and holes are retained. Clip points outside the study area first.
- Enter 2–8 sizes in metres (e.g. 250, 500, 1000). All baseline grids share the lower-left corner of the study bounding box. With the offset option four origins are tested. The legend calls them base grid, ½ cell east, ½ cell north and ½ cell north-east, so the same scale is seen with different cell boundaries, the zoning effect of MAUP. The fields hold the east and north offsets as a share of the cell size (0 or 0.5).
- Cell shape can be squares, hexagons or both. A hexagon has the same area as the square of the same nominal size (0.0625 km² at 250 m), so counts and densities are comparable, the centre spacing is 1.075 × size. A hexagon has six edge neighbours and no corner neighbours, so it is less sensitive to the grid orientation and its neighbour relations are uniform. With both shapes the scenarios of the two shapes can be compared side by side.
- Choose count or points/km². Positive-area clipped cells, including zero counts, are retained. Each point is counted once per grid. Counts depend on cell area; density can be unstable in tiny edge cells.
- Choose Queen, Rook, symmetrised KNN or fixed distance. Relations refer to the original lattice and grid centres. With hexagons Queen and Rook are identical. Queen/Rook change physical neighbourhood scale with cell size; a fixed distance keeps the physical threshold constant. Isolated cells are excluded from inference.
- Global Moran I and Geary C use permutations; Gi* uses analytical z and p values. Optional local Moran I uses conditional permutations and 95% classes. BH-FDR applies within each scenario. Low permutation counts limit local p-value resolution.
Interpretation
The grid layer includes all scenarios; enable one scenario at a time in the layer legend. The first is visible initially. The HTML report includes charts, baseline maps and tables; CSV files give summary statistics and 95% Gi* hot/cold areas and counts. Gi* classes range from −3 to +3; optional LISA classes identify HH/LL/HL/LH.
Jaccard = intersection area / union area. Separate hot and cold Jaccard, combined signed significant Jaccard and opposite-sign intersection in km² are reported. Comparisons are restricted to the common valid Gi* area; empty unions are undefined. Overlap always uses Gi*, including when LISA map styling is selected.
Limits: exploratory sensitivity analysis, not a formal test of differences across scales. FDR is not across all scenarios. Maximum 30,000 candidate cells per grid and 100,000 output cells overall. HTML maps are omitted above 3,500 cells, but all grid cells are in the GIS layer. Constant or very small samples have no inference.
Try it
Load the synthetic traffic accident points, create a study polygon using QGIS bounding geometry or your own boundary, then run 250, 500 and 1000 m grids with Queen weights.
Spatial Statistics Studio – integrated analysis workspace
Click the main toolbar icon to open the dockable Studio. The adjacent arrow opens the familiar tools menu. Studio complements the QGIS map and native Processing dialogs.
- The tools follow the methodological path from descriptive and exploratory methods towards inferential and explanatory models. Point pattern analysis, clustering, spatial autocorrelation, multiscale analysis and finally regression, there from exploratory OLS through GLR, spatial autoregression, GWR and MGWR to Random Forest.
- The ⚙ button next to the search box customises the panel. Set the text size, switch to short tool names, hide the help pane or the title bar, and turn groups off. Use the ⚙ menu to choose a colour theme (petrol, midnight blue, graphite and amber, burgundy, forest green, violet, light, the QGIS theme colours or your own title bar and accent colour) and an icon style (colourful with one colour per group, theme colour, monochrome or no icons). Every option reads well on the dark QGIS theme. Right-click a tool to move it up or down, hide it or mark it as a favourite. Studio remembers collapsed groups, the pane split and the group filter. The same menu restores the default order or every setting. Search also finds hidden tools.
- The Recent tab lists the 15 tools you opened most recently, with the time and the number of times. Double-click to open one again. The list can be cleared.
- On the Tools tab, search by method name or ID, filter by group, and mark favourites. The selected tool shows its help. A compatible active vector layer is preselected.
- Run the method in the native QGIS dialog. When it closes, the returned outputs, report summary and settings appear on Runs & results. If the same dialog runs several times, only its last returned result is recorded. Runs started directly from the Processing Toolbox or scripts are not automatically collected.
- Double-click an output to open it or activate and zoom to its project layer. Interactive HTML reports open in your browser. History is saved with the QGIS project (up to 200 records).
- Ctrl/Shift-select 2–8 runs to compare. Identical report labels are aligned across runs; export as CSV. Matching labels do not establish statistical comparability. Check the sample, dependent variable, model family, CRS and scale.
- Archive files copies available HTML, CSV and JSON outputs and run metadata to a separate folder. Save map layers separately (e.g. to GeoPackage). Temporary outputs may disappear when QGIS closes. Removing a record does not delete files or layers.
- Run again opens the same tool; previous parameter values are not restored automatically.
Large datasets
The input dialogs show only the settings most analyses need. Everything else (analysis CRS, row standardisation, number of permutations, random seed, kernel shape, distance type and so on) is in the collapsed Advanced parameters group with sensible defaults.
Before a long run the tool writes a warning to the log with a rough upper estimate of the computing time. The progress bar always moves and Cancel stops every tool within a moment. Typical times on a laptop:
| Method | Grows with | Comfortable up to |
|---|---|---|
| GWR / GWPR with automatic bandwidth | about n² | 5 000 observations (a manual bandwidth is about seven times faster) |
| MGWR | n², memory too | 1 000 observations, hard limit about 1 800 |
| HDBSCAN, OPTICS | n² | 50 000 points |
| Spatial autoregression, Moran, Geary, LISA, Gi* | about n | 100 000 features |
| Ripley K / L | n² per simulation | hard limit 2 500 points |
For a quick first look use a random sample or a coarser aggregation, then run the final analysis on the full data.
Self-test
Diagnostics → Self-test runs every tool on the bundled sample data and compares the results with stored reference values. Run it after installing or updating QGIS, its Python libraries or the plugin. It takes a few seconds.
- The reference values were produced by this version and checked against statsmodels, mgwr, PySAL (spreg, esda, pointpats), scikit-learn and hdbscan.
- Deterministic outputs (coefficients, local statistics, cluster labels, densities) are compared to a relative tolerance of 10⁻⁶. Outputs that depend on random permutations or on optional libraries are only run, because their random streams may change between library versions.
- The HTML report lists the plugin, QGIS, Python, NumPy, SciPy, scikit-learn and XGBoost versions. If a row says Test failed, send the report to the maintainer.
- From the Python console the same test runs with
from spatial_statistics_studio.selftest import run; run().
Methodological limits
- The plugin uses NumPy and SciPy. Regression results may differ from ArcGIS Pro and other tools because of bandwidth definition, optimisation or standard error computation. The clustering results match scikit-learn.
- MGWR works with dense matrices. Memory grows with the square of the number of observations and with the number of model terms. Local standard errors are conditional on the selected bandwidths.
- Spatial autoregression fits a Gaussian model by maximum likelihood. The spatial parameters are limited to between −0.99 and 0.99, and standard errors are computed with the estimated spatial parameters fixed.
- The plugin predicts onto vector layers. Raster values can be attached beforehand with the QGIS sampling tools. The saved GLR model uses the plugin's own JSON format.
References
- Ankerst, M., Breunig, M. M., Kriegel, H.-P., Sander, J. (1999). OPTICS. Ordering points to identify the clustering structure. ACM SIGMOD Record 28(2), 49–60.
- Campello, R. J. G. B., Moulavi, D., Sander, J. (2013). Density-based clustering based on hierarchical density estimates. PAKDD 2013, 160–172.
- Campello, R. J. G. B., Moulavi, D., Zimek, A., Sander, J. (2015). Hierarchical density estimates for data clustering, visualization, and outlier detection. ACM Transactions on Knowledge Discovery from Data 10(1), 5.
- McInnes, L., Healy, J., Astels, S. (2017). hdbscan. Hierarchical density based clustering. Journal of Open Source Software 2(11), 205.
- Fotheringham, A. S., Yang, W., Kang, W. (2017). Multiscale geographically weighted regression (MGWR). Annals of the American Association of Geographers 107(6), 1247–1265.
QGIS install from ZIP · hdbscan documentation · scikit-learn clustering · PySAL MGWR documentation