semantique.extent.SpatialExtent.rasterize

semantique.extent.SpatialExtent.rasterize#

SpatialExtent.rasterize(resolution, crs=None)[source]#

Rasterize the spatial extent into an array.

Rasterizing the spatial extent creates a rectangular two-dimensional regular grid that covers the bounding box of the extent. Each grid cell corresponds to a spatial location within this bounding box. Cells that do not intersect with the extent itself get assigned a value of 0. Cells that do intersect with the extent itself get assigned a positive integer, depending on which of the features in the extent they intersects with, i.e. a 1 if they intersect with the first feature in the extent, a 2 if they intersect with the second feature in the extent, et cetera.

Parameters:
  • resolution (list) – Spatial resolution of the grid. Should be given as a list in the format [y, x], where y is the cell size along the y-axis, x is the cell size along the x-axis, and both are given as int or float value expressed in the units of the CRS. These values should include the direction of the axes. For most CRSs, the y-axis has a negative direction, and hence the cell size along the y-axis is given as a negative number.

  • crs (optional) – Coordinate reference system in which the grid should be created. Can be given as any object understood by the initializer of pyproj.crs.CRS. This includes pyproj.crs.CRS objects themselves, as well as EPSG codes and WKT strings. If None, the CRS of the extent itself is used.

Returns:

xarray.DataArray