Find Existing Locations

Find Existing Locations

The FindExistingLocations task selects features in the input layer that meet a specified query. A query is composed of one or more expressions. There are two types of expressions: attribute and spatial.

An example of an attribute expression is a parcel must be vacant, which is an attribute of the Parcels layer (where STATUS = 'VACANT').

An example of a spatial expression is the parcel must also be within a certain distance of a river (Parcels within a distance of 0.75 Miles from Rivers).

Request URL

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

Request parameters

ParameterDescription

inputLayers

(Required)

A list of layers that will be used in the expressions parameter. Only those features in the first layer will be written to the output.

Each layer in the list can be either 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>}

Example list of URLs:

Use dark colors for code blocksCopy
1
2
3
4
5
[
    {"url": "http://someservices.arcgis.com/ees4FIJk4mpkX1ID/arcgis/rest/services/LAParkSitingData/FeatureServer/0"},
    {"url": "http://someservices.arcgis.com/ees4FIJk4mpkX1ID/arcgis/rest/services/LAParkSitingData/FeatureServer/1"},
    {"url": "http://someservices.arcgis.com/ees4FIJk4mpkX1ID/arcgis/rest/services/LAParkSitingData/FeatureServer/2"}
]

expressions

(Required)

A list of expressions. There are two types of expressions: attribute and spatial.

Example attribute expression:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
[
 {
   "operator": "and",
   "layer": 0,
   "where": "STATUS = 'VACANT'"
 }
]

Notes:

  • The operator value can be either and or or.
  • The layer value is the index of the layer in the inputLayers parameter.
  • The where clause must be enclosed by double quotes.
  • When working with text fields, values must be in single quotes, for example, ('VACANT').
  • Date fields support all queries except LIKE. Dates are strings in YYYY:MM:DD hh:mm:ss format. The following is an example using the date field ObsDate:"where": "ObsDate >= '1998-04-30 13:30:00' "
OperatorDescription

=

Equal

>

Greater than

<

Less than

>=

Greater than or equal to

<=

Less than or equal to

<>

Not equal

LIKE '% <string>'

A percent symbol (%) signifies a wildcard, meaning that anything is acceptable in its place—one character, a hundred characters, or no character. The following expression would select Mississippi and Missouri among USA state names: STATE_NAME LIKE 'Miss%'

BETWEEN <value1> AND <value2>

Selects a record if it has a value greater than or equal to <value1> and less than or equal to <value2>. For example, the following expression selects all records with an HHSIZE value greater than or equal to 3 and less than or equal to 10:

HHSIZE BETWEEN 3 AND 10

The above is equivalent to the following:

HHSIZE >= 3 AND HHSIZE <= 10

This operator applies to numeric or date fields. The following is an example of a date query on the ObsDate field:

ObsDate BETWEEN '1998-04-30 00:00:00' AND '1998-04-30 23:59:59'

Time is optional.

NOT BETWEEN <value1> AND <value2>

Selects a record if it has a value outside the range between <value1> and <value2>. For example, the following expression selects all records with an HHSIZE value less than 5 and greater than 7:

HHSIZE NOT BETWEEN 5 AND 7

The above is equivalent to:

HHSIZE < 5 OR HHSIZE > 7

This operator applies to numeric or date fields.

Example spatial expression:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
[
 {
   "operator": "and",
   "layer": 0,
   "spatialRel": "withinDistance",
   "selectingLayer": 1,
   "distance": 10,
   "units": "miles"
 }
]
  • The operator value can be either and or or.
  • The layer value is the index of the layer in the inputLayers parameter. The result of the expression is features in this layer.
  • The selectingLayer is the index of the layer in the inputLayers parameter that is used to define the spatial relationship with features in the layer.
  • The spatialRel value is the spatial relationship. The nine spatial relationships are described in the following table:
spatialRelDescription

intersects

notIntersects

Intersects

A feature in layer passes the intersect test if it overlaps any part of a feature in selectingLayer, including touches (where features share a common point).

  • intersects—If a feature in layer intersects a feature in selectingLayer, the feature in layer is included in the output.
  • notIntersects—If a feature in layer intersects a feature in selectingLayer, the feature in layer is excluded from the output.

withinDistance

notWithinDistance

withinDistance

The within a distance relationship uses the straight-line distance between features in layer to those in selectingLayer.

  • withinDistance—A feature in layer is selected (included in the output) if any part is within the specified distance of a feature in selectingLayer. For example, parcels within 100 meters of a river will be included in the output.
  • notWithinDistance—A feature in layer is excluded (not included in the output) if it is within a distance of a feature in selectingLayer. For example, parcels within 100 meters of a river will not be included in the output. You can think of this relationship as is farther away than.

contains

notContains

contains

A feature in layer passes this test if it completely surrounds a feature in selectingLayer. No portion of the contained feature can be outside the containing feature; however, the contained feature can touch the containing feature (that is, share a common point along its boundary).

  • contains—If a feature in layer contains a feature in selectingLayer, the feature in layer is included in the output.
  • notContains—If a feature in layer contains a feature in selectingLayer, the feature in the first layer is excluded from the output.

within

notWithin

within

A feature in layer passes this test if it is completely surrounded by a feature in selectingLayer. The entire feature in layer must be within the containing feature; however, the two features can touch (that is, share a common point along its boundary).

  • within—If a feature in layer is completely within a feature in selectingLayer, the feature in layer is included in the output.
  • notWithin—If a feature in layer is completely within a feature in selectingLayer, the feature in layer is excluded from the output.

nearest

Nearest to

A feature in the first layer passes this test if it is nearest to a feature in the second layer.

  • nearest—If a feature in the first layer is nearest to a feature in the second layer, the feature in the first layer is included in the output.
  • The distance value is the distance to use for the withinDistance and notWithinDistance spatial relationship.
  • The units value is the units to use for the distance parameter. Values: Meters | Kilometers | Feet | Yards | Miles

An expression can be a list, which denotes a group. The first operator in the group indicates how the group expression is added to the previous expression. Grouping expressions is only necessary when you need to create two or more distinct sets of features from the same layer. One way to think of grouping is that without grouping, you would have to run the FindExistingLocations task multiple times and merge the results.

The following is an example where grouping is needed:

  • You have a layer representing places that contain toxic chemicals. Each feature has an attribute, CHEMICAL, containing the name of the toxic chemical known to exist at the site.
  • You want to find toxic sites containing Mercury or Selenium that are near a river (layer 0).
  • You also want to find toxic sites containing Benzene or Lead that are near a park (layer 1).

Example of grouping using a list:

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
[
   {
       "operator": "and",
       "layer": 0,
       "spatialRel": "withinDistance",
       "selectingLayer": 1,
       "distance": 0.5,
       "units": "Miles"
   },
   [
       {
           "operator": "and",
           "layer": 0,
           "where": "CHEMICAL = 'MERCURY'"
       },
       {
           "operator": "or",
           "layer": 0,
           "where": "CHEMICAL = 'SELENIUM'"
       },
   ],
   [
       {
           "operator": "or",
           "layer": 0,
           "spatialRel": "withinDistance",
           "selectingLayer": 2,
           "distance": 0.5,
           "units": "Miles"
       },
       [
           {
               "operator": "and",
               "layer": 0,
               "where": "CHEMICAL = 'BENZENE'"
           },
           {
               "operator": "or",
               "layer": 0,
               "where": "CHEMICAL = 'LEAD'"
           }
       ]
   ]
]

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

clipFeatures

When only a portion of a feature meets the criteria, this parameter specifies whether the result includes the entire feature or only the portions of the feature that meet all criteria:

  • True—Only the portions of the feature that meet all criteria will be returned. Specifying this option, is equivalent to running the DeriveNewLocations task.
  • False—The entire feature will be returned provided at least a portion of the feature meets all criteria. This is the default.

This parameter is available in ArcGIS Online or ArcGIS Enterprise 11.2 and later.

Use dark colors for code blocksCopy
1
"clipFeatures":false

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 value 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 value 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>/FindExistingLocations/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:

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

resultLayer

Request example:

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

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 an outputName value was provided, value contains the URL to the feature service layer.
Use dark colors for code blocksCopy
1
2
3
4
5
{
"paramName":"unknown",
"dataType":"GPString",
"value":{"url":"<hosted featureservice layer url>"}
}
  • If no outputName value was provided, value contains a feature collection.
Use dark colors for code blocksCopy
1
2
3
4
5
{
"paramName":"unknown",
"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.