Geographically Weighted Regression (GWR) (Spatial Statistics)

License Level:BasicStandardAdvanced


Performs Geographically Weighted Regression (GWR), a local form of linear regression used to model spatially varying relationships.

Learn more about how Geographically Weighted Regression works


Geographically Weighted Regression
GWR is a local regression model. Coefficients are allowed to vary.



GeographicallyWeightedRegression_stats (in_features, dependent_field, explanatory_field, out_featureclass, kernel_type, bandwidth_method, {distance}, {number_of_neighbors}, {weight_field}, {coefficient_raster_workspace}, {cell_size}, {in_prediction_locations}, {prediction_explanatory_field}, {out_prediction_featureclass})
ParameterExplanationData Type

The feature class containing the dependent and independent variables.

Feature Layer

The numeric field containing values for what you are trying to model.


A list of fields representing independent explanatory variables in your regression model.


The output feature class to receive dependent variable estimates and residuals.

Feature Class

Specifies if the kernel is constructed as a fixed distance, or if it is allowed to vary in extent as a function of feature density.

  • FIXEDThe spatial context (the Gaussian kernel) used to solve each local regression analysis is a fixed distance.
  • ADAPTIVEThe spatial context (the Gaussian kernel) is a function of a specified number of neighbors. Where feature distribution is dense, the spatial context is smaller; where feature distribution is sparse, the spatial context is larger.

Specifies how the extent of the kernel should be determined. When AICc or CV are selected, the tool will find the optimal distance/neighbor parameter for you. Typically you will select either AICc or CV if you don't know what to use for the distance (kernel_type = FIXED) or the number_of_neighbors (kernel_type = ADAPTIVE) parameters. If you select BANDWIDTH_PARAMETER you will need to specify a value for the distance or number_of_neighbors parameters.

  • AICcThe extent of the kernel is determined using the Akaike Information Criterion (AICc).
  • CVThe extent of the kernel is determined using Cross Validation.
  • BANDWIDTH_PARAMETERThe extent of the kernel is determined by a fixed distance or a fixed number of neighbors.

Specifies a fixed bandwidth extent or distance whenever the kernel type is FIXED and the bandwidth method is BANDWIDTH_PARAMETER.


An integer reflecting the exact number of neighbors to include in the local bandwidth of the Gaussian kernel whenever the kernel type is ADAPTIVE and the bandwidth method is BANDWIDTH_PARAMETER.


The numeric field containing a spatial weighting for individual features. This weight field allows some features to be more important in the model calibration process than others. Primarily useful when the number of samples taken at different locations varies, values for the dependent and independent variables are averaged, and places with more samples are more reliable (should be weighted higher). If you have an average of 25 different samples for one location, but an average of only 2 samples for another location, you can use the number of samples as your weight field so that locations with more samples have a larger influence on model calibration than locations with few samples.


A full pathname to the workspace where all of the coefficient rasters will be created. When this workspace is provided, rasters are created for the intercept and every explanatory variable.


The cell size (a number) or reference to the cell size (a pathname to a raster dataset) to use when creating the coefficient rasters.

The default cell size is the shortest of the width or height of the extent specified in the geoprocessing environment output coordinate system, divided by 250.

Analysis Cell Size

A feature class containing features representing locations where estimates should be computed. Each feature in this dataset should contain values for all of the explanatory variables specified; the dependent variable for these features will be estimated using the model calibrated for the input feature class data.

Feature Layer

A list of fields representing explanatory variables in the Prediction locations feature class. These field names should be provided in the same order (a one-to-one correspondance) as those listed for the input feature class Explanatory variables parameter. If no prediction explanatory variables are given, the output prediction feature class will only contain computed coefficient values for each prediction location.


The output feature class to receive dependent variable estimates for each feature in the Prediction locations feature class.

Feature Class

Code Sample

GeographicallyWeightedRegression Example (Python Window)

The following Python Window script demonstrates how to use the GeographicallyWeightedRegression tool.

import arcpy
arcpy.env.workspace = "c:/data"
arcpy.GeographicallyWeightedRegression_stats("CallData.shp", "Calls","BUS_COUNT;RENTROCC00;NoHSDip",
                                             "CallsGWR.shp", "ADAPTIVE", "BANDWIDTH PARAMETER",
                                             "#", "25", "#","CoefRasters", "135", "PredictionPoints", 
                                             "#", "GWRCallPredictions.shp")
GeographicallyWeightedRegression Example (stand-alone Python script)

The following stand-alone Python script demonstrates how to use the GeographicallyWeightedRegression tool.

# Model 911 emergency calls using GWR

# Import system modules
import arcpy

# Set the geoprocessor object property to overwrite existing outputs = True

# Local variables...
workspace = r"C:\Data"

    # Set the current workspace (to avoid having to specify the full path to the feature classes each time)
    arcpy.env.workspace = workspace

    # 911 Calls as a function of {number of businesses, number of rental units,
    # number of adults who didn't finish high school}
    # Process: Geographically Weighted Regression... 
    gwr = arcpy.GeographicallyWeightedRegression_stats("CallData.shp", "Calls", 
                        "CallsGWR.shp", "ADAPTIVE", "BANDWIDTH PARAMETER","#", "25", "#",
                        "CoefRasters", "135", "PredictionPoints", "#", "GWRCallPredictions.shp")

    # Create Spatial Weights Matrix to use with Global Moran's I tool
    # Process: Generate Spatial Weights Matrix... 
    swm = arcpy.GenerateSpatialWeightsMatrix_stats("CallsGWR.shp", "UniqID",
                        "#", "#", "#", 25) 
    # Calculate Moran's Index of Spatial Autocorrelation for 
    # OLS Residuals using a SWM File.  
    # Process: Spatial Autocorrelation (Morans I)...      
    moransI = arcpy.SpatialAutocorrelation_stats("CallsGWR.shp", "StdResid",
                        "NO_REPORT", "GET_SPATIAL_WEIGHTS_FROM_FILE", 
                        "EUCLIDEAN_DISTANCE", "NONE", "#", 

    # If an error occurred when running the tool, print out the error message.
    print arcpy.GetMessages()


Output Coordinate System

Feature geometry is projected to the Output Coordinate System after analysis is complete. Consequently, the value entered for the Distance parameter should be specified in the same units as the Input feature class. Values entered for the Output cell size should be specified in the same units as the Output Coordinate System.

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst or Geostatistical Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst or Geostatistical Analyst
ArcGIS for Desktop Advanced: Yes