viewerlayers

this module contains the LayerManager and related classes

class tuiview.viewerlayers.LayerManager(*args: Any, **kwargs: Any)[source]

Class that manages a list of layers

newPercentSig

signal emitted when a new progress percent is reached

alias of int

topLayerChanged

signal emitted when top layer changed

alias of object

addLayer(layer)[source]

Add the given layer

addRasterLayer(gdalDataset, width, height, stretch, lut=None, ignoreProjectionMismatch=False, quiet=False)[source]

Add a new raster layer with given display width and height, stretch and optional lut.

addVectorFeatureLayer(ogrDataSource, ogrLayer, ogrFeature, width, height, color=(255, 255, 0, 255), quiet=False)[source]

Add a vector feature layer

addVectorLayer(ogrDataSource, ogrLayer, width, height, color=(255, 255, 0, 255), resultSet=False, origSQL=None, label=None, quiet=False)[source]

Add a vector layer. See ViewerVectorLayer.open for more info on params

endProgress()[source]

Called when a progress run has finished

fromFile(fileobj, nlayers, width, height)[source]

Tries to read the json out of fileobj and reconstruct all the layers

getFullExtent()[source]

Return the full extent for all the open layers

getTopDisplayedRasterLayer()[source]

Returns the top most raster layer (if there is one) otherwise None

getTopDisplayedVectorLayer()[source]

Returns the top most vector layer (if there is one) otherwise None

getTopLayer()[source]

Returns the very top layer which may be raster or vector

getTopRasterLayer()[source]

Returns the top most raster layer (if there is one) otherwise None

getTopVectorLayer()[source]

Returns the top most vector layer (if there is one) otherwise None

static isSameRasterProjection(layer1, layer2)[source]

Checks to see if 2 raster layers have the same projection

makeLayersConsistent(reflayer)[source]

Make all layers spatially consistent with reflayer

moveLayerDown(layer)[source]

Move the specified layer ‘down’ - ie render it later which is actually up the list

moveLayerToTop(layer)[source]

Move layer to the end of the list so it is rendererd last.

moveLayerUp(layer)[source]

Move the specified layer ‘up’ - ie render it later which is actually down the list

newPercent(percent)[source]

New progress value

newProgress(string)[source]

Called when we are about to start a new progress

recalcFullExtent()[source]

Internal method. Recalculates the full extent of all the layers. Called when dataset added or removed.

removeLayer(layer)[source]

Remove the specified layer

removeTopLayer()[source]

Removes the top layer

setDisplaySize(width, height)[source]

When window resized this updates all the layers

setDisplayedState(layer, state)[source]

Sets the displayed state for a layer use this rather than setting layer.displayed directly as title bar will be updated this way

setStretchAllLayers(stretch, local=False)[source]

Sets the stretch for all layers contained by the LayerManager.

timeseriesBackward()[source]

Assume images are a stacked timeseries oldest to newest. Turn on the previous one to the current topmost displayed

timeseriesForward()[source]

Assume images are a stacked timeseries oldest to newest. Turn off the current topmost displayed

toFile(fileobj)[source]

Save all the layers and info needed to re-create them to the fileobj as JSON.

updateImages()[source]

Tell each of the layers to get a new ‘image’ for rendering. This is called when extents have changed etc.

updateTopFilename()[source]

Call this when the top displayed layer may have changed and the correct signal will be emitted

zoomFullExtent()[source]

Zoom to the full extent of all the layers This might need a re-think for vectors.

zoomNativeResolution()[source]

Zoom to the native resolution of the top raster later

endProgressSig

signal emitted when progress is finished

layersChanged

signal emitted when layers have changed

newProgressSig = 'QString'

signal emitted when a new progress bar is needed

statusMessageSig = 'QString'

signal emitted with a new status message needs to be shown to the user

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

overviewsPresentInFile()[source]

return whether overviews are present. Call loadOverviewInfo first

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]

get the datum, if set

getProjection()[source]

get the projection, if set

getSpheroid()[source]

get spheroid, if set

getUTMZone()[source]

get the UTM zone, if set

getUnits()[source]

get the units, if set

getWKT()[source]

get the projection as a WKT

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]

unlike the base class we don’t support SQL

hasSQL()[source]

returns True if there is an attribute filter in place

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

toEastingNorthing(long, lat)[source]

Convert lat/long coord to easting in northing in this layer

toFile(fileobj)[source]

Write all the information needed to re-open this layer

toLatLong(easting, northing)[source]

Convert from northing as eastings to latlong

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.

getAvailableAttributes()[source]

Returns a list of available attributes

getColorAsRGBATuple()[source]

Returns the current color as a tuple

getFieldToLabel()[source]

get the field that is being used to label

getFill()[source]

returns True if polygons are being filled

getHalfCrossSize()[source]

get the half cross size (used for points)

getImage()[source]

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

getLabelColorAsRGBATuple()[source]

Returns the current label color as a tuple

getLineWidth()[source]

gets the current line width

getPropertiesInfo()[source]

Return the properties as a PropertyInfo we can show the user

getSQL()[source]

returns the SQL used for this layer

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, label=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

setFieldToLabel(field)[source]

set the field to label (None disables)

setFill(bFill)[source]

Sets if the polygons are filled or not

setHalfCrossSize(halfCrossSize)[source]

set the half cross size (used for points)

setLabelColor(color)[source]

Sets the labels as the specified colour (tuple)

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

updateLabelColor(color)[source]

Like setLabelColor, but also re-labels in the new color

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.

tuiview.viewerlayers.NOTSET_STRING = 'Not Set'

Returned when one of the property items not set on the file