Skip to content

RS_AsRaster

Rasterizes a geometry using the grid of a reference raster.

Usage

raster RS_AsRaster(geometry: geometry, reference_raster: raster, pixel_type: string)
raster RS_AsRaster(geometry: geometry, reference_raster: raster, pixel_type: string, all_touched: boolean)
raster RS_AsRaster(geometry: geometry, reference_raster: raster, pixel_type: string, all_touched: boolean, burn_value: double)
raster RS_AsRaster(geometry: geometry, reference_raster: raster, pixel_type: string, all_touched: boolean, burn_value: double, nodata_value: double)
raster RS_AsRaster(geometry: geometry, reference_raster: raster, pixel_type: string, all_touched: boolean, burn_value: double, nodata_value: double, use_geometry_extent: boolean)
raster RS_AsRaster(geometry: geometry, reference_raster: raster, pixel_type: string, all_touched: boolean, burn_value: double, nodata_value: double, use_geometry_extent: boolean)

Arguments

  • geometry (geometry)
  • reference_raster (raster)
  • pixel_type (string)
  • all_touched (boolean)
  • burn_value (double)
  • nodata_value (double)
  • use_geometry_extent (boolean)

[!WARNING]

Experimental. This function is experimental; its behavior may change without notice.

Description

Creates a single-band in-db raster by rasterizing geometry onto the grid defined by reference_raster.

The output pixel type is controlled by pixel_type. Optional arguments control whether pixels touched by the geometry are burned, the value burned into covered pixels, the nodata fill value, and whether the output extent is cropped to the geometry extent or kept equal to the full reference raster extent.

When both geometry and reference_raster have a CRS and they differ, geometry is reprojected into the reference raster’s CRS before rasterization. An error is returned if exactly one of them has a CRS.

Examples

WITH r AS (
  SELECT RS_FromPath('https://download.osgeo.org/geotiff/samples/gdal_eg/cea.tif') AS raster
)
SELECT RS_Width(
  RS_AsRaster(
    RS_ConvexHull(raster),
    raster,
    'float64',
    false,
    1.0,
    0.0,
    false
  )
)
FROM r;
┌──────────────────────────────────────────────────────────────────────────────┐
│ rs_width(rs_asraster(rs_convexhull(r.raster),r.raster,Utf8("float64"),Boolea │
│               n(false),Float64(1),Float64(0),Boolean(false)))…               │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                                          514 │
└──────────────────────────────────────────────────────────────────────────────┘