Skip to main content
Converts a Geometry to a Raster dataset. Unlike 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.
For more information about ScaleX, ScaleY, SkewX, SkewY, please refer to the Affine Transformations section.

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"
Decides the pixel selection criteria. If set to true, the function selects all pixels touched by the geometry. If false, selects only pixels whose centroids intersect the geometry.
Double
default:"1.0"
The value to be used for assigning pixels covered by the geometry.
Double
default:"null"
Used for assigning the no data value of the resultant raster.
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.

Return type

The resulting raster.

Examples

With default parameters

Using allTouched and useGeometryExtent