This module contains the ReaderInfo class which holds information about the area being read and info on the current block

class rios.readerinfo.AttributeTableCache[source]

Allows attribute columns to be cached. This means that an attribute column can be requested for each block through the image, but the actual column data will only be read the first time and cached for subsequent calls.

getColumn(fname, band, colName)[source]

Returns the column if previously cached, otherwise None.

setColumn(fname, band, colName, column)[source]

Puts the column into the cache

class rios.readerinfo.ReaderInfo(workingGrid, statscache, ratcache, windowxsize, windowysize, overlap, loggingstream)[source]

ReaderInfo class. Holds information about the area being read and info on the current block

getAttributeColumn(block, colName, band=1)[source]

Gets the attribute for the given block and column name Caches columns so only first call actually extracts data


Return a tuple of the world coordinates for every pixel in the current block. Each array has the same shape as the current block. Return value is a tuple:

(xBlock, yBlock)

where the values in xBlock are the X coordinates of the centre of each pixel, and similarly for yBlock.

The coordinates returned are for the pixel centres. This is slightly inconsistent with usual GDAL usage, but more likely to be what one wants.


Gets the count of the current block


Get the size of the current block. Returns a tuple:

(numCols, numRows)

for the current block. Mostly the same as the window size, except on the edge of the raster.


Get the input filename of a dataset

getGDALBandFor(block, band)[source]

Get the underlying GDAL handle for a band of a dataset


Get the underlying GDAL handle of a dataset

getNoDataValueFor(block, band=1)[source]

Returns the ‘no data’ value for the dataset underlying the block. This should be the same as what was set for the stats ignore value when that dataset was created. The value is cast to the same data type as the dataset.


Returns the size of the pixel overlap between each window. This is the number of pixels added as margin around each block


Returns the percent complete.

getPixColRow(x, y)[source]

This function is for internal use only. The user should be looking at getBlockCoordArrays() or getPixRowColBlock() for dealing with blocks and coordinates.

Get the (col, row) relative to the current image grid, for the nominated pixel within the current block. The given (x, y) are column/row numbers (starting at zero), and the return is a tuple:

(column, row)

where these are relative to the whole of the current working grid. If working with a single raster, this is the same as for that raster, but if working with multiple rasters, the working grid is the intersection or union of them.

Note that this function will give incorrect/misleading results if used in conjunction with a block overlap.

getPixRowColBlock(x, y)[source]

Return the row/column numbers, within the current block, for the pixel which contains the given (x, y) coordinate. The coordinates of (x, y) are in the world coordinate system of the reference grid. The row/col numbers are suitable to use as array indices in the array(s) for the current block. If the nominated pixel is not contained within the current block, the row and column numbers are both None (hence this should be checked).

Return value is a tuple of 2 int values
(row, col)

Gets the current pixel size and returns it as a tuple (x and y)


Return the WKT describing the current projection system


Returns the total number of blocks the dataset has been split up into for processing


Returns the total size (in pixels) of the dataset being processed


Return the current transform between world and pixel coords. This is as defined by GDAL.


Returns the size of the current window. Returns a tuple (numCols, numRows)

global_max(block, band=1, ignore=None)[source]

Returns the max for the whole band

global_mean(block, band=1, ignore=None)[source]

Returns the mean for the whole band

global_min(block, band=1, ignore=None)[source]

Returns the min for the whole band

global_stats(block, band=1, ignore=None)[source]

Returns the (min,max,mean,stddev) for the whole band

global_stddev(block, band=1, ignore=None)[source]

Returns the stddev for the whole band


Returns True if this is the first block to be processed


Returns True if this is the last block to be processed

setBlockBounds(blocktl, blockbr)[source]

Sets the coordinate bounds of the current block

This routine is for internal use by RIOS. Its use in any other context is not sensible.

setBlockCount(xblock, yblock)[source]

Sets the count of the current block

This routine is for internal use by RIOS. Its use in any other context is not sensible.

setBlockDataset(block, dataset, filename)[source]

Saves a match between the numpy block read and it’s GDAL dataset. So we can look up the dataset later given a block.

This routine is for internal use by RIOS. Its use in any other context is not sensible.

setBlockSize(blockwidth, blockheight)[source]

Sets the size of the current block

This routine is for internal use by RIOS. Its use in any other context is not sensible.

class rios.readerinfo.StatisticsCache[source]

Allows global statistics for all the files used to be cached Statistics are stored here associated with the filename so if there are multiple calls to global_stats for one file the statistics will only get calculated once.

getStats(fname, band, ignore)[source]

Returns tuple with (min,max,mean,stddev) if previously cached, None otherwise.

setStats(fname, band, ignore, stats)[source]

Sets tuple with (min,max,mean,stddev) in cache