Converts raster pixels into polygon geometries. For each connected region of pixels with the same value, returns a polygon geometry along with the pixel value. This is useful for vectorizing raster data.
Signatures
RS_Polygonize(raster: Raster, band: Int)
Parameters
The band index (1-based) to polygonize.
Return type
An array of structs, each containing a polygon geometry and its corresponding pixel value.
Examples
SELECT RS_Polygonize(raster, 1) FROM my_raster_table
SELECT exploded.geom, exploded.value
FROM my_raster_table,
LATERAL VIEW explode(RS_Polygonize(raster, 1)) AS exploded