RasterProduct

class eolab.georastertools.product.rasterproduct.RasterProduct(file: Path | str, vrt_outputdir: Path | str | None = None)[source]

Bases: object

Data model for a raster product that handles :

  • a raster type

  • the list of available bands

  • the path to the product

A raster product can be easily like this:

with RasterProduct("my_product_filename.zip") as product:
    rastertype = product.rastertype()
    raster = product.get_raster()  # raster is an in-memory VRT that can
                                   # be opened using rasterio
    with rasterio.open(raster) as rst:
        print(rst.count)
        data = rst.read([1, 2, 3], masked=True)  # data is a numpy masked array

A raster product handles several in-memory VRTs that must be properly released. The with statement enables this. If you want to control the clean-up of the in-memory VRTs you have to call free_in_memory_vrts().

Attributes

RasterProduct.bands_files

Dictionary of available bands.

RasterProduct.channels

List of available channels in the product

RasterProduct.file

Product path

RasterProduct.is_archive

Whether the raster product is an archive (zip, tar, dir, ...) or a regular raster image

RasterProduct.masks_files

Dictionary of available mask bands.

RasterProduct.rastertype

Type of the raster

Methods

RasterProduct.__init__(file[, vrt_outputdir])

Constructor

RasterProduct.free_in_memory_vrts()

Free in-memory VRTs by closing all MemoryFile objects.

RasterProduct.get_date()

Extracts the timestamp of the raster

RasterProduct.get_date_string([strformat])

Extracts the timestamp of the raster and returns it as a formatted string

RasterProduct.get_raster([bands, masks, ...])

Gets the path to the raster corresponding to this product.

RasterProduct.get_relative_orbit()

Extracts the relative orbit number of the raster

RasterProduct.get_satellite()

Extracts the satellite's name of the raster

RasterProduct.get_tile()

Extracts the tile identifier of the raster

RasterProduct.open([bands, masks, roi])