Find Centroids

Find Centroids workflow diagram

The Find Centroids task finds and generates points from the representative center (centroid) of each input multipoint, line, or area feature. Finding the centroid of a feature is common for many analytical workflows in which the resulting points can then be used in other analytic workflows.

For example, polygon features that contain demographic data can be converted to centroids that can be used in network analysis.

Request URL

Use dark colors for code blocksCopy
1
http://<analysis url>/FindCentroids/submitJob

Request parameters

ParameterDescription

inputLayer (Required)

The multipoint, line, or polygon features that will be used to generate centroid point features.

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

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

Examples:

  • {"url": <feature service layer url>, "filter": <where clause>}
  • {"layerDefinition": {}, "featureSet": {}, "filter": <where clause>}

pointLocation

A Boolean value that determines the output location of the points.

Values: true | false

  • true—Output points will be the nearest point to the actual centroid, but located inside or contained by the bounds of the input feature.
  • false—Output point locations will be determined by the calculated geometric center of each input feature. This is the default.

Example:"pointLocation" : "false"

outputName

If provided, the task will create a feature service of the results. You define the name of the service. If an outputName value is not provided, the task will return a feature collection.

Syntax:

Use dark colors for code blocksCopy
1
2
3
4
5
{
  "serviceProperties": {
    "name": "<service name>"
  }
}

In ArcGIS Online or ArcGIS Enterprise 10.9.1 and later, you can overwrite an existing feature service by providing the itemId value of the existing feature service and setting the overwrite property to true. Including the serviceProperties parameter is optional. As described in the Feature output topic, you must either be the owner of the feature service or have administrative privileges to perform the overwrite.

Syntax:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
{

  "itemProperties": {
			"itemId": "<itemID of the existing feature service>",
			"overwrite": true
	}
}

or

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
"serviceProperties": {
    "name": "<existing service name>"
  },
"itemProperties": {
				"itemId": "<itemID of the existing feature service>",
				"overwrite": true
	}
}

context

The Context parameter contains the following additional settings that affect task operation:

  • Extent (extent)—A bounding box that defines the analysis area. Only input features that intersect the bounding box will be analyzed.
  • Output spatial reference (outSR)—The output features will be projected into the output spatial reference.

Syntax:

Use dark colors for code blocksCopy
1
2
3
4
{
"extent" : {extent},
"outSR" : {spatial reference}
}

f

The response format. The default response format is html.

Values: html | json

Response

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

Use dark colors for code blocksCopy
1
2
3
4
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

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

Use dark colors for code blocksCopy
1
http://<analysis url>/FindCentroids/jobs/<jobId>

Results access

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:

Use dark colors for code blocksCopy
1
http://<analysis url>/FindCentroids/jobs/<jobId>/results/outputLayer?token=<your token>&f=json
ParameterDescription

outputLayer

The centroid points. Example:

Use dark colors for code blocksCopy
1
{"url":"http://<analysis url>/FindCentroids/jobs/<jobId>/results/outputLayer"}

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.

  • If outputName was provided, value contains the URL to the feature service layer.
Use dark colors for code blocksCopy
1
2
3
4
5
{
"paramName":"outputLayer",
"dataType":"GPString",
"value":{"url":"<hosted featureservice layer url>"}
}
  • If outputName was not provided, value contains a feature collection.
Use dark colors for code blocksCopy
1
2
3
4
5
{
"paramName":"outputLayer",
"dataType":"GPString",
"value":{"layerDefinition": {}, "featureSet": {}  }
}

See Feature Output for more information about how the result layer or collection is accessed.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.