viewerlayers

this module contains the LayerManager and related classes

class tuiview.viewerlayers.OverviewInfo(xsize, ysize, fullrespixperpix, index)[source]

Stores size and index of an overview

class tuiview.viewerlayers.OverviewManager[source]

This class contains a list of valid overviews and allows the best overview to be retrieved

findBestOverview(imgpixperwinpix)[source]

Finds the best overview for given imgpixperwinpix

getFullRes()[source]

Get the full res overview - ie the non overview image

loadOverviewInfo(ds, bands)[source]

Load the overviews from the GDAL dataset into a list bands should be a list or tuple of band indices. Checks are made that all lists bands contain the same sized overviews

class tuiview.viewerlayers.PropertyInfo[source]

Container for Info for proerties window

addBandInfo(bandName, infoList)[source]

sets info for a band

addFileInfo(name, value)[source]

Add a file info

addHistogramInfo(bandName, histInfo)[source]

sets histogram info for a band. Should be a tuple of min, max, data

getDatum()[source]
getProjection()[source]
getSpheroid()[source]
getUTMZone()[source]
getUnits()[source]
getWKT()[source]
setSR(sr)[source]

set spatial reference

class tuiview.viewerlayers.ViewerFeatureVectorLayer[source]

A vector Feature layer. Same as ViewerVectorLayer but works with a single feature provided by the driving program.

getImage()[source]

Updates self.image with the outlines of the vector feature in the current color

getSQL()[source]
hasSQL()[source]
open(ogrDataSource, ogrLayer, ogrFeature, width, height, extent=None, color=(255, 255, 0, 255))[source]

Set Data source, plus first feature to rasterize

setFeature(ogrFeature)[source]

Update feature to draw

setSQL(sql=None)[source]

unlike the base class we don’t support SQL

toFile(fileobj)[source]

This doesn’t make sense since the ogrDataSource etc is owned by the driving program so we can’t recreate it

class tuiview.viewerlayers.ViewerLayer[source]

Base class for a type of layer

fromFile(fileobj, width, height)[source]

Initialise this instance of the class with information from json in fileobj

getImage()[source]

return a QImage with the data in it

getPropertiesInfo()[source]

Return the properties as a PropertyInfo instance we can show the user

toFile(fileobj)[source]

write information to re-create layer as JSON

class tuiview.viewerlayers.ViewerQueryPointLayer[source]

Class for display of query points.

getImage()[source]

Update self.image

removeQueryPoint(senderid)[source]

remove a query point based on the id() of the requesting object

setQueryPoint(senderid, easting, northing, color, size=None, cursor=None)[source]

Add/replace a query point based on the id() of the requesting object

class tuiview.viewerlayers.ViewerRasterLayer(layermanager)[source]

Represents a raster layer

changeUpdateAccess(update)[source]

Re-opens the GDAL dataset in the new update mode (True for update False for readonly)

deleteStretchFromFile()[source]

deletes the stretch and current LUT from the file

exportStretchandLUTToText(fname)[source]

Exports the current stretch and lookup table to a JSON formatted text file

fromFile(fileobj, width, height)[source]

Reads information (written by toFile) and builds a layer assumes that the ‘type’ line has already been read.

getBandNames()[source]

Return the list of band names

getImage()[source]

Refresh the ‘image’ which is a QImage instance used for rendering. Does the selection of overview, choosing of area (based on coordmgr) reading, and applying LUT.

getNoDataValues()[source]

Return a list of no data values - one for each band

getPropertiesInfo()[source]

Get the properties of the file as a PropertyInfo for presentation to user. Do something similar to gdalinfo.

getWavelengths()[source]

Return the list of wavelength if file they conform to the expected format for the driver (provided by getWavelengthsMetaFormat).

getWavelengthsMetaFormat()[source]

Get the format used to store wavelenths in the metadata.

Note, currently just returns ENVI for all drivers. This can be used for ENVI files and files converted from ENVI format, which retain the same metadata format.

highlightRows(color, selectionArray=None)[source]

Highlight selected rows in the LUT

open(gdalDataset, width, height, stretch, lut=None)[source]

Open a filename as a raster layer. width and height is the display size. stretch is the ViewerStretch instance to use. if specified, the lut is used to display the data, otherwise calculated from the stretch Keeps a reference to gdalDataset Assumes gdalDataset opened in read only mode.

saveStretchToFile(stretch)[source]

Saves the given stretch and current LUT to the file

setColorTableLookup(lookupArray=None, colName=None, surrogateLUT=None, surrogateName=None)[source]

Use array as a lookup to color table

setNewStretch(newstretch, local=False)[source]

Set the new stretch

toFile(fileobj)[source]

Write all the information needed to re-open this layer

writeRATColumnOrder()[source]

calls self.attributes.writeColumnOrderToGDAL. Assumes file upen in update mode - raises exception otherwise

class tuiview.viewerlayers.ViewerVectorLayer[source]

A vector layer. Uses vectorrasterizer to burn in the outlines

fromFile(fileobj, width, height)[source]

Initialise this instance of the class with information from json in fileobj

getAttributesAtPoint(easting, northing, tolerance=0)[source]

Returns a list of attributes for the point centred on (easting, northing). If tolerance is specified a box will will be drawn centred at (easting, northing) and size tolerance. Each item in the list contains a dictionary keyed on the attribute name and the value will be the attribute value as a string.

getColorAsRGBATuple()[source]
getFill()[source]

returns True if polygons are being filled

getImage()[source]

Updates self.image with the outlines of the vector in the current color

getLineWidth()[source]
getPropertiesInfo()[source]

Return the properties as a PropertyInfo we can show the user

getSQL()[source]
hasSQL()[source]

returns True if there is an attribute filter in place

open(ogrDataSource, ogrLayer, width, height, extent=None, color=(255, 255, 0, 255), resultSet=False, origSQL=None)[source]

Use the supplied datasource and layer for accessing vector data keeps a reference to the datasource and layer If resultSet is True then ogrDataSource.ReleaseResultSet is called on destruction. If resultSet is True then origSQL should be passed so layer can be recreated if saved as json

setColor(color)[source]

Sets up the LUT to use the specified color

setFill(bFill)[source]

Sets if the polygons are filled or not

setLineWidth(linewidth)[source]

sets the line width

setSQL(sql=None)[source]

sets the sql attribute filter

toFile(fileobj)[source]

write information to re-create layer as JSON

updateColor(color)[source]

Like setColor, but also updates the stored self.image to be in the new color

tuiview.viewerlayers.GDALTypeToNumpyType(gdaltype)[source]

Given a gdal data type returns the matching numpy data type

tuiview.viewerlayers.NumpyTypeToGDALType(numpytype)[source]

For a given numpy data type returns the matching GDAL data type

tuiview.viewerlayers.replicateArray(arr, outarr, dspLeftExtra, dspTopExtra, dspRightExtra, dspBottomExtra)[source]

Replicate the data in the given 2-d array so that it increases in size to be (ysize, xsize).

Replicates each pixel in both directions.

dspLeftExtra, dspTopExtra are the number of pixels to be shaved off the top and left. dspRightExtra, dspBottomExtra are the number of pixels to be shaved off the bottom and right of the result. This allows us to display fractional pixels.