urclib.ui_qt.visualizer.ogrglscene

Scene compatible with gdal/ogr data.

Module Contents

Classes

OGRGLScene

Subclass of GAIAGLScene that adds support for directly loading data from OGR.

class urclib.ui_qt.visualizer.ogrglscene.OGRGLScene(*args, **kwargs)

Bases: urclib.ui_qt.visualizer.geometryglscene.GeometryGLScene

Subclass of GAIAGLScene that adds support for directly loading data from OGR.

Parameters:
  • widget (object,optional) – The parent object that will manage the OpenGL context for the hosting UI framework.

  • refreshkey (str,optional) – Name of function to call from widget whenever the draw state changes.

  • getextKey (str,optional) – Name of function to call from widget whenever draw extents are needed.

initializeGL()

Initializes the OpenGL subsystem. This will need to be called before any rendering can take place.

PolyLayerFromOgrLyr(lyr, **kwargs)

Import Geometry from a previously loaded polygon ogr_layer.

Parameters:

lyr (ogr.Layer) – Layer containing the geometry to import.

Returns:

The new ogr_layer id, and the total number of polygons imported.

Return type:

int,int

PointLayerFromOgrLyr(lyr, **kwargs)

Import Geometry from a previously loaded point ogr_layer.

Parameters:

lyr (ogr.Layer) – Layer containing the geometry to import.

Returns:

The new ogr_layer id, and the total number of points imported.

Return type:

int,int

LineLayerFromOgrLyr(lyr, **kwargs)

Import Geometry from a previously loaded line ogr_layer.

Parameters:

lyr (ogr.Layer) – Layer containing the geometry to import.

Returns:

The new ogr_layer id, and the total number of points imported.

Return type:

int,int

_getLabellingArgs(kwargs)

Separate out dlg_label specific keyword arguments from a general argument dict.

Parameters:

kwargs (dict) – The keyword arguments to parse.

Returns:

Keyword arguments suitable for passing to self.AddTextLayer().

Return type:

dict

static _readBand(h, w, band)
RasterColorBand(h, w, ds)

Retrieve RGBA color bands for the image.

Parameters:
  • h (int) – The height of the image, in pixels.

  • w (int) – The width of the image, in pixels.

  • ds (osgeo.gdal.Dataset) – The Dataset with the image data to retrieve.

Returns:

The image data divided into RGBA channels; shape is (h,`w`,4).

Return type:

numpy.ndarray

RasterGrayBand(h, w, ds)

Retrieve the grayscale band for the image.

Parameters:
  • h (int) – The height of the image, in pixels.

  • w (int) – The width of the image, in pixels.

  • ds (osgeo.gdal.Dataset) – The Dataset with the image data to retrieve.

Returns:

The image grayscale band; shape is (h,`w`).

Return type:

numpy.ndarray

_rasterLayerFromGdalLyr(ds)

Retrieve raster data from a GDAL dataset.

Parameters:

ds (osgeo.gdal.Dataset) – The dataset to extract the raster from.

Returns:

numpy.ndarray the data composing the image, and a list of the geospatial extents.

Return type:

tuple

RasterImageLayerFromGdalLyr(ds)

Create an image raster layer from a GDAL raster layer.

Parameters:

ds (osgeo.gdal.Dataset) – the Dataset containing the raster to load.

Returns:

The id of the newly created layer.

Return type:

int

RasterIndexLayerFromGdalLyr(ds, gradObj=GradientRecord())

Create an indexed value raster layer from a GDAL raster layer.

Parameters:
  • ds (osgeo.gdal.Dataset) – the Dataset containing the raster to load.

  • gradObj (GradientRecord,optional) – Custom gradient to assign, if any.

Returns:

The id of the newly created layer.

Return type:

int

OpenPolyLayer(path, **kwargs)

Import polygon data from a file using OGR to interpret.

Parameters:

path (str) – Path to the file to load.

Returns:

The total number of polygons imported.

Return type:

int

OpenPtLayer(path, **kwargs)

Import point data from a file using OGR to interpret.

Parameters:

path (str) – Path to the file to load.

Returns:

The total number of points imported.

Return type:

int

OpenLineLayer(path, **kwargs)

Import line data from a file using OGR to interpret.

Parameters:

path (str) – Path to the file to load.

Returns:

The total number of lines imported.

Return type:

int

OpenRasterImageLayer(path)

Load a raster image layer from a file supported by GDAL.

Parameters:

path (str) – Path to the file to load.

Returns:

the id of the newly created layer.

Return type:

int

OpenRasterIndexLayer(path, gradObj=GradientRecord())

Load an index value raster layer from a file supported by GDAL.

Parameters:
  • path (str) – Path to the file to load.

  • gradObj (GradientRecord,optional) – Custom gradient to assign, if any.

Returns:

the id of the newly created layer.

Return type:

int

GetSelectedFIDs(lyrId)

Retrieve FIDs for any selected features in a layer.

Parameters:

lyrId (int) – Id of layer to query.

Returns:

indices of any features that are selected within the layer.

Return type:

set

DeleteLayer(id)

Remove a layer from the scene.

Parameters:

id (int) – Id of the layer to remove.

ClearPolyLayers()

Remove all polygon layers.

ClearPointLayers()

Remove all point layers.

ClearLineLayers()

Remove all line layers.

ClearAllLayers()

Remove all layers

ReprojectLayer(id, toSRef)

Reproject a given layer to another SRS.

Parameters:
  • id (int) – The layer to transform.

  • toSRef (osgeo.osr.SpatialReference) – The SRS to reproject into.