Skip to main content

Module spatial_stats

Module spatial_stats 

Source
Expand description

Spatial statistics module for analyzing spatial patterns and relationships

This module provides statistical measures commonly used in spatial analysis, including measures of spatial autocorrelation, clustering, and pattern analysis.

§Features

  • Spatial Autocorrelation: Moran’s I, Geary’s C
  • Local Indicators: Local Moran’s I (LISA)
  • Distance-based Statistics: Getis-Ord statistics
  • Pattern Analysis: Nearest neighbor analysis

§Examples

use scirs2_core::ndarray::array;
use scirs2_spatial::spatial_stats::{morans_i, gearys_c};

// Create spatial data (values at different locations)
let values = array![1.0, 2.0, 1.5, 3.0, 2.5];

// Define spatial weights matrix (adjacency-based)
let weights = array![
    [0.0, 1.0, 0.0, 0.0, 1.0],
    [1.0, 0.0, 1.0, 0.0, 0.0],
    [0.0, 1.0, 0.0, 1.0, 0.0],
    [0.0, 0.0, 1.0, 0.0, 1.0],
    [1.0, 0.0, 0.0, 1.0, 0.0],
];

// Calculate spatial autocorrelation
let moran = morans_i(&values.view(), &weights.view()).expect("Operation failed");
let geary = gearys_c(&values.view(), &weights.view()).expect("Operation failed");

println!("Moran's I: {:.3}", moran);
println!("Geary's C: {:.3}", geary);

Structs§

AnnResult
Result of the average nearest neighbor analysis

Functions§

average_nearest_neighbor
Calculate the average nearest neighbor distance statistic
clark_evans_index
Calculate Clark-Evans nearest neighbor index
contiguity_weights_matrix
Build a contiguity-based spatial weights matrix from polygon adjacency
distance_weights_matrix
Calculate spatial weights matrix based on distance decay
gearys_c
Calculate Geary’s C statistic for spatial autocorrelation
getis_ord_gi
Calculate Getis-Ord Gi statistic for hotspot analysis
knn_weights_matrix
Build a k-nearest neighbors spatial weights matrix
local_morans_i
Calculate Local Indicators of Spatial Association (LISA) using Local Moran’s I
morans_i
Calculate Moran’s I statistic for spatial autocorrelation
ripleys_k
Compute Ripley’s K-function for point pattern analysis
ripleys_l
Compute Ripley’s L-function (variance-stabilized K-function)