geo3d.rasters.types

Classes

GeoTransform

GeoTransform class.

Raster

Class for defining raster objects.

Module Contents

class geo3d.rasters.types.GeoTransform(/, **data: Any)

Bases: pydantic.BaseModel

GeoTransform class.

xorigin: float
yorigin: float
pixelwidth: float
pixelheight: float
rowrotation: float
columnrotation: float
size: Tuple[int, int]
dump() dict

Convert to a dictionary object.

Returns:

A GeoTransform dictionary with the same keys as the object’s attributes.

Return type:

dict

resize(new_size: Tuple[int, int]) GeoTransform

Adapt the GeoTransform dataclass for a different image size.

Parameters:

new_size (Tuple[int, int]) – New image size.

Returns:

A new GeoTransform instance.

Return type:

GeoTransform

pixels2coordinates(pixels: Tuple[int, int]) Tuple[float, float]

Convert a pixel position to a geometric coordinates.

Parameters:

pixels (Tuple[int, int]) – The position of a pixel as (col, row).

Returns:

The geometric coordinates of a pixel position.

Return type:

Tuple[float, float]

class geo3d.rasters.types.Raster(dataset: osgeo.gdal.Dataset)

Class for defining raster objects.

color_file
ds_
classmethod read(path: str) Raster

Create a raster object from a file.

Parameters:

path (str) – The path to the raster object.

Returns:

The created raster object.

Return type:

Raster

property width: int

Get the width of the raster.

Returns:

The width value.

Return type:

int

property height: int

Get the height of the raster.

Returns:

The height value.

Return type:

int

property dimensions: Tuple[int, int]

Get the dimensions of the raster.

Returns:

The width x height.

Return type:

Tuple[int, int]

property geotransform: GeoTransform

Get the affine transformation.

Return type:

Tuple[int | float]

to_png(output_path: str, colors: bool = True) None

Convert the raster to a PNG image.

Parameters:
  • output_path (str) – The path to the output image file.

  • colors (bool, optional) – Apply color relief if True. Defaults to True.

close() None

Close the raster.