Label | Explanation | Data Type |
Input Features
| The input features containing the field that will be spatially filtered. | Feature Layer |
Input Field
| The input field that will be spatially filtered. | Field |
Output Features
| The output features containing a field of the spatially filtered input field and fields of the spatial components used to filter it. | Feature Class |
Append All Fields From Input Features
(Optional) | Specifies whether all fields will be copied from the input features to the output feature class.
| Boolean |
Input Spatial Weights Matrix File
(Optional) | The input SWM file (.swm). If a value is provided, the file will be used to define neighbors and weights of the input features. If no value is provided, the tool will test 28 different neighborhoods and use the one that most effectively filters spatial autocorrelation from the input field. | File |
Output Spatial Weights Matrix File
(Optional) | The output SWM file (.swm) of the neighbors and weights selected by the tool. This parameter does not apply if you provide an input .swm file. | File |
Unique ID Field (Optional) | The unique ID field of the output .swm file. The field must be an integer and must have a unique value for each input feature. | Field |
Summary
Creates a spatially filtered version of an input field. The filtered variable will have no statistically significant spatial clustering but will maintain the core statistical properties of the field. The spatially filtered version of the field can then be used in analytical workflows (such as correlation or regression analysis) that assume the values at each location are spatially independent (not spatially clustered).
The tool filters spatial autocorrelation by splitting the field in a nonspatial component (the filtered field) and a set of spatial components (called Moran eigenvectors). When the input field is a field of residuals or standardized residuals from a prediction or regression model, including the spatial components as explanatory variables in the model (in addition to the original explanatory variables) will reduce or eliminate spatial autocorrelation of the residual term, which is an assumption of various prediction models.
Illustration
Usage
The output feature class will contain a field of the spatially filtered input variable along with fields of the spatial components used to filter it. When run in an active map, the output feature layer will draw based on the spatially filtered input field.
The geoprocessing messages include the following two tables that summarize the selection of spatial components used to spatially filter the input field:
- Neighborhood Search History—For each of the 28 spatial weight matrices (SWMs) that were tested, details of the SWM (such as the number of neighbors and weighting scheme), the Moran's I p-value for the original input variable, the Moran's I value and p-value of the spatially filtered input variable, and the number of components that were required to remove the spatial autocorrelation are displayed. The SWM that was selected to filter the input field is indicated by bold text and an asterisk.
- Spatial Component Search History—For the selected SWM, the ID value of each component (for example, ID 4 means that it was the fourth spatial component), the Moran's I value of the component, and the Moran's I value and p-value of the spatially filtered input variable are displayed. The rows are ordered in the order of the selected components, so the p-value will increase at each row until it exceeds 0.05 (not statistically significant).
The tool selects a SWM for the input features (unless one is provided in the Input Spatial Weights Matrix File parameter) and selects components that most effectively remove spatial autocorrelation from the input field using the following procedure:
- For each SWM, the input field is tested for statistically significant spatial autocorrelation using a permutation test of Moran's I. If the spatial autocorrelation is not statistically significant (the p-value is greater than 0.05) for all SWMs, the tool will fail and the input field will not be spatially filtered. This indicates that the field is spatially uncorrelated and does not need to be filtered. The p-values of the tests are adjusted using a Šidák correction to account for the number of SWMs tested.
- For each SWM with statistically significant autocorrelation, spatial components are sequentially added and used as explanatory variables to predict the input field. For each new spatial component, the spatial autocorrelation of the residual term is tested for statistical significance, and each SWM stops adding components when the autocorrelation of the residuals are no longer statistically significant (the p-value is greater than 0.05). Each new component is selected based on the largest increase in the p-value of the autocorrelation of the residual term (indicating the lowest spatial autocorrelation).
- The SWM that required the fewest number of components to produce residuals that are not significantly autocorrelated is selected. If there are ties in the fewest number of components, the one with the largest p-value is selected.
- The selected components and residuals are returned as fields of the output feature class. The residuals are the spatially filtered version of the input field.
This procedure is called the MIR (Minimizing autocorrelation In the Residuals) selection method and is fully described in the following reference:
Griffith, Daniel A., and Pedro R. Peres-Neto. 2006. "Spatial modeling in ecology: the flexibility of eigenfunction spatial analyses." Ecology 87, no. 10: 2603-2613. https://doi.org/10.1890/0012-9658(2006)87[2603:SMIETF]2.0.CO;2.
Parameters
arcpy.stats.FilterSpatialAutocorrelationFromField(in_features, input_field, out_features, {append_all_fields}, {in_swm}, {out_swm}, {id_field})
Name | Explanation | Data Type |
in_features | The input features containing the field that will be spatially filtered. | Feature Layer |
input_field | The input field that will be spatially filtered. | Field |
out_features | The output features containing a field of the spatially filtered input field and fields of the spatial components used to filter it. | Feature Class |
append_all_fields (Optional) | Specifies whether all fields will be copied from the input features to the output feature class.
| Boolean |
in_swm (Optional) | The input SWM file (.swm). If a value is provided, the file will be used to define neighbors and weights of the input features. If no value is provided, the tool will test 28 different neighborhoods and use the one that most effectively filters spatial autocorrelation from the input field. | File |
out_swm (Optional) | The output SWM file (.swm) of the neighbors and weights selected by the tool. This parameter does not apply if you provide an input .swm file. | File |
id_field (Optional) | The unique ID field of the output .swm file. The field must be an integer and must have a unique value for each input feature. | Field |
Code sample
The following Python window script demonstrates how to use the FilterSpatialAutocorrelationFromField function:
# Filter spatial autocorrelation from a field.
arcpy.env.workspace = r"c:\data\project_data.gdb"
arcpy.stats.FilterSpatialAutocorrelationFromField(
in_features="myFeatureClass",
input_field="myAnalysisField",
out_features=r"myOutputFeatureClass",
append_all_fields="ALL",
in_swm=None,
out_swm=None,
id_field=None
)
The following stand-alone script demonstrates how to use the FilterSpatialAutocorrelationFromField function:
# Run Generalized Linear Regression, then filter spatial autocorrelation from residuals.
import arcpy
# Set the current workspace
arcpy.env.workspace = r"c:\data\project_data.gdb"
# Run the regression tool.
arcpy.stats.GeneralizedLinearRegression(
in_features=r"myFeatureClass",
dependent_variable="myDependentField",
model_type="CONTINUOUS",
output_features=r"myOutputFeatureClass",
explanatory_variables="myExplanatoryField1;myExplanatoryField2",
distance_features=None,
prediction_locations=None,
explanatory_variables_to_match=None,
explanatory_distance_matching=None,
output_predicted_features=None,
output_trained_model=None
)
arcpy.stats.FilterSpatialAutocorrelationFromField(
in_features="myOutputFeatureClass",
input_field="RESIDUAL",
out_features=r"myFilteredOutputFeatureClass",
append_all_fields="ALL",
in_swm=None,
out_swm=None,
id_field=None
)
# Print the messages.
print(arcpy.GetMessages())
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes