Derive New Locations

Derive New Locations

The Derive New Locations task derives new features from the input layers that meet a query you specify. A query is made up of one or more expressions. There are two types of expressions: attribute and spatial. An example of an attribute expression is that a parcel must be vacant, which is an attribute of the Parcels layer (where STATUS = 'VACANT'). An example of a spatial expression is that the parcel must also be within a certain distance of a river (Parcels within a distance of 0.75 Miles from Rivers).

The Derive New Locations task is very similar to the Find Existing Locations task, the main difference is that the result of Derive New Locations can contain partial features.

  • In both tasks, the attribute expression where and the spatial relationships within and contains return the same result. This is because these relationships return entire features.
  • When intersects or withinDistance is used, Derive New Locations creates new features in the result. For example, when intersecting a parcel feature and a flood zone area that partially overlap each other, Find Existing Locations will return the entire parcel whereas Derive New Locations will return just the portion of the parcel that is within the flood zone.

Request URL

http://<analysis url>/DeriveNewLocations/submitJob

Request Parameters

ParameterDescription

inputLayers

(Required)

A list of layers that will be used in the expressions parameter.

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

Example list of urls:
[
    {"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)

This is a list of expressions. There are two types of expressions, attribute and spatial.

Example attribute expression:
{
     "operator": "and",
     "layer": 0,
     "where": "STATUS = 'VACANT'"
}
Notes:
  • operator can be either and or or
  • layer is the index of the layer in the inputLayers parameter.
  • The where clause must be surrounded by double quotes.
  • When dealing with text fields, values must be single-quoted ('VACANT').
  • Date fields support all queries except LIKE. Dates are strings in YYYY:MM:DD hh:mm:ss format. Here's 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. This 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, this 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:

HHSIZE >= 3 AND HHSIZE <= 10

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

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, this expression selects all records whose HHSIZE value is 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:
{
      "operator": "and",
      "layer": 0,
      "spatialRel": "withinDistance",
      "selectingLayer": 1,
      "distance": 10,
      "units": "miles"
}
  • operator can be either and or or
  • layer is the index of the layer in the inputLayers parameter. The result of the expression is features in this layer.
  • spatialRel is the spatial relationship. There are eight spatial relationships.

    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 portion of the feature in layer that intersects the feature in selectingLayer is included in the output.
    • notIntersects—If a feature in layer intersects a feature in selectingLayer, the portion of the feature in layer that intersects the feature in selectingLayer 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—The portion of the feature in layer that is within the specified distance of a feature in selectingLayer is included in the output.
    • notWithinDistance—The portion of the feature in layer that is within the specified distance of a feature in selectingLayer is excluded from 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 is allowed to 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.

    Note:

    • You can use the contains relationship with points and lines. For example, you have a layer of street centerlines (lines) and a layer of manhole covers (points), and you want to find streets that contain a manhole cover. You could use contains to find streets that contain manhole covers, but in order for a line to contain a point, the point must be exactly on the line (that is, in GIS terms, they are snapped to each other). If there is any doubt about this, use the withinDistance relationship with a suitable distance value.

    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 are allowed to 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.

    Note:

    • You can use the within relationship for points and lines, just as you can with the contains relationship. For example, your first layer contains points representing manhole covers and you want to find the manholes that are on street centerlines (as opposed to parking lots or other non-street features). You could use within to find manhole points within street centerlines, but in order for a point to contain a line, the point must be exactly on the line (that is, in GIS terms, they are snapped to each other). If there is any doubt about this, use the withinDistance relationship with a suitable distance value.

  • distance is the distance to use for the withinDistance and notWithinDistance spatial relationship.
  • units is the units for distance. Values: Meters | Kilometers | Feet | Yards | Miles

An expression may 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 execute Derive New Locations multiple times and merge the results.

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:
[
    {
        "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 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 Derive New Locations, there are two settings.

  1. Extent (extent)—a bounding box that defines the analysis area. Only those features in the input list inputLayers that intersect the bounding box will be analyzed.
  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>/DeriveNewLocations/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>/DeriveNewLocations/jobs/<jobId>/results/<output parameter name>?token=<your token>&f=json

ParameterDescription

resultLayer

Request example:
{"url": 
"http://<analysis url>/DeriveNewLocations/jobs/<jobId>/results/resultLayer"}

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":"resultLayer", 
    "dataType":"GPString",
    "value":{"url":"<hosted featureservice layer url>"}
    }
  • If outputName was not provided, value contains a feature collection.
    {
    "paramName":"resultLayer",
    "dataType":"GPString",
    "value":{"layerDefinition": {}, "featureSet": {}}
    }

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