Skip To Content ArcGIS for Developers Sign In Dashboard

Geographically Weighted Regression

Description

Geographically Weighted Regression

This tool performs GeographicallyWeightedRegression (GWR), which is a local form of linear regression used to model spatially varying relationships.

The following are examples of the types of questions you can answer using this tool:

  • Is the relationship between educational attainment and income consistent across the study area?
  • What are the key variables that explain high forest fire frequency?
  • Where are the districts in which children are achieving high test scores? What characteristics seem to be associated? Where is each characteristic most important?

Request parameters

ParameterDetails
inputLayer

(Required)

The layer containing the dependent and independent variables.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST examples

//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

//REST scripting example
"inputLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter":"Month = 'September'"}
exlpanatoryVariableses

(Required)

One or more fields representing independent explanatory variables in your regression model.

REST examples

//REST web example
Rate

//REST scripting example
"explanatoryVariables": "Rating,Nights"
dependentVariable

(Required)

The numeric field containing the observed values you want to model.

REST examples

//REST web example
Earnings

//REST scripting examples
"dependentVariable": "Arrest"
modelType

(Required)

Specifies the type of data that will be modeled.

REST examples

//REST web example
Continuous

//REST scripting example
"modelType": "Continuous"
neighborhoodSelectionMethod

(Required)

Specifies how the neighborhood size will be determined.

  • UserDefined—The neighborhood size will be specified by either the numberOfNeighbors or distanceBand parameter.

REST examples

//REST web example
UserDefined

//REST scripting example
"neighborhoodSelectionMethod": "UserDefined"
neighborhoodType

(Required)

Specifies whether the neighborhood used is constructed as a fixed distance or allowed to vary in spatial extent depending on the density of the features.

  • DistanceBand—The neighborhood size is a constant or fixed distance for each feature.
  • NumberOfNeighbors—The neighborhood size is a function of a specified number of neighbors included in calculations for each feature. Where features are dense, the spatial extent of the neighborhood is smaller; where features are sparse, the spatial extent of the neighborhood is larger.

REST examples

//REST web example
DistanceBand

//REST scripting example
"neighborhoodType": "NumberOfNeighbors"
distanceBand

(Required if neighborhoodType is DistanceBand)

The distance for the spatial extent of the neighborhood.

REST examples

//REST web example
10

//REST scripting example
"distanceBand": 22.5
distanceBandUnit

(Required if distanceBand is used)

The unit of the distance for the spatial extent of the neighborhood.

Values: Meters | Kilometers | Feet | Miles | NauticalMiles | Yards

REST examples

//REST web example
Meters

//REST scripting example
"distanceBandUnit": "Miles"
numberOfNeighbors

(Required if neighborhoodType is NumberOfNeighbors)

The closest number of neighbors (up to 1000) to consider for each feature. The number should be an integer between 2 and 1000.

REST examples

//REST web example
500

//REST scripting example
"numberOfNeighbors": 350
localWeightingScheme

(Optional)

Specifies the kernel type that will be used to provide the spatial weighting in the model. The kernel defines how each feature is related to other features within its neighborhood.

  • BiSquare—A weight of 0 will be assigned to any feature outside the neighborhood specified. This is the default.
  • Gaussian—All features will receive weights, but weights become exponentially smaller the farther away they are from the target feature.

REST examples

//REST web example
BiSquare

//REST scripting example
"localWeightingScheme": Gaussian
outputTrainedName

The task will create a feature service of the results. You define the name of the service.

REST examples

//REST web example
myOutput

//REST scripting example
"outputTrainedName": "myOutput"
context

(Optional)

The context parameter contains additional settings that affect task execution. For this task, there are four settings:

  • Extent (extent)—A bounding box that defines the analysis area. Only those features that intersect the bounding box will be analyzed.
  • Processing spatial reference (processSR)—The features will be projected into this coordinate system for analysis.
  • Output spatial reference (outSR)—The features will be projected into this coordinate system after the analysis to be saved. The output spatial reference for the spatiotemporal big data store is always WGS84.
  • Data store (dataStore)—Results will be saved to the specified data store. The default is the spatiotemporal big data store.

Syntax:
{
"extent" : {extent},
"processSR" : {spatial reference},
"outSR" : {spatial reference},
"dataStore":{data store}
}

f

The response format. The default response format is html.

Values: html | json

Example usage

Below is a sample request URL for GoegrapchicallyWeightedRegression:

https://webadaptor.domain.com/server/rest/services/System/GeoAnalyticsTools/GPServer/GeogrpahicallyWeightedRegression/submitJob?inputLayer={"url":"https://webadaptor.domain.com/server/rest/services/Hurricane/hurricaneTrack2017/0"}&dependentVariable=ShelterCapacity&explanatoryVariables=CityDensity, ShelterLocations&modelType=Continuous&neighborhoodType=NumberOfNeighbors&numberOfNeighbors=100&outputTrainedName=myoutput&context={"extent":{"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6,"spatialReference":{"wkid":4326}}}&f=json

Response

When you submit a request, the service assigns a unique job ID for the transaction.

Syntax:
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

After the initial request is submitted, you can use jobId to periodically check the status of the job and messages as described in Checking job status. Once the job has successfully completed, use jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<analysis url>/GeograhpicallyWeightedRegression/jobs/<jobId>

Access results

When the status of the job request is esriJobSucceeded, you can access the results of the analysis by making a request of the following form:

https://<analysis-url>/GeographicallyWeightedRegression/jobs/<jobId>/results/<response type>?token=<your token>&f=json

ResponseDescription
output

The input features that are fit to the model. The type of feature (table, point, line, or polygon) depends on the input layers.

{"url": "https://<analysis-url>/GeographicallyWeightedRegression/jobs/<jobId>/results/output"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputName parameter provided in the initial request. The value contains the URL of the feature service layer.

{
"paramName":"output", 
"dataType":"GPRecordSet",
"value":{"url":"<hosted featureservice layer url>"}
}

See Feature output for more information about how the result layer is accessed.

processInfo

The processInfo parameter contains strings that summarize the Forest-based Classification and Regression result. These strings are used for reporting by the Generalized Linear Regression in the map viewer. You can create your own custom reports for your application using these strings. There are four parts in the returned JSON as follows:

  • messageCode—The serial number for each unique message.
  • message—Text that may or may not contain parameters (in ${paramsName} format) that need to be replaced by values.
  • params—A dictionary of the keys and values to be inserted into the ${paramsName} parameter in the message.
  • style—The formatting of the report produced by the Generalized Linear Regression tool in the map viewer.
{
  "messageCode" : "SS_84507",
  "message" : ["Attribute", "Min", "Max", "SD", "Mean","Input"],
  "params" : {},
  "style" : "<table><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr>"
}