Skip to content

SQL Functions

RS_CLASSIFY

The RS_Classify function performs single-label, multi-class classification.

Input Parameters

  • model_id: STRING. The identifier of the model to be used for classification. Supported model ID: landcover-eurosat-sentinel2.
  • input_raster: LazyOutDBRaster. The SQL column containing the input raster data for classification.

Returns

Return Type: A MAP containing the following fields: - key: STRING. The class label. - value: FLOAT. The confidence score for the class label.

Example Invocation

SELECT outdb_raster, RS_CLASSIFY('landcover-eurosat-sentinel2', outdb_raster) AS preds
FROM df_raster_input;

RS_MAX_CONFIDENCE

Returns the label and confidence of the highest confidence class from the RS_CLASSIFY function.

Input Parameters

  • prediction_column: MAP. The prediction column result from RS_CLASSIFY

Returns

Return Type: A STRUCT containing the following fields: - max_confidence_label: STRING. The label with the highest confidence score. - max_confidence_score: FLOAT. The highest confidence score.

RS_SEGMENT

The RS_Segment function performs semantic segmentation.

Input Parameters

  • model_id: STRING. The identifier of the model to be used for segmentation. Supported model ID: solar-satlas-sentinel2.
  • input_raster: LazyOutDBRaster. The SQL column containing the input raster data for segmentation.

Returns

Return Type: A STRUCT containing the following fields: - confidence_array: ARRAY<FLOAT>. An array of confidence scores. - class_map: MAP<STRING, INTEGER>. A mapping of class labels to their corresponding integer values.

Example Invocation

SELECT outdb_raster, RS_SEGMENT('solar-satlas-sentinel2', outdb_raster) AS preds
FROM df_raster_input;

RS_DETECT_BBOXES

The RS_Detect_BBoxes function performs object detection and returns bounding boxes.

Input Parameters

  • model_id: STRING. The identifier of the model to be used for object detection. Supported model ID: marine-satlas-sentinel2.
  • input_raster: LazyOutDBRaster. The SQL column containing the input raster data for object detection.

Returns

Return Type: A STRUCT containing the following fields: - bboxes_wkt: ARRAY<STRING>. The bounding boxes in Well-Known Text (WKT) format. - confidence_scores: ARRAY<FLOAT>. The confidence scores corresponding to the bounding boxes. - labels: ARRAY<INTEGER>. The labels for the bounding boxes.

Example Invocation

SELECT outdb_raster, RS_DETECT_BBOXES('marine-satlas-sentinel2', outdb_raster) AS preds
FROM df_raster_input;

RS_FILTER_BOX_CONFIDENCE

The RS_Filter_Box_Confidence function filters the bounding boxes by a confidence threshold.

Input Parameters

  • bboxes_wkt: ARRAY<STRING>. The bboxes_wkt column results from RS_DETECT_BBOXES.
  • confidence_scores: ARRAY<FLOAT>. The confidence scores corresponding to the bounding boxes.
    • labels: ARRAY<INTEGER>. The labels for the bounding boxes.

Returns

Return Type: A STRUCT containing the following fields: - max_confidence_bboxes: ARRAY<STRING>. The bounding boxes with the highest confidence. - max_confidence_scores: ARRAY<FLOAT>. The confidence scores corresponding to the bounding boxes. - max_confidence_labels: ARRAY<STRING>. The labels for the bounding boxes with the highest confidence.

Example Invocation

SELECT outdb_raster, RS_FILTER_BOX_CONFIDENCE(bboxes_wkt, confidence_scores, labels) AS preds
FROM preds_table;

RS_TEXT_TO_BBOXES

The RS_Text_to_BBoxes function performs text-prompted object detection, returning bounding boxes for objects matching the text description. The flexibility of the text prompt depends on the underlying model.

Input Parameters

  • model_id: STRING. The identifier of the model to be used for text-prompted detection. Supported model IDs: owlv2.
  • input_raster: LazyOutDBRaster. The SQL column containing the input raster data for detection.
  • text_prompt: STRING. A natural language input used by the object detection model to determine which objects to identify.
  • confidence_threshold: FLOAT. A value between 0 and 1 to filter detection confidence. Lower values return more potential matches.

Returns

Return Type: A STRUCT containing the following fields: - bboxes_wkt: ARRAY<STRING>. The bounding boxes in Well-Known Text (WKT) format. - confidence_scores: ARRAY<FLOAT>. The confidence scores corresponding to the bounding boxes. - labels: ARRAY<STRING>. The text labels for the bounding boxes (matching the input prompt).

Example Invocation

SELECT outdb_raster, RS_TEXT_TO_BBOXES('owlv2', outdb_raster, 'solar panels', 0.1) AS detect_result
FROM df_raster_input;

RS_TEXT_TO_SEGMENTS

The RS_Text_to_Segments function performs text-prompted instance segmentation, returning WKT polygons converted from pixel-wise masks for areas matching the text description.

Input Parameters

  • model_id: STRING. The identifier of the model to be used for text-prompted segmentation. Supported model ID: sam2.
  • input_raster: LazyOutDBRaster. The SQL column containing the input raster data for segmentation.
  • text_prompt: STRING. A natural language description of the features to segment.
  • confidence_threshold: FLOAT. A value between 0 and 1 to filter segmentation confidence. Lower values return more potential matches.

Returns

Return Type: A STRUCT containing the following fields: - confidence_array: ARRAY<FLOAT>. An array of confidence scores for each segment. - segments_wkt: ARRAY<STRING>. The segmentation polygons in Well-Known Text (WKT) format. - labels: ARRAY<STRING>. The text labels for the segments (matching the input prompt).

Example Invocation

SELECT outdb_raster, RS_TEXT_TO_SEGMENTS('sam2', outdb_raster, 'solar panels', 0.3) AS detect_result
FROM df_raster_input;

Notes

The functions RS_Text_to_BBoxes and RS_Text_to_Segments are best suited for exploratory detection scenarios where: 1. Target features have high visual contrast with surroundings. 1. Target features have clear, unambiguous descriptions. 1. Image resolution and quality are sufficient to resolve features of interest.

Results should be reviewed by a human operator for accuracy, as confidence scores may not perfectly separate correct from incorrect predictions. To visually inspect the tabular results, use the python API's wherobots.inference.plot.detections.show_detections function.