RS_Clip, which extracts a subset of an existing raster while preserving its original values, RS_AsRaster generates a new Raster where the Geometry is rasterized onto a raster grid. The function supports all geometry types.
The function doesn’t support rasters that have any one of the following properties:If a raster is provided with any one of these properties then IllegalArgumentException is thrown.
Signatures
Parameters
Geometry
required
The geometry to be rasterized.
Raster
required
The reference raster to be used for overlaying the geometry on.
String
required
Defines data type of the output raster. Accepts one of:
D (double), F (float), I (integer), S (short), US (unsigned short) or B (byte).Boolean
default:"false"
For polygons,
false selects pixels whose centroids intersect the polygon; true also includes cells entered by the polygon’s boundary. Point and line selection follows the rules below.Double
default:"1.0"
The value to be used for assigning pixels covered by the geometry.
Double
Fills pixels not covered by the geometry, including interior holes, and becomes the output band’s no-data metadata. The value must be exactly representable in
pixelType. Fractional or out-of-range values for an integer type, and values that cannot be exactly represented in a floating-point type, raise an error. NaN is supported for F and D; infinite values are not supported.When omitted, the value is inherited from the reference raster’s first band. An error is raised if that band has no no-data value.Boolean
default:"true"
Defines the extent of the resultant raster. When set to
true, it corresponds to the extent of geom. When set to false, it corresponds to the extent of raster. If true and the geometry neither burns nor overlaps any raster pixel, the function returns NULL because there is nothing to crop. A polygon that overlaps a pixel without covering its center still returns a cropped, unburned raster.Pixel selection
Pixel selection depends on the geometry type:- A polygon never selects a pixel it touches only on the pixel’s boundary, whichever edge that is. A polygon whose edges lie on grid lines selects only pixels inside it.
- A point selects its containing half-open pixel, regardless of
allTouched. A pixel contains its first edges in pixel order (the left and top edges on a north-up raster) but not its last. A point on an internal edge or corner selects the pixel after it in pixel order; a point on the raster’s last edge selects none. - Line rasterization follows the cells entered by its segments rather than requiring a pixel-centre intersection. A segment lying on a grid line selects the pixels after it in pixel order; one lying on the raster’s last edge selects none. A neighboring pixel contacted only at a segment endpoint is not selected unless the segment enters it.
LineString geometries, allTouched=true can expand the geometry extent at grid boundaries. With useGeometryExtent=true, this can change both the output dimensions and the selected pixels.
Return type
The resulting raster.

