RS_Clip¶
Introduction: Returns a raster that is clipped by the given geometry.
If crop is not specified then it will default to true, meaning it will make the resulting raster shrink to the geometry's extent and if noDataValue is not specified then the resulting raster will have the minimum possible value for the band pixel data type.
The allTouched parameter (Since v1.7.1) determines how pixels are selected:
- When true, any pixel touched by the geometry will be included.
- When false (default), only pixels whose centroid intersects with the geometry will be included.
Note
- Since
v1.5.1, if the coordinate reference system (CRS) of the inputgeomgeometry differs from that of theraster, thengeomwill be transformed to match the CRS of theraster. If therasterorgeomdoesn't have a CRS then it will default to4326/WGS84. - Since
v1.7.0,RS_Clipfunction will returnnullif therasterandgeometrygeometry do not intersect. If you want to throw an exception in this case, you can set thelenientparameter tofalse.
Format:
RS_Clip(raster: Raster, band: Integer, geom: Geometry, allTouched: Boolean, noDataValue: Double, crop: Boolean, lenient: Boolean)
RS_Clip(raster: Raster, band: Integer, geom: Geometry, allTouched: Boolean, noDataValue: Double, crop: Boolean)
RS_Clip(raster: Raster, band: Integer, geom: Geometry, allTouched: Boolean, noDataValue: Double)
RS_Clip(raster: Raster, band: Integer, geom: Geometry, allTouched: Boolean)
RS_Clip(raster: Raster, band: Integer, geom: Geometry)
Since: v1.5.1
Original Raster:

SQL Example
SELECT RS_Clip(
RS_FromGeoTiff(content), 1,
ST_GeomFromWKT('POLYGON ((236722 4204770, 243900 4204770, 243900 4197590, 221170 4197590, 236722 4204770))'),
false, 200, true
)
Output:

SQL Example
SELECT RS_Clip(
RS_FromGeoTiff(content), 1,
ST_GeomFromWKT('POLYGON ((236722 4204770, 243900 4204770, 243900 4197590, 221170 4197590, 236722 4204770))'),
false, 200, false
)
Output:
