Find centroids

A find centroids analysis resulting in a new layer that contains center points within USA state boundaries.

What is a find centroid analysis?

A find centroid analysis is the process of finding the representative centers of each multipoint, polyline, or polygon feature. To execute the analysis, use the spatial analysis service and the FindCentroids operation.

find centroids

Real-world examples of this analysis include the following:

  • Preparing home or spending values for analyses that require point data.
  • Finding the representative centers of parcels.
  • Finding the representative centers for open spaces.

How to find centroids

The general steps to find centroids are as follows:

  1. Review the parameters for the FindCentroids operation.
  2. Send a request to get the spatial analysis service URL.
  3. Execute a job request with the following URL and parameters:
    • URL: https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/FindCentroids/submitJob
    • Parameters:
      • inputLayer: Your points dataset as a hosted feature layer or feature collection.
      • pointLocation: Whether the output point locations are calculated by the geometric center of each input feature.
      • outputName: A string representing the name of the hosted feature layer to reutrn with the results.
  4. Check the status.
  5. Get the output layer results.

To see examples using ArcGIS API for Python, ArcGIS REST JS, and the ArcGIS REST API, go to Examples below.

URL request

Use dark colors for code blocksCopy
 
1
http://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/FindCentroids/submitJob?<parameters>

Required parameters

NameDescriptionExamples
fThe format of the data returned.f=json f=pjson
tokenAn OAuth 2.0 access token. Learn how to get an access token in Security and authentication.token=<ACCESS_TOKEN>
inputLayerThe multipoint, line, or polygon features that will be used to generate centroid point features.{"url":"https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Average_PDX_home_values/FeatureServer/0","name":"Average_PDX_home_values"}

Key parameters

NameDescriptionExamples
pointLocationOutput points are determined by the calculated geometric center of each input feature. If set to true the points will be contained by the bounds of the input feature.false (default)
outputNameA string representing the name of the hosted feature layer to return with the results. NOTE: If you do not include this parameter, the results are returned as a feature collection (JSON).{"serviceProperties": {"name": "<SERVICE_NAME>"}}
contextA bounding box or output spatial reference for the analysis."extent":{"xmin:", "ymin:", "xmax:", "ymax:"}

Examples

Find centroids within square bins

This example uses the FindCentroids operation to generate points within square bins. The inputLayer value is the Generate tessellations in Portland hosted feature layer. The feature layer was created using the GenerateTessellations operation. To learn how to generate square bins, go to generate tessellations.

Find centroid analysis showing centroids generated within square bins.

APIs

ArcGIS REST JSArcGIS REST JSArcGIS API for Python
Expand
Use dark colors for code blocksCopy
                                                                   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  const operationUrl = `${analysisUrl}/FindCentroids/submitJob`;

  const params = {

    inputLayer: {
      url:
        "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Generate_tessellations_on_Portland_boundary/FeatureServer/0"
    },
    pointLocation: false,
    // Outputs results as a hosted feature layer.
    outputName: {
      serviceProperties: { name: "Find centroids results" },
    },

  const jobReq = await Job.submitJob({
    url: operationUrl,
    params: params,
    authentication: auth,
  });

  // listen to the status event to get updates every time the job status is checked.
  jobReq.on(JOB_STATUSES.Status, jobInfo => {
    console.log(jobInfo.status)
  });

  // get all the results, this will start monitoring and trigger events
  const jobResp = await jobReq.getAllResults();

  console.log(jobResp);

Service requests

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
     
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded

&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
{
  "helperServices": {
    // Other parameters
    "analysis": {
      "url": "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
    },
    "geoenrichment": {
      "url": "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
    }
  }
}

Find centroids for census blocks

This example uses the FindCentroids operation to generate points that represent census blocks. The inputLayer value is the Census blocks in SF hosted feature layer.

Find centroid analysis showing centroids generated from census blocks.

APIs

ArcGIS REST JSArcGIS REST JSArcGIS API for Python
Expand
Use dark colors for code blocksCopy
                                                                   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  const operationUrl = `${analysisUrl}/FindCentroids/submitJob`;

  const params = {

    inputLayer: {
      url:
        "https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/Intersect_of_U_S__Census_Blocks_and_SF_Neighborhoods/FeatureServer/0",
    },
    pointLocation: false,
    // Outputs results as a hosted feature layer.
    outputName: {
      serviceProperties: { name: "Find centroids results" },
    }
  };

  const jobReq = await Job.submitJob({
    url: operationUrl,
    params: params,
    authentication: auth,
  });

  // listen to the status event to get updates every time the job status is checked.
  jobReq.on(JOB_STATUSES.Status, jobInfo => {
    console.log(jobInfo.status)
  });

  // get all the results, this will start monitoring and trigger events
  const jobResp = await jobReq.getAllResults();

  console.log(jobResp);

Service requests

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
     
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded

&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
{
  "helperServices": {
    // Other parameters
    "analysis": {
      "url": "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
    },
    "geoenrichment": {
      "url": "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
    }
  }
}

Tutorials

Learn how to perform related analyses interactively with Map Viewer and programmatically with ArcGIS API for Python, ArcGIS REST JS, and ArcGIS REST API.

Services

Spatial analysis service

Process spatial datasets to discover relationships and patterns.

API support

Full supportPartial supportNo support
  • 1. Access with geoprocessing task
  • 2. Access via ArcGIS REST JS

Tools

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