Find existing locations

A find location analysis resulting in a new layer with parks 150 meters from a bike route.

What is a find existing locations analysis?

A find existing location analysis is the process of selecting and copying features that satisfy one or more SQL and/or spatial expressions. To execute the analysis, use the spatial analysis service and the FindExistingLocations operation.

find existing locations

Real-world examples of this analysis include the following:

  • Finding neighborhoods within a specified distance from schools or police stations.
  • Selecting specific points of interest within a larger dataset.
  • Finding road access that cannot be on or within view of a protected area.

How to perform a find location analysis

The general steps to performing a find existing locations analysis are as follows:

  1. Review the parameters for the FindExistingLocations operation.
  2. Determine if you would like the results as a feature collection (dynamic) or hosted feature layer (stored).
  3. Send a request to get the spatial analysis service URL.
  4. Execute a job request with the following URL and parameters:
    • URL: https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer/FindExistingLocations/submitJob
    • Parameters:
      • expressions: The SQL or spatial relation to select a subset of the data.
      • inputLayers: The feature collection(s) or hosted feature layer(s) from which you want to extract features.
      • outputName: A string representing the name of the hosted feature layer to return with the results.
  5. Check the status.
  6. 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/FindExistingLocations/submitJob?<parameters>

Required parameters

NameDescriptionExamples
fThe format of the data returned.f=json f=pjson
token

An access token (API key or OAuth 2.0) with the required Spatial Analysis > Feature analysis privilege.

token=<ACCESS_TOKEN>
inputLayersThe point, polyline, or polygon feature data that will be used to construct the query.[{"url":"https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/OpenStreetMap - Points of interest/FeatureServer/0","name":"OpenStreetMap - Points of interest (bèta) - Punten"}]
expressionsThe SQL or spatial query.[{"operator":"","layer":0,"where":"service = 'Eten en Drinken'"}]

Key parameters

NameDescriptionExamples
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:"}

Code examples

Find neighborhoods (spatial query)

This example uses the FindExistingLocations operation to construct a spatial query that selects and returns all the neighborhoods within a half mile of a police station.

For the analysis, the inputLayers value is the Police stations and San Francisco Neighborhoods hosted feature layers. The expression value is: SF Neighborhoods within a distance of 0.5 Miles from Police Stations.

Find existing locations using a spatial query to return neighborhoods within 0.5 miles of police stations.

APIs

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
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

police_stations = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Police_Stations/FeatureServer/0"

neighborhoods = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/SF_Neighborhoods/FeatureServer/0"

results = find_existing_locations(
    input_layers=[neighborhoods, police_stations],
    expressions=[
        {
            "operator": "",
            "layer": 0,
            "selectingLayer": 1,
            "spatialRel": "withinDistance",
            "distance": 0.5,
            "units": "Miles",
        }
    ],
    #Outputs results as a hosted service.
    output_name="Find locations results"
)


result_features = results.layers[0].query()

print(
    f"Find existing features returned {len(result_features.features)} new records"
)

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 hotels (SQL query)

This example uses the FindExistingLocations operation to construct a SQL query that selects and returns the restaurants within the OpenStreetMap-Points of interest (bèta) hosted layer.

For the analysis, the inputLayers value is the OpenStreetMap-Points of interest (bèta) hosted layer. The expression value is: "where":"service = 'Hotels en Pensions'".

Find existing locations using a SQL query to return hotels in Amsterdam.

APIs

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
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


osm_points_of_interest = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/OpenStreetMap - Points of interest/FeatureServer/0"

results = find_existing_locations(
    input_layers=[osm_points_of_interest],
    expressions=[
        {"operator": "", "layer": 0, "where": "POI-laag = 'Hotels en Pensions'"}
    ],
   #Outputs results as a hosted feature layer.
    output_name="Find locations results",
    context={
        "extent": {
            "xmin": 568547.4926900844,
            "ymin": 6816058.336549545,
            "xmax": 570749.8345676091,
            "ymax": 6817610.963686628,
            "spatialReference": {"wkid": 102100, "latestWkid": 3857},
        }
    },
)

result_features = results.layers[0].query()

print(
    f"Find existing features returned {len(result_features.features)} new records"
)

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"
    }
  }
}

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