This module creates pyramid layers and calculates statistics for image files. Much of it was originally for ERDAS Imagine files but should work with any other format that supports pyramid layers and statistics

class rios.calcstats.ProgressUserData[source]
rios.calcstats.addPyramid(ds, progress, minoverviewdim=33, levels=[4, 8, 16, 32, 64, 128, 256, 512], aggregationType=None)[source]

Adds Pyramid layers to the dataset. Adds levels until the raster dimension of the overview layer is < minoverviewdim, up to a maximum level controlled by the levels parameter.

Uses gdal.Dataset.BuildOverviews() to do the work.

rios.calcstats.addStatistics(ds, progress, ignore=None, approx_ok=False)[source]

Calculates statistics and adds them to the image

Uses gdal.Band.ComputeStatistics() for mean, stddev, min and max, and gdal.Band.GetHistogram() to do histogram calculation. The median and mode are estimated using the histogram, and so for larger datatypes, they will be approximate only.

For thematic layers, the histogram is calculated with as many bins as required, for athematic integer and float types, a maximum of 256 bins is used.

rios.calcstats.calcStats(ds, progress=None, ignore=None, minoverviewdim=33, levels=[4, 8, 16, 32, 64, 128, 256, 512], aggregationType=None, approx_ok=False)[source]

Does both the stats and pyramid layers. Calls addPyramid() and addStatistics() functions. See their docstrings for details.

rios.calcstats.findOrCreateColumn(ratObj, usage, name, dtype)[source]

Returns the index of an existing column matched on usage. Creates it if not already existing using the supplied name and dtype Returns a tupe with index and a boolean specifying if it is a new column or not

rios.calcstats.progressFunc(value, string, userdata)[source]

Progress callback for BuildOverviews

rios.calcstats.setNullValue(ds, nullValue)[source]

Set the given null value on all bands of the given Dataset