class Raster(dtcc_model.model.Model)[source]

A georeferenced n-dimensional raster of values.

This class represents a georeferenced n-dimensional raster of values, where data is a NumPy array of shape (height, width, channels) or (height, width) if channels is 1.

data

The data of the raster as a NumPy array.

Type:

np.ndarray

georef

The georeference of the raster.

Type:

Affine

nodata

The value representing nodata or missing data.

Type:

float

crs

The coordinate reference system (CRS) information.

Type:

str

Public members

nodata : float = nan
crs : str = ''
__str__()[source]

Return a string representation of the Raster.

property shape

Get the shape of the raster data.

property height

Get the height (number of rows) of the raster data.

property width

Get the width (number of columns) of the raster data.

property channels

Get the number of channels in the raster data.

property bounds

Get the spatial bounds of the raster.

calculate_bounds()[source]

Calculate the spatial bounds of the raster.

property cell_size

Get the cell size (pixel size) of the raster.

property min

Get the minimum value of the raster.

property max

Get the maximum value of the raster.

get_value(x: float, y: float)[source]

Get the value at the given coordinate.

copy(no_data=False)[source]

Return a copy of the object.

to_proto() Raster[source]

Convert the Raster object to a protobuf representation.

from_proto(pb: Raster | bytes)[source]

Initialize the Raster object from a protobuf representation.

Raster(data: ~numpy.ndarray = <factory>, ...)

Initialize self. See help(type(self)) for accurate signature.

__repr__()

Return repr(self).

__eq__(other)

Return self==value.

save(path)

Save a Raster object to a file.

fill_holes()

Fill nodata holes in a Raster object using the nearest neighbour.

resample(cell_size=None, scale=None, method='bilinear')

Resample a Raster object to a new cell size or scale.

stats(polygons: Polygon | list[Polygon], stats=['mean'])

Compute statistics for a raster within a polygon.

burn_polygons(poly_values: tuple, ...) Raster

Burn polygons into a raster.

slope_aspect() tuple[Raster, Raster]
TRI() Raster

Compute the Terrain Roughness Index (TRI) of a DEM using optimized array operations.

TPI(window_size=3)

Compute the Topographic Position Index (TPI) of a DEM.

VRM(window_size=3)

Compute the Vector Ruggedness Measure (VRM) of a DEM.

to_pointcloud() PointCloud

Convert a raster to a point cloud. The points will be in the center of each cell.

view()

View a raster in 3D with a GLFW window.

data : ndarray
georef : Affine
to_json() str

Return a JSON representation of the object.

classmethod add_methods(module, name=None)

Adds methods from a module or function to the class.

classmethod print_methods(verbose=False)

Print the methods that have been added to the class.