Scenes.SearchFeatures Method

Definition

Search for STAC features by collection id, bbox, intersecting geometry, start and end datetime.

public virtual Azure.Response SearchFeatures (string collectionId, Azure.Core.RequestContent content, int? maxpagesize = default, int? skip = default, Azure.RequestContext context = default);
abstract member SearchFeatures : string * Azure.Core.RequestContent * Nullable<int> * Nullable<int> * Azure.RequestContext -> Azure.Response
override this.SearchFeatures : string * Azure.Core.RequestContent * Nullable<int> * Nullable<int> * Azure.RequestContext -> Azure.Response
Public Overridable Function SearchFeatures (collectionId As String, content As RequestContent, Optional maxpagesize As Nullable(Of Integer) = Nothing, Optional skip As Nullable(Of Integer) = Nothing, Optional context As RequestContext = Nothing) As Response

Parameters

collectionId
String

Collection Id to be searched. Allowed values: "Sentinel_2_L2A" | "Sentinel_2_L1C".

content
RequestContent

The content to send as the body of the request. Details of the request body schema are in the Remarks section below.

maxpagesize
Nullable<Int32>

Maximum number of features needed (inclusive). Minimum = 1, Maximum = 100, Default value = 10.

skip
Nullable<Int32>

Skip token for getting next set of results.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service. Details of the response body schema are in the Remarks section below.

Exceptions

collectionId or content is null.

collectionId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call SearchFeatures with required parameters and request content, and how to parse the result.

var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetScenesClient(<2022-11-01-preview>);

var data = new {
    startDateTime = "2022-05-10T18:57:31.2311892Z",
    endDateTime = "2022-05-10T18:57:31.2311892Z",
};

Response response = client.SearchFeatures("<collectionId>", RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("href").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("rel").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("href").ToString());

This sample shows how to call SearchFeatures with all parameters and request content, and how to parse the result.

var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetScenesClient(<2022-11-01-preview>);

var data = new {
    startDateTime = "2022-05-10T18:57:31.2311892Z",
    endDateTime = "2022-05-10T18:57:31.2311892Z",
    intersects = new {
        coordinates = new[] {
            new[] {
                new[] {
                    new[] {
                        123.45d
                    }
                }
            }
        },
        type = "MultiPolygon",
    },
    bbox = new[] {
        123.45d
    },
    featureIds = new[] {
        "<String>"
    },
};

Response response = client.SearchFeatures("<collectionId>", RequestContent.Create(data), 1234, 1234);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacExtensions")[0].ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("geometry").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("bbox")[0].ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("href").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("rel").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("title").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("href").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("title").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("roles")[0].ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("collection").ToString());
Console.WriteLine(result.GetProperty("nextLink").ToString());

Remarks

Below is the JSON schema for the request and response payloads.

Request Body:

Schema for SearchFeaturesQuery:

{
  startDateTime: string (ISO 8601 Format), # Required. Start datetime of the time interval in which to search for Features.
  endDateTime: string (ISO 8601 Format), # Required. End datetime of the time interval in which to search for Features.
  intersects: {
    type: "Point" | "Polygon" | "MultiPolygon", # Required. GeoJSON object type.
  }, # Optional. GeoJSON (For more details: https://geojson.org/). Note: Coordinates are expected in [Longitude, Latitude] format.
  bbox: [number], # Optional. Only features that have a geometry that intersects the bounding box are selected.
The bounding box is provided as four numbers. The coordinate reference system of the values is WGS84 longitude/latitude.
  featureIds: [string], # Optional. Array of feature ids to return.
}

Response Body:

Schema for SearchFeaturesResponse:

{
  features: [
    {
      stacVersion: string, # Required. The STAC version the Feature implements.
      stacExtensions: [string], # Optional. A list of extensions the Feature implements.
      id: string, # Required. Provider identifier. Globally unique ID by Data provider.
      type: string, # Required. Type of the GeoJSON Object. It's value is always Feature.
      geometry: AnyObject, # Optional. Defines the full footprint of the asset represented by this item.
Its a GeoJSON geometry.
      bbox: [number], # Optional. Bounding box of the feature.
      properties: AnyObject, # Required. A dictionary of additional metadata for the item.
      links: [
        {
          href: string, # Required. The actual link in the format of an URL.
          rel: string, # Required. Relationship between the current document and the linked document.
          type: string, # Optional. Media type of the referenced entity.
          title: string, # Optional. A human readable title to be used in rendered displays of the link.
        }
      ], # Required. List of link objects to resources and related URLs.
      assets: Dictionary<string, StacFeatureAsset>, # Required. Dictionary of asset objects, each with a unique key.
      collection: string, # Optional. The id of the STAC Collection this Feature references.
    }
  ], # Required. List of features.
  nextLink: string, # Optional. URL to do the POST request with same filters,
to get next set of features.
}

Applies to