geo-registry

Rasterize

Burns vector features into a raster grid, with a fixed value or a value from an attribute.

Pitfall. By default only cells whose centre falls inside a polygon are burned, so thin or small features can disappear.
Pitfall. Cells outside every feature are nodata in some engines and 0 in others.
About this operation
Also called Feature To Raster, Polygon To Raster, Vector To Raster, burn
Group conversion/vector-to-raster
Checks crs.present, raster.nodata
Pitfalls 2 listed above
Columbus tool Not stated
Notes Not stated
Status active
Broader Not stated
Narrower Not stated
Related

Parameters

Name Type Required Default Values Note
resolution number yes Not stated Not stated Cell size, in the layer's CRS units.
value number no 1 Not stated Value burned into cells covered by a feature.
field field no Not stated Not stated Burn this attribute's value instead of a fixed value.
all_touched boolean no no Not stated Burn every cell a feature touches, not only cells whose centre it covers.

Inputs and outputs

Direction Name Type Geometry Note
Input layer vector Not stated Not stated
Output output raster Not stated Not stated

In each engine

Engine Tool Parameters Differences
gdal gdal vector rasterize
  • resolution → resolution : x and y: --resolution 10,10.
  • value → burn
  • field → attribute-name
  • all_touched → all-touched
  • layer → input
  • output → output
  • With a resolution and no extent, the grid starts half a cell outside the features: a 50 m by 30 m rectangle at 10 m cells gives a 6 by 4 grid. Give extent, or target-aligned-pixels, to control it.
  • Cells outside every feature get init (default 0), not nodata, unless nodata is set.
geocube geocube.api.core.make_geocube
  • resolution A pair, (-res, res).
  • value Rasterizes columns; add a constant column for a fixed value.
  • field → measurements : A list of columns to rasterize.
  • layer → vector_data
  • Returns an xarray Dataset with one variable per column.
grass v.to.rast
  • resolution Set by the computational region (g.region res=...).
  • value → value
  • field Set use = attr and attribute_column; this mapping burns a fixed value (use = val).
  • all_touched Use the d flag for dense lines; areas burn cell centres.
  • layer → input
  • output → output
None noted
Preset: {"use":"val"}
postgis-raster st_asraster
  • resolution scalex and scaley: the cell size, with scaley negative.
  • value → value
  • field Pass the column as value.
  • all_touched → touched
  • layer → geom
  • Per geometry; union the features first (ST_Union) or use ST_AsRaster with a reference raster for a common grid.
qgis gdal:rasterize
  • resolution Set UNITS = 1 (georeferenced units) and give the cell size as both WIDTH and HEIGHT.
  • value → BURN
  • field → FIELD
  • all_touched Pass -at in EXTRA.
  • layer → INPUT
  • output → OUTPUT
None noted
rasterio rasterio.features.rasterize
  • resolution Give out_shape and transform instead (rasterio.transform.from_origin(west, north, res, res)).
  • value → default_value
  • field Pass (geometry, value) pairs as shapes.
  • all_touched → all_touched
  • layer → shapes
  • Returns an array; cells outside every shape get fill (default 0).
terra terra::rasterize
  • resolution y is a template raster; make one with rast(x, resolution = res).
  • value → values
  • field → field
  • all_touched → touches
  • layer → x
  • Cells outside every feature get background (default NA).
whiteboxtools VectorPolygonsToRaster
  • resolution → cell_size
  • value Burns a field's values; field defaults to FID.
  • field → field
  • all_touched always no
  • layer → input
  • output → output
  • Polygons only (VectorLinesToRaster and VectorPointsToRaster are separate tools); base can give a raster whose grid to match.