196 | | 1) ST_Clip(raster, ulx float8, uly float8, width int, height int) -> raster |
197 | | |
198 | | 2) ST_Clip(raster, band, ulx float8, uly float8, width int, height int) -> raster |
199 | | |
200 | | 3) ST_Clip(raster, geometry) -> raster |
201 | | |
202 | | 4) ST_Clip(raster, band, geometry) -> raster |
203 | | |
204 | | 5) ST_Clip(raster, geometry, 'EXACT') -> raster |
205 | | |
206 | | 6) ST_Clip(raster, band, geometry, 'EXACT') -> raster |
207 | | |
208 | | |
209 | | |
210 | | Variant 1 takes the upper left corner, the width and the height of the desired extent. |
211 | | |
212 | | Variant 3 determine the extent of the resulting raster from the extent of the provided geometry. All pixels from the original raster are copied in the resulting raster including the ones outside the geometry. |
213 | | |
214 | | Variant 5 determine the extent of the resulting raster from the extent of the provided geometry. All pixels outside the geometry are set to nodata values. |
215 | | |
216 | | Variants 2, 4 and 6 return only the selected band with the clipped raster. |
| 196 | 1) ST_Clip(raster, ulx float8, uly float8, width int, height int, nodata float8 DEFAULT null) -> raster |
| 197 | |
| 198 | 2) ST_Clip(raster, band, ulx float8, uly float8, width int, height int, nodata float8 DEFAULT null) -> raster |
| 199 | |
| 200 | 3) ST_Clip(raster, geometry, nodata float8 DEFAULT null, trim boolean DEFAULT false) -> raster |
| 201 | |
| 202 | 4) ST_Clip(raster, band, geometry, nodata float8 DEFAULT null, trim boolean DEFAULT false) -> raster |
| 203 | |
| 204 | |
| 205 | Variant 1 and 2 take the upper left corner, the width and the height of the desired extent. |
| 206 | |
| 207 | Variant 3 and 4 set every pixels outside the provided geometry to nodata. The 'trim' parameter determines if the resulting raster extent should be the one of the original raster or the one of the intersection between the raster and the geometry, thus trimming nodata values as much as possible. |
| 208 | |
| 209 | Variants 2 and 4 returns only the selected band in the clipped raster. Variant 1 and 3 returns all bands. |
| 210 | |
| 211 | When no nodata value is provided, the resulting raster keeps its nodata value. If the raster does not have a nodata value, the minimum possible value for the pixeltype of each band is used as nodata value. |
222 | | Implemented as a wrapper around ST_MapAlgebra. |
223 | | |
224 | | newrast := ST_AddBand(ST_MakeEmptyRaster(x2 - x1, y2 - y1, ST_Raster2WorldCoordX(rast, x1, y2), ST_Raster2WorldCoordY(rast, x1, y2), ST_PixelSizeX(rast), ST_PixelSizeY(rast),ST_SkewX(rast),ST_SkewY(rast), ST_SRID(rast)), ‘1BB’, 1, 0) |
225 | | newrast := ST_MultiBandMapAlgebra(rast, newrast, ‘rast1’, ‘INTERSECTION’) |
226 | | |
227 | | Could also be implemented as ST_Intersection -> ST_Band(ST_Intersection(geometry, raster, band, “TRIM”), 1) Would require some kind of TRIM and would be slower. |
228 | | |
229 | | This function is necessary to optimize ST_Intersection. The raster to be polygonised before proceeding to a vector intersection should first be clipped to the minimal intersecting area using ST_Clip(). |
| 217 | Variants 3 and 4 are implemented as a wrapper around ST_MapAlgebra(raster, ST_AsRaster(geometry)). |
| 218 | |
| 219 | This function is useful to optimize ST_Intersection(raster, geometry). The raster to be polygonised before proceeding to a vector intersection should first be clipped to the minimal intersecting area using ST_Clip(). |