- URL:
- https://<imageservice-url>/query
- Methods:
GET
- Required Capability:
- Catalog
- Version Introduced:
- 10.0
Description
The query
operation is performed on an image service resource and queries the resource by applying a filter specified by the user through the request. The result of this operation is a set of features or an array of raster IDs (if return
is set to true
), a count (if return
is set to true
), or a set of field statistics (if out
is used).
While there is a limit (max
) to the number of features included in the feature set response, there is no limit to the number of object IDs returned in the ID array response. Clients can use this to get all the query-conforming object IDs by specifying return
and subsequently requesting feature sets for subsets of object IDs.
At 10.8.1, the query
operation supports raster
if the image service uses Arc
or Arc
as the service provider.
You can provide arguments to the query
operation as query parameters defined in the parameters table below.
Request parameters
Parameter | Details |
---|---|
|
The response format. The default response format is Values: |
| The object IDs of the raster catalog to be queried. Syntax
Example
|
| A where clause for the query filter. Any legal SQL where clause operating on the fields in the raster catalog is allowed. Example
|
| The time instant or the time extent to query.
|
| The geometry that will be applied as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API. In addition to the JSON structures, for envelopes and points, you can specify the geometry with a comma-separated syntax. Syntax
Examples
|
| The number of decimal places in the response geometries returned by the query operation. This applies to x and y values only (not m- or z-values). Example
|
| Specifies the type of geometry provided in the Values: |
| The spatial reference of the input |
| Specifies the spatial relationship that will be applied to the input geometry while performing the query. The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is intersects ( Values: |
| The list of fields that will be included in the returned result set. This list is a comma-delimited list of field names. To request geometry, set Example
|
| Specifies whether the result set will include the geometry associated with each result ( Values: |
|
The spatial reference of the returned geometry. |
| Specifies whether the response will only include an array of raster IDs ( While there is a limit to the number of rasters included in the raster set response, there is no limit to the number of raster IDs returned in the ID array response. Clients can use this to get all the query conforming raster IDs by specifying Values: |
| Specifies whether the response will only include the This parameter supersedes the Values: |
| The pixel size that will be used to query visible rasters. If no value is provided, rasters at all resolutions can be queried. The structure of the Syntax
Examples
|
| Order results by one or more field names. This parameter uses Syntax
Example
|
| Specifies whether distinct values based on the fields specified in the Values: |
| An array of statistic definitions for one or more field-based statistics to be calculated. The definitions specify the type of statistic, the field on which it is to be calculated, and the resulting output field name. This parameter is only supported if the Syntax
Example
|
| One or more field names using the values that need to be grouped for calculating the statistics. This parameter is only valid when the Syntax
Example
|
| The filters defined by multiple dimensional definitions. See Dimensional Definition objects for more information. Syntax
|
| The number of records that will be skipped when fetching query results. The query results start from the next record (for example, You can use this parameter to fetch records that are beyond the |
| The number of query results that will be fetched. When the This parameter only applies when Example
|
| The maximum offset that will be used for generalizing geometries returned by the query operation. This parameter value will be in the units of the Example
|
| Specifies whether true curves will be returned in the output geometries ( Values: |
| Introduced at 10.8.1. A query based on key properties of each raster catalog item. Any legal SQL where clause operating on the key properties of raster catalog items is allowed. Example
|
Example usage
Example 1
The following is a sample request URL for the query
operation that demonstrates a query that uses a where clauses and requests to return specific outfields:
https://machine.domain.com/webadaptor/rest/services/Portland/CascadeLandsat/ImageServer/query?where=Name LIKE 'p045r028%' AND Name NOT LIKE 'Ovr%'&outFields=Name,MinPS,MaxPS,LowPS,HighPS&returnGeometry=true&returnIdsOnly=false&f=html
Example 2
The following is a sample request URL for the query
operation that demonstrates a query that uses point geometry and where clauses and requests to return only object IDs:
https://machine.domain.com/webadaptor/rest/services/Portland/CascadeLandsat/ImageServer/query?where=NAME NOT LIKE 'Ov_%'&geometry={"x":-122.895114,"y":45.558214,"spatialReference":{"wkid":4269}}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelIntersects&outFields=*&returnGeometry=false&returnIdsOnly=true&f=html
Example 3
The following is a sample request URL for the query
operation that demonstrates querying distinct sensors and products in an image service:
https://machine.domain.com/webadaptor/rest/services/myImageService/ImageServer/query?where=1=1&outFields=SensorName,ProductName&returnDistinctValuesOnly=true&orderByFields=SensorName ASC, ProductName DESC&f=pjson
Example 4
The following is a sample request URL for the query
operation that demonstrates querying for the latest image acquisition date for each sensor:
https://machine.domain.com/webadaptor/rest/services/myImageService/ImageServer/query?outStatistics=[{"statisticType": "max","onStatisticField": "acquisitionDate","outStatisticFieldName": "LatestImageDate"}]&groupByFieldsForStatistics=SensorName&f=pjson
JSON Response syntax examples
Example 1
The following JSON syntax example demonstrates the response returned when the request includes return
as false
and return
as false
:
{
"objectIdFieldName": "<objectIdFieldName>",
"spatialReference": <spatialReference>,
"fields": [
{
"name": "<fieldName1>",
"type": "<fieldType1>",
"alias": "<fieldAlias1>",
"length": "<length1>"
},
{
"name": "<fieldName2>",
"type": "<fieldType2>",
"alias": "<fieldAlias2>",
"length": "<length2>"
}
],
"features": [
<feature1>,
<feature2>
]
}
Example 2
The following JSON syntax example demonstrates the response returned when the request includes return
as true
:
{
"count": <count>
}
Example 3
The following JSON syntax example demonstrates the response returned when the request includes return
as true
:
{
"objectIdFieldName": "<objectIdFieldName>",
"objectIds": [
<objectId1>,
<objectId2>
]
}
JSON Response examples
Example 1
The following is a sample response example for the query
operation:
{
"objectIdFieldName": "IMAGEID",
"spatialReference": {
"wkid": 4326
},
"fields": [
{
"name": "ST",
"alias": "ST",
"type": "esriFieldTypeString",
"length": 2
},
{
"name": "OBJECTID",
"alias": "OBJECTID",
"type": "esriFieldTypeOID"
},
{
"name": "AREANAME",
"alias": "City Name",
"type": "esriFieldTypeString",
"length": 255
}
],
"geometryType": "esriGeometryPolygon",
"features": [
{
"geometry": {
"rings": [
[
[-97.06138,32.837],
[-97.06133,32.836],
[-97.06124,32.834],
[-97.06127,32.832],
[-97.06138,32.837]
]
]
},
"attributes": {
"IMAGEID": 37,
"OWNER": "Joe Smith",
"VALUE": 94820.37,
"APPROVED": true,
"LASTUPDATE": 1227663551096
}
},
{
"geometry": {
"rings": [
[
[-97.06326,32.759],
[-97.06298,32.755],
[-97.06153,32.749],
[-97.06326,32.759]
]
]
},
"attributes": {
"IMAGEID": 462,
"OWNER": "John Doe",
"VALUE": 17325.90,
"APPROVED": false,
"LASTUPDATE": 1227628579430
}
}
]
}
Example 2
The following is a sample response example for the query
operation when return
is true
:
{
"count":48
}