Hot Spot Analysis Worker
Processes hot spot analysis jobs using Getis-Ord Gi* statistics.
Overview
The hot spot analysis worker identifies statistically significant clusters of high and low values in spatial data using the Getis-Ord Gi* statistic.
Job Type
hotspot_analysis
Input Parameters
{
"dataset_id": 123,
"value_field": "population",
"neighbor_type": "distance",
"distance": 1000,
"output_mode": "static"
}
Parameters
dataset_id(required): Source dataset IDvalue_field(required): Numeric field to analyzeneighbor_type(optional): “distance” or “knn” (default: “distance”)distance(required if neighbor_type=”distance”): Distance threshold in dataset unitsk_neighbors(required if neighbor_type=”knn”): Number of nearest neighborsoutput_mode(optional): “static”, “view”, or “materialized_view” (default: “static”)
Output
Creates a new dataset with hot spot analysis results:
Gi Z-Score*: Standardized z-score indicating hot/cold spots
P-Value: Statistical significance
Hot Spot Class: Categorized classes (99% hot, 95% hot, 90% hot, not significant, 90% cold, 95% cold, 99% cold)
Output Modes
Static Table (default)
Results stored in a permanent table spatial_data_{output_id}. Best for:
Final results that won’t change
Maximum query performance
Historical snapshots
View
Results stored as a database view. Best for:
Results that should update when source data changes
Real-time analysis
Reduced storage requirements
Materialized View
Results stored as a materialized view. Best for:
Large datasets requiring periodic refresh
Balance between performance and freshness
Scheduled updates
Algorithm
The worker uses PostGIS functions to:
Calculate spatial weights matrix based on neighbor type
Compute Getis-Ord Gi* statistic for each feature
Calculate z-scores and p-values
Categorize results into hot spot classes
Store results in output table/view
Example
# Enqueue a hot spot analysis job via API
curl -X POST "https://example.com/api/analysis_hotspot_run.php" \
-H "Content-Type: application/json" \
-d '{
"dataset_id": 123,
"value_field": "population",
"neighbor_type": "distance",
"distance": 1000
}'
# Worker processes the job automatically
# Check status via API
curl "https://example.com/api/job_status.php?job_id=456"
Background Jobs
This analysis runs as a background job. The worker:
Fetches queued
hotspot_analysisjobsValidates input parameters
Executes PostGIS analysis queries
Creates output dataset
Marks job as completed
Performance Considerations
Processing time depends on dataset size and neighbor configuration
Distance-based analysis may be slower for large datasets
KNN-based analysis is generally faster
Consider using materialized views for very large datasets