Skip to main content
100%

ST_ClipEx a working variation of ST_Clip for raster

✓ Published0🌍 Public
Aandrewxhill
Last edited Dec 8, 2011
Created on Dec 8, 2011

ST_ClipEx demonstrates a custom SQL function for clipping raster data in PostGIS, showing how to extract a rectangular subset of pixels from a larger raster grid. The function takes input coordinates and dimensions, then constructs a new empty raster with matching georeferencing properties before copying pixel values band by band. It iterates through each band and cell position using nested loops, applying ST_Value to read source pixels and ST_SetValue to write them into the clipped result. The code explicitly manages edge cases where the requested clip extends beyond the original raster bounds.

AI-generated description

Similar vizzes