raster
This module contains procedures to access and operate with raster data that has been loaded into Snowflake with using Raster Loader.
Learn more about loading raster data as raster tables in Snowflake following this guide.
RASTER_VALUES
RASTER_VALUES(raster_table, vector_query, output_expression, output_table, options)Description
Returns each pixel and associated values from a output_expression across all bands in a given area of interest of a raster table. The result will include the data from the vector_query as well as from all bands, corresponding to the pixels that intersect each geography.
raster_table:VARCHARthe qualified table name of the raster table, e.g.'database.schema.raster_table'.vector_query:VARCHARquery containing the area of interest in which to perform the extraction, stored in a column namedgeom. Additional columns can be included into this query in order to be referenced from theoutput_expression. It can beNULL, in which case all values stored in the raster table will be extracted.output_expression:VARCHARcontains the bands and values to be extracted from the raster. This expression support alias. It does not support aggregations. If you need to use aggregations, use theRASTER_AGG_VALUESfunction. This expression can beNULLif apixelcolumn is added using theinclude_pixeloption.output_table:VARCHARwhere the resulting table will be stored. It must be aVARCHARof the form'database.schema.output_table'. The schema must exist and the caller needs to have permissions to create a new table on it. The process will fail if the target table already exists.options:VARCHARa JSON string with additional options:OptionDescriptioninclude_pixelBOOLEANwhether to include thepixelcolumn of the extracted pixel values, in quadbin format. Default isfalse.
Result
The result is a table with the corresponding values extracted from the output_expression and, if selected, a pixel column with quadbin indexes.
Examples
Extract band_1 values for raster pixels intersected by each point in the vector query. The output will be stored in a table.
Extract band_1 values for the raster pixels intersected by each polygon in the vector query. The output will be stored in a table.
Extract band_1, band_2 values wih alias names for the raster pixels intersected by all the geographies in the vector table. It will include the input columns except geom. The output will be stored in a table.
Extract band_1 values for raster pixels intersected by each point in the vector table. It will include the input columns except geom. The output will be stored in a table. The option "include_pixel" can be set to true to include the pixel value in quadbin format.
RASTER_AGG_VALUES
Description
Returns aggregated values for all pixels intersecting the specified geometries, according to an output_expression.
raster_table:VARCHARthe qualified table name of the raster table, e.g.'database.schema.raster_table'.input_query:VARCHARquery containing the area of interest in which to perform the aggregation, stored in a column namedgeom. Additional columns can be included into this query in order to be referenced from theoutput_expression. It can beNULL, in which case all values stored in the raster table will be used.output_expression:VARCHARcontains the aggregated values to be computed from the raster. For extracting non-aggregated values, use theRASTER_VALUESfunction. This expression cannot beNULL.output_table:VARCHARwhere the resulting table will be stored. It must be aVARCHARof the form'database.schema.output_table'. The schema must exist and the caller needs to have permissions to create a new table on it. The process will fail if the target table already exists.options:VARCHARa JSON string with additional options.OptionDescriptiongroupby_vector_columnsARRAYgroup by extra columns included in thevector_query, in addition to thegeomcolumn. It does not take effect whenvector_queryisNULL.groupby_raster_columnsARRAYgroup by extra columns included in theraster_table, in addition to thegeomcolumn.
Result
The result is a table with the corresponding aggregated values from the output_expression.
Examples
Aggregate band_1 values for the raster pixels intersected by each polygon in the vector query. The output will be stored in a table.
Aggregate band_1, band_2 values wih different aggregations for the raster pixels intersected by all the geographies in the vector table. It will include the input columns. The output will be stored in a table.
Aggregate band_1 values for the raster pixels intersected by each polygon in the vector table. It will include the input columns. The option groupby_vector_columns will be set to id (unique-id) to aggregate with duplicated geographies. The output will be stored in a table.
Last updated
Was this helpful?
