Find Centroids

Find Centroids workflow diagram

The Find Centroids task that finds and generates points from the representative center (centroid) of each input multipoint, line, or area feature. Finding the centroid of a feature is very common for many analytical workflows where 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.

Note:

Find Centroids is only available in ArcGIS Online. This tool will be added to ArcGIS Enterprise in a future release.

Request URL

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

  • a URL to a feature service layer with an optional filter to select specific features, or
  • 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 outputName is not supplied, the task will return a feature collection.

Syntax:
{
  "serviceProperties": {
    "name": "<service name>"
  }
}

context

Context contains additional settings that affect task execution. For Find Centroids, there are two settings.

  1. Extent (extent)—a bounding box that defines the analysis area. Only those features in the inputLayer that intersect the bounding box will be buffered.
  2. Output Spatial Reference (outSR)—the output features will be projected into the output spatial reference.

Syntax:
{
"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:
{
"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 topic Checking job status. Once the job has successfully completed, you use the jobId to retrieve the results. To track the status, you can make a request of the following form:

http://<analysis url>/FindCentroids/jobs/<jobId>

Accessing results

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

http://<analysis url>/FindCentroids/jobs/<jobId>/results/centroidLayer?token=<your token>&f=json

ParameterDescription

centroidLayer

The centroid points.

Example:
{"url": 
"http://<analysis url>/FindCentroids/jobs/<jobId>/results/centroidLayer"}

The result has properties for parameter name, data type, and value. The contents of value depends upon the outputName parameter provided in the initial request.

  • If outputName was provided, value contains the url to the feature service layer.

    {
    "paramName":"centroidLayer", 
    "dataType":"GPString",
    "value":{"url":"<hosted featureservice layer url>"}
    }

  • If outputName was not provided, value contains a feature collection.

    {
    "paramName":"centroidLayer",
    "dataType":"GPString",
    "value":{"layerDefinition": {}, "featureSet": {}  }
    }

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