Zonalstats

class eolab.georastertools.Zonalstats(stats: List[str], categorical: bool = False, valid_threshold: float = 0.0, area: bool = False, prefix: str | None = None, bands: List[int] = [1])[source]

Bases: Rastertool

Raster tool that computes zonal statistics of a raster product.

Attributes

Zonalstats.area

Whether to compute the statistics multiplied by the pixel area

Zonalstats.bands

List of bands to process

Zonalstats.categorical

Whether to compute the counts of every unique pixel values

Zonalstats.category_file

Filename containing the categories when computing stats per categories in the geometries

Zonalstats.category_file_type

Type of the category file, either 'raster' or 'vector'

Zonalstats.category_index

Column name identifying categories in categroy_file (only if file format is geometries)

Zonalstats.category_labels

Dict with classes index as keys and names to display as values

Zonalstats.chart_file

Name of the chart file to generate

Zonalstats.display_chart

Whether to display the chart

Zonalstats.generated_stats

The list of generated stats in the same order as the input files

Zonalstats.generated_stats_dates

The list of dates when they can be extracted from the input files' names

Zonalstats.generated_stats_per_date

After processing one or several files, this method enables to retrieve a dictionary that contains the statistics for each inputfile's date:

Zonalstats.geometries

The geometries where to compute zonal statistics

Zonalstats.geometry_index

The column name identifying the name of the geometry

Zonalstats.keep_vrt

Whether intermediate VRT images shall be kept

Zonalstats.output_format

Output format for the features stats

Zonalstats.outputdir

Path of the output directory where are stored the results

Zonalstats.prefix

Prefix of the features stats (one per band)

Zonalstats.sigma

Number of sigmas for identifying outliers

Zonalstats.stats

List of stats to compute

Zonalstats.supported_output_formats

List of all possible output format are provided by fiona.supported_drivers.keys()

Zonalstats.valid_stats

List of stats that can be computed.

Zonalstats.valid_threshold

Minimum percentage of valid pixels in a shape to compute its statistics

Zonalstats.vrt_dir

Dir where to store intermediate VRT images

Zonalstats.within

Whether to compute stats for geometries within the raster (if False, stats for all geometries intersecting the raster are computed)

Methods

Zonalstats.__init__(stats[, categorical, ...])

Constructor

Zonalstats.compute_stats(raster, bands, ...)

Compute the statistics of the input data.

Zonalstats.postprocess_files(inputfiles, ...)

Generate the chart if requested after computing stats for each input file

Zonalstats.process_file(inputfile)

Compute the stats for a single input file

Zonalstats.process_files(inputfiles)

Run the rastertool to a set of input files.

Zonalstats.with_chart([chart_file, ...])

Set up the charting capability

Zonalstats.with_geometries(geometries[, within])

Set up the geometries where to compute stats.

Zonalstats.with_outliers(sigma)

Set up the computation of outliers

Zonalstats.with_output([outputdir, ...])

Set up the output.

Zonalstats.with_per_category(category_file)

Set up the zonal stats computation per categories

Zonalstats.with_vrt_stored(keep_vrt)

Configure if the intermediate VRT images that are generated when handling the input files (which can be complex raster product composed of several band files) shall be stored to disk or not - for debug purpose for instance.