hubdc.core

class hubdc.core.Column(x, z)[source]

Bases: object

Class for managing image column location.

x()[source]

Returns column x coordinate.

z()[source]

Returns column z coordinate.

class hubdc.core.ENVI[source]

Bases: object

SPATIAL_KEYS = ['lines', 'samples', 'map info', 'projection info', 'coordinate system string']
static findHeader(filenameBinary, ext='.hdr')[source]
classmethod gdalType(enviType)[source]
static numpyType(enviType)[source]
static readHeader(filenameHeader)[source]
static typeSize(enviType)[source]
classmethod writeAttributeTable(filename, table)[source]

Write attribute table values to csv file next to the given binary file.

static writeHeader(filenameHeader, metadata)[source]
class hubdc.core.ESRIShapefileDriver[source]

Bases: hubdc.core.VectorDriver

ESRI Shapefile driver.

class hubdc.core.EnviDriver[source]

Bases: hubdc.core.RasterDriver

ENVI driver.

class Option[source]

Bases: object

class INTERLEAVE[source]

Bases: object

BIL = 'INTERLEAVE=BIL'
BIP = 'INTERLEAVE=BIP'
BSQ = 'INTERLEAVE=BSQ'
class SUFFIX[source]

Bases: object

ADD = 'SUFFIX=ADD'
REPLACE = 'SUFFIX=REPLACE'
class hubdc.core.ErdasDriver[source]

Bases: hubdc.core.RasterDriver

Erdas Imagine driver.

class hubdc.core.Extent(xmin, xmax, ymin, ymax, projection)[source]

Bases: object

Class for managing extents (i.e. bounding boxes).

buffer(buffer: float, left=True, right=True, up=True, down=True) → hubdc.core.Extent[source]

Returns a new instance with a buffer applied in different directions.

centroid()[source]

Returns the centroid.

equal(other, tol=1e-05)[source]

Returns wether self is equal to other.

static fromGeometry(geometry)[source]

Create an extent from the bounding box a Geometry.

geometry()[source]

Returns self as a Geometry.

intersection(other)[source]

Returns a new instance which is the intersection of self and other in the projection of self.

intersects(other)[source]

Returns whether self and other intersects.

lowerLeft()[source]

Returns the lower left corner.

lowerRight()[source]

Returns the lower right corner.

projection()[source]

Returns the Projection.

reproject(projection)[source]

Reproject self into the given projection.

union(other)[source]

Returns a new instance which is the union of self with other in the projection of self.

upperLeft()[source]

Returns the upper left corner.

upperRight()[source]

Returns the upper right corner.

xmax()[source]

Returns the xmax.

xmin()[source]

Returns the xmin.

ymax()[source]

Returns the ymax.

ymin()[source]

Returns the ymin.

class hubdc.core.Feature(ogrFeature, projection=None)[source]

Bases: object

geometry()[source]
ogrFeature() → <Mock name='mock.ogr.Feature' id='140289914469200'>[source]
projection()[source]
value(attribute)[source]
class hubdc.core.GTiffDriver[source]

Bases: hubdc.core.RasterDriver

GTiff driver.

class Option[source]

Bases: object

class ALPHA[source]

Bases: object

NON_PREMULTIPLIED = 'ALPHA=NON-PREMULTIPLIED'
PREMULTIPLIED = 'ALPHA=PREMULTIPLIED'
UNSPECIFIED = 'ALPHA=UNSPECIFIED'
YES = 'ALPHA=YES'
class BIGTIFF[source]

Bases: object

IF_NEEDED = 'BIGTIFF=IF_NEEDED'
IF_SAFER = 'BIGTIFF=IF_SAFER'
NO = 'BIGTIFF=NO'
YES = 'BIGTIFF=YES'
static BLOCKXSIZE(n=256)[source]
static BLOCKYSIZE(n=256)[source]
class COMPRESS[source]

Bases: object

CCITTFAX3 = 'COMPRESS=CCITTFAX3'
CCITTFAX4 = 'COMPRESS=CCITTFAX4'
CCITTRLE = 'COMPRESS=CCITTRLE'
DEFLATE = 'COMPRESS=PACKBITS'
JPEG = 'COMPRESS=JPEG'
LERC = 'COMPRESS=LERC'
LERC_DEFLATE = 'COMPRESS=LERC_DEFLATE'
LERC_ZSTD = 'COMPRESS=LERC_ZSTD'
LZMA = 'COMPRESS=LZMA'
LZW = 'COMPRESS=LZW'
NONE = 'COMPRESS=NONE'
PACKBITS = 'COMPRESS=JPEG'
WEBP = 'COMPRESS=WEBP'
ZSTD = 'COMPRESS=ZSTD'
class COPY_SRC_OVERVIEWS[source]

Bases: object

NO = 'COPY_SRC_OVERVIEWS=NO'
YES = 'COPY_SRC_OVERVIEWS=YES'
class GEOTIFF_KEYS_FLAVOR[source]

Bases: object

ESRI_PE = 'GEOTIFF_KEYS_FLAVOR=ESRI_PE'
STANDARD = 'GEOTIFF_KEYS_FLAVOR=STANDARD'
class INTERLEAVE[source]

Bases: object

BAND = 'INTERLEAVE=BAND'
PIXEL = 'INTERLEAVE=PIXEL'
static JPEG_QUALITY(n=75)[source]
static MAX_Z_ERROR(threshold=0)[source]
static NBITS(n)[source]
static NUM_THREADS(n='ALL_CPUS')[source]
class PHOTOMETRIC[source]

Bases: object

CIELAB = 'PHOTOMETRIC=CIELAB'
CMYK = 'PHOTOMETRIC=CMYK'
ICCLAB = 'PHOTOMETRIC=ICCLAB'
ITULAB = 'PHOTOMETRIC=ITULAB'
MINISBLACK = 'PHOTOMETRIC=MINISBLACK'
MINISWHITE = 'PHOTOMETRIC=MINISWHITE'
RGB = 'PHOTOMETRIC=RGB'
YCBCR = 'PHOTOMETRIC=YCBCR'
class PIXELTYPE[source]

Bases: object

DEFAULT = 'PIXELTYPE=DEFAULT'
SIGNEDBYTE = 'PIXELTYPE=SIGNEDBYTE'
class PREDICTOR[source]

Bases: object

FloatingPoint = 'PREDICTOR=3'
HorizontalDifferencing = 'PREDICTOR=2'
NONE = 'PREDICTOR=1'
class PROFILE[source]

Bases: object

BASELINE = 'PROFILE=BASELINE'
GDALGeoTIFF = 'PROFILE=GDALGeoTIFF'
GeoTIFF = 'PROFILE=GeoTIFF'
class SPARSE_OK[source]

Bases: object

FALSE = 'SPARSE_OK=FALSE'
TRUE = 'SPARSE_OK=TRUE'
class TILED[source]

Bases: object

NO = 'TILED=NO'
YES = 'TILED=YES'
static WEBP_LEVEL(n=75)[source]
class WEBP_LOSSLESS[source]

Bases: object

FALSE = 'WEBP_LOSSLESS=FALSE'
TRUE = 'WEBP_LOSSLESS=TRUE'
static ZLEVEL(n=6)[source]
static ZSTD_LEVEL(n=9)[source]
class hubdc.core.GeoPackageDriver[source]

Bases: hubdc.core.VectorDriver

ESRI Shapefile driver.

class hubdc.core.Geometry(wkt, projection)[source]

Bases: object

Class for managing geometries.

intersection(other)[source]

Returns the intersection of self and other.

intersects(other)[source]

Returns whether self and other intersect.

ogrGeometry() → <Mock name='mock.ogr.Geometry' id='140289912901968'>[source]

Returns ogr.Geometry object.

projection()[source]

Returns the Projection.

reproject(projection)[source]

Reproject self into given projection.

typeName() → str[source]

Return the geometry type name.

union(other)[source]

Returns the union of self and other.

within(other)[source]

Returns whether self is within other.

wkt()[source]

Returns well known text string.

class hubdc.core.Grid(extent, resolution)[source]

Bases: object

Class for managing raster grids in terms of extent, resolution and projection.

anchor(point)[source]

Returns a new instance that is anchored to the given point. Anchoring will result in a subpixel shift. See the source code for implementation details.

atResolution(resolution)[source]

Return grid with same extent and projection, but new resolution.

clip(extent)[source]

Return self clipped by given extent.

equal(other, tol=1e-05)[source]

Returns whether self is equal to other.

extent()[source]

Returns the Extent.

geoTransform()[source]

Returns a GDAL georeferencing transform tuple (xmin, xres, 0, ymax, 0, -yres) from bounds and resolution, without any rotation or shearing.

pixelBuffer(buffer, left=True, right=True, up=True, down=True)[source]

Returns a new instance with a pixel buffer applied in different directions.

Parameters:
  • buffer (int) – number of pixels to be buffered (can also be negativ)
  • left (bool) – whether to buffer to the left/west
  • right (bool) – whether to buffer to the right/east
  • up (bool) – whether to buffer upwards/north
  • down (bool) – whether to buffer downwards/south
Returns:

Return type:

hubdc.core.Grid

pixelCoordinate(point: hubdc.core.Point) → hubdc.core.Pixel[source]

Return pixel coordinate for given point.

projection()[source]

Returns the Projection.

reproject_OLD(other)[source]

Returns a new instance with: a) extent reprojected into the projection of other, b) resolution of other, and c) anchored to other.

resolution()[source]

Returns the Resolution.

shape()[source]

Returns size as (ysize, xsize) tuple.

size()[source]

Returns the Size.

subgrids(size)[source]

Returns the decomposition of self into subgrids of given size. Subgrids at the border are trimmed to the extent of self.

subset(offset, size, trim=False)[source]

Returns a new instance that is a subset given by an offset location and a raster size. Optionally set trim=True to restrain the grid extent to the extent of self.

xMapCoordinates()[source]

Returns the list of map coordinates in x dimension.

xMapCoordinatesArray()[source]

Returns the 2d array of map x coordinates.

xPixelCoordinates(offset=0)[source]

Returns the list of pixel coordinates in x dimension with optional offset.

xPixelCoordinatesArray(offset=0)[source]

Returns the 2d array of pixel x coordinates with optional offset.

yMapCoordinates()[source]

Returns the list of map coordinates in y dimension.

yMapCoordinatesArray()[source]

Returns the 2d array of map y coordinates.

yPixelCoordinates(offset=0)[source]

Returns the list of pixel coordinates in y dimension with optional offset.

yPixelCoordinatesArray(offset=0)[source]

Returns the 2d array of pixel y coordinates with optional offset.

class hubdc.core.MapViewer[source]

Bases: object

addLayer(layer)[source]
extent()[source]
onKeyPressed(e)[source]
projection()[source]
resize(xsize=None, ysize=None)[source]
save(filename)[source]
setExtent(extent)[source]
setProjection(projection)[source]
show(size=None)[source]
class hubdc.core.MemDriver[source]

Bases: hubdc.core.RasterDriver

MEM driver.

class hubdc.core.MemoryDriver[source]

Bases: hubdc.core.VectorDriver

Memory driver.

class hubdc.core.MetadataFormatter[source]

Bases: object

Class for managing GDAL metadata value formatting.

classmethod stringToValue(string, dtype)[source]

Returns a representation of string as value of given dtype. If string represents a list of values in curly brackets (e.g. {1, 2, 3}), a list of values is returned.

classmethod valueToString(value)[source]

Returns a string representation of value.

class hubdc.core.Pixel(x, y)[source]

Bases: object

Class for managing image pixel location.

static parse(obj)[source]

Create instance from given Pixel or (number, number) object.

x()[source]

Returns pixel x coordinate.

y()[source]

Returns pixel y coordinate.

class hubdc.core.Point(x, y, projection)[source]

Bases: hubdc.core.Geometry

Class for managing map locations.

projection()[source]

Returns the Projection.

reproject(projection)[source]

Reproject self into given projection.

x()[source]

Returns map x coordinate.

y()[source]

Returns map y coordinate.

class hubdc.core.Projection(wkt)[source]

Bases: object

Class for managing projections.

equal(other)[source]

Returns whether self is equal to other.

static fromEpsg(epsg)[source]

Create by given epsg authority ID.

osrSpatialReference()[source]

Returns osr.SpatialReference object.

classmethod utm(zone, north=True)[source]

Create UTM projection of given zone.

static wgs84()[source]

Create WGS84 projection (epsg=4326), also see http://spatialreference.org/ref/epsg/wgs-84/

static wgs84WebMercator()[source]

Create WGS84 Web Mercator projection (epsg=3857), also see http://spatialreference.org/ref/sr-org/7483/

wkt()[source]

Returns the well known text string.

class hubdc.core.PseudoGrid(size)[source]

Bases: hubdc.core.Grid

static fromArray(array)[source]
class hubdc.core.RasterBandDataset(raster, index)[source]

Bases: object

Class for managing raster band datasets.

array(grid=None, resampleAlg=<Mock name='mock.gdal.GRA_NearestNeighbour' id='140289912904016'>, noDataValue=None, errorThreshold=0.0, warpMemoryLimit=104857600, multithread=False)[source]

Returns raster band data as 2d array of shape = (ysize, xsize) for the given grid, where zsize is the number of raster bands, and ysize, xsize = grid.shape().

Parameters:
  • grid (hubdc.core.Grid) – if not specified self.grid() is used
  • resampleAlg (int) – one of the GDAL resampling algorithms gdal.GRA_*
  • noDataValue (float) – if not specified, no data value of self is used
  • errorThreshold (float) – error threshold for approximation transformer (in pixels)
  • warpMemoryLimit (int) – size of working buffer in bytes
  • multithread (bool) – whether to multithread computation and I/O operations
Returns:

Return type:

numpy.ndarray

categoryColors()[source]

Returns band category colors as list of rgba tuples.

categoryNames()[source]

Returns band category names.

copyMetadata(other)[source]

Copy raster and raster band metadata from self to other

description()[source]

Returns band description.

fill(value)[source]

Write constant value to the whole raster band.

flushCache()[source]

Flush the cache.

gdalBand()[source]

Return the gdal.Band.

index()[source]

Returns the raster band index.

mapLayer()[source]
mapViewer()[source]
metadataDict()[source]

Return the metadata dictionary for all domains.

metadataDomain(domain='')[source]

Return the metadata dictionary for the given domain.

metadataDomainList()[source]

Returns the list of metadata domain names.

metadataItem(key, domain='', default=None, required=False, dtype=<class 'str'>)[source]

Return the metadata item.

noDataValue(default=None, required=False)[source]

Returns band no data value. Returns default if no data value is undefined, or raises an error if required.

raster()[source]

Returns the RasterDataset.

readAsArray(grid=None, resample_alg=<Mock name='mock.gdal.GRA_NearestNeighbour' id='140289912904016'>)[source]

Returns raster band data as 2d array.

Parameters:
  • grid (hubdc.core.Grid) – if provided, only data inside the grid extent is returned.
  • resampleAlg (int) – one of the GDAL resampling algorithms (i.e. gdal.GRA_*)
Returns:

Return type:

numpy.ndarray

setCategoryColors(colors)[source]

Set band category colors from list of rgba tuples.

setCategoryNames(names)[source]

Set band category names.

setDescription(value)[source]

Set band description.

setMetadataItem(key, value, domain='')[source]

Set a metadata item. value can be a string, a number or a list of strings or numbers.

setNoDataValue(value)[source]

Set no data value.

writeArray(array, grid=None)[source]

Writes raster data.

Parameters:
  • array (3d array | list of 2d arrays) –
  • grid (hubdc.core.Grid) – if provided, data is written to the location given by the grid extent
xprofile(y)[source]

Returns raster data as 1d array for the given row y.

yprofile(x)[source]

Returns raster data as 1d array for the given column x.

class hubdc.core.RasterDataset(gdalDataset)[source]

Bases: object

Class for managing raster datasets files.

acquisitionTime()[source]

Returns the acquisition time. Restore it from ‘acquisition time’ metadata item inside the ‘ENVI’ domain.

Returns:
Return type:datetime.datetime
array(indices=None, grid=None, resampleAlg=<Mock name='mock.gdal.GRA_NearestNeighbour' id='140289912904016'>, noDataValue=None, forceWarp=True, errorThreshold=0.0, warpMemoryLimit=104857600, multithread=False)[source]

Returns raster data as 3d array of shape = (zsize, ysize, xsize) for the given grid, where zsize is the number of raster bands, and ysize, xsize = grid.shape().

Parameters:
  • indices (list) – band indices to read (default is all bands)
  • grid (hubdc.core.Grid) – if not specified self.grid() is used
  • resampleAlg (int) – one of the GDAL resampling algorithms gdal.GRA_*
  • noDataValue (float) – if not specified, no data value of self is used
  • errorThreshold (float) – error threshold for approximation transformer (in pixels)
  • warpMemoryLimit (int) – size of working buffer in bytes
  • multithread (bool) – whether to multithread computation and I/O operations
Returns:

Return type:

numpy.ndarray

band(index)[source]

Return the RasterBandDataset given by index.

bands()[source]

Returns an iterator over each RasterBandDataset.

close()[source]

Close the gdal.Dataset.

copyCategories(other)[source]

Copy raster band category names and lookup tables.

copyMetadata(other)[source]

Copy raster and raster band metadata from other to self.

description()[source]

Returns the description.

driver()[source]

Return the Driver.

dtype()[source]

Returns the raster data type.

extent()[source]

Return the Extent.

filename()[source]

Return filename.

filenames()[source]

Return gdal dataset file list``

flushCache()[source]

Flush the cache.

static fromArray(array, grid=None, filename='', driver=None, options=None)[source]

Creates a new raster file with content, data type and number of bands given by array and with extent, resolution and projection given by grid.

Parameters:
Returns:

Return type:

hubdc.core.RasterDataset

gdalDataset()[source]

Return the gdal.Dataset.

gdalType()[source]

Returns the raster data type.

grid()[source]

Return the Grid.

mapLayer()[source]
metadataDict()[source]

Returns the metadata dictionary for all domains.

metadataDomain(domain='')[source]

Returns the metadata dictionary for the given domain.

metadataDomainList()[source]

Returns the list of metadata domain names.

metadataItem(key, domain='', dtype=<class 'str'>, required=False, default=None)[source]

Returns the value (casted to a specific dtype) of a metadata item.

noDataValue(default=None, required=False)[source]

Returns no data value. Returns default if all band no data values are undefined, or raises Raises an exception if not all bands share the same no data value.

If all bands are without a no data value, default is returned.

noDataValues(default=None, required=False)[source]

Returns band no data values. For bands without a no data value, default is returned, or if required is True, an error is raised

plotCategoryBand(index=0, noPlot=False, showPlot=True)[source]
plotMultibandColor(rgbindex=(0, 1, 2), rgbvmin=(None, None, None), rgbvmax=(None, None, None), rgbpmin=(None, None, None), rgbpmax=(None, None, None), noPlot=False, showPlot=True)[source]
plotSinglebandGrey(index=0, vmin=None, vmax=None, pmin=None, pmax=None, cmap='gray', noPlot=False, showPlot=True)[source]

cmap see https://matplotlib.org/examples/color/colormaps_reference.html https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imshow.html

plotXProfile(row, plotWidget=None, yscale=1.0, **kwargs)[source]
plotYProfile(column, plotWidget=None, yscale=1.0, **kwargs)[source]
plotZProfile(pixel, plotWidget=None, spectral=False, xscale=1.0, yscale=1.0, **kwargs)[source]
projection()[source]

Return the Projection.

readAsArray(grid=None, resampleAlg=<Mock name='mock.gdal.GRA_NearestNeighbour' id='140289912904016'>)[source]

Returns raster data as 3d array.

Parameters:
  • grid (hubdc.core.Grid) – if provided, only data inside the grid extent is returned
  • resampleAlg (int) – one of the GDAL resampling algorithms (i.e. gdal.GRA_*)
Returns:

Return type:

numpy.ndarray

reopen(eAccess=<Mock name='mock.gdal.GA_ReadOnly' id='140289912902992'>)[source]

Returns re-opened version of itself. Useful in cases where flushCache is not sufficient.

setAcquisitionTime(acquisitionTime)[source]

Set the acquisition time. Store it as ‘acquisition time’ metadata item inside the ‘ENVI’ domain.

Parameters:acquisitionTime (datetime.datetime) –
setDescription(value)[source]

Set the description.

setGrid(grid)[source]

Set the Grid.

setMetadataDict(metadataDict)[source]

Set the metadata dictionary

setMetadataDomain(metadataDomain, domain)[source]

Set the metadata domain

setMetadataItem(key, value, domain)[source]

Set a metadata item. value can be a string, a number or a list of strings or numbers.

setNoDataValue(value)[source]

Set a single no data value to all bands.

setNoDataValues(values)[source]

Set band no data values.

shape()[source]

Returns the (zsize, ysize, xsize) tuple.

translate(grid=None, filename='', driver=None, options=None, resampleAlg=None, **kwargs)[source]

Returns a new instance of self translated into the given grid (default is self.grid()).

Parameters:
Returns:

Return type:

hubdc.core.RasterDataset

warp(grid=None, filename='', driver=MemDriver(), options=None, resampleAlg=None, **kwargs)[source]

Returns a new instance of self warped into the given grid (default is self.grid()).

Parameters:
Returns:

Return type:

hubdc.core.RasterDataset

waveband(center)[source]

Return the RasterBandDataset given by center wavelenth in nanometers.

writeArray(array, grid=None)[source]

Writes raster data.

Parameters:
  • array (3d array | list of 2d arrays) –
  • grid (hubdc.core.Grid) – if provided, data is written to the location given by the grid extent
xprofile(row)[source]

Returns raster data as 1d array for the given row.

xsize()[source]

Returns raster x size in pixels.

yprofile(column)[source]

Returns raster data as 1d array for the given column.

ysize()[source]

Returns raster y size in pixels.

zprofile(pixel)[source]

Returns raster data as 1d array for the given pixel.

zsize()[source]

Returns raster z size in terms of number of raster bands.

class hubdc.core.RasterDriver(name, options=None)[source]

Bases: object

Class for managing raster drivers

create(grid, bands=1, gdalType=<Mock name='mock.gdal.GDT_Float32' id='140289904747856'>, filename='', options=None)[source]

Creates a new raster file with extent, resolution and projection given by grid.

Parameters:
  • grid (hubdc.core.Grid) –
  • bands (int) – number of raster bands
  • gdalType (int) – one of the gdal.GDT_* data types, or use gdal_array.NumericTypeCodeToGDALTypeCode
  • filename (str) – output filename
  • options (list) – raster creation options
Returns:

Return type:

hubdc.core.RasterDataset

equal(other)[source]

Returns whether self is equal to the other driver.

classmethod fromFilename(filename)[source]
gdalDriver()[source]

Returns the GDAL driver object.

name()[source]

Returns the driver name.

options()[source]

Returns default creation options.

prepareCreation(filename)[source]

Returns absolute filename and creates root folders if not existing.

setOptions(options=None)[source]

Set the default options.

class hubdc.core.RasterLayer(qgsRasterLayer)[source]

Bases: object

initMultiBandColorRenderer(redIndex=0, greenIndex=1, blueIndex=2, redMin=None, redMax=None, greenMin=None, greenMax=None, blueMin=None, blueMax=None, percent=2)[source]

Initialize a MultiBandColorRenderer for given band index.

initRendererFromQml(filename)[source]
initSingleBandGrayRenderer(grayIndex=0, grayMin=None, grayMax=None, percent=2)[source]

Initialize a SingleBandGrayRenderer.

initTrueColorRenderer(**kwargs)[source]
mapViewer()[source]
qgsLayer()[source]
show()[source]
class hubdc.core.RasterSize(x, y)[source]

Bases: object

Class for managing image sizes.

static parse(obj)[source]

Create instance by parsing the given RasterSize object, a (number, number) tuple or list

x()[source]

Returns the x size.

y()[source]

Returns the y size.

class hubdc.core.ResampleAlgHandler[source]

Bases: object

classmethod resampleAlgorithms()[source]
classmethod toString(resampleAlg)[source]

Return clear name of given resampleAlg.

classmethod translateResampleAlgorithms()[source]
classmethod warpResampleAlgorithms()[source]
class hubdc.core.Resolution(x, y)[source]

Bases: object

Class for managing pixel resolutions.

equal(other, tol=0.0)[source]

Returns whether self is equal to other.

static parse(obj)[source]

Create new instance from given Resolution object, number or (number, number) object.

x()[source]

Returns x resolution.

y()[source]

Returns y resolution.

class hubdc.core.Row(y, z)[source]

Bases: object

Class for managing image row location.

y()[source]

Returns row y coordinate.

z()[source]

Returns row z coordinate.

class hubdc.core.VectorDataset(ogrDataSource, layerNameOrIndex=0)[source]

Bases: object

Class for managing vector layer datasets.

attributeTable()[source]
close()[source]

Closes the ogr.DataSourse and ogr.Layer

createFidDataset(filename, fidName='_fid') → hubdc.core.VectorDataset[source]

Create a vector dataset with same features but only one FID attribute.

delete()[source]

Closes and deletes/unlinks itself from disk/memory.

driver()[source]

Return the Driver.

extent()[source]

Returns the Extent.

extractPixel(rasterDataset)[source]

Extracts all pixel profiles covert by self, together with all associated attribute.

Returns (rasterValues, vectorValues) tuple.

featureCount()[source]

Returns the number of features.

features()[source]
fieldCount()[source]

Returns the number of attribute fields.

fieldNames()[source]

Returns the attribute field names.

fieldTypeNames()[source]

Returns the attribute field data type names.

filename()[source]

Returns the filename.

static fromPoints(points, attributes=None, filename='', driver=MemoryDriver())[source]

Create instance from given points. Projection is taken from the first point.

static fromPolygons(geometries: List[hubdc.core.Geometry], filename='', driver=MemoryDriver())[source]

Create instance from given geometries. Projection and geometry type is taken from the first geometry.

geometryTypeName()[source]

Return the geometry type name.

grid(resolution)[source]

Returns grid with extent of self and given resolution.

layerNameOrIndex()[source]

Returns the layer name/index.

mapLayer()[source]
mapViewer()[source]
metadataDict()[source]

Returns the metadata dictionary for all domains.

metadataDomain(domain='')[source]

Returns the metadata dictionary for the given domain.

metadataDomainList()[source]

Returns the list of metadata domain names.

metadataItem(key, domain='', dtype=<class 'str'>, required=False, default=None)[source]

Returns the value (casted to a specific dtype) of a metadata item.

ogrDataSource()[source]

Returns the ogr.DataSource.

ogrLayer()[source]

Returns the ogr.Layer.

projection()[source]

Returns the Projection.

rasterize(grid, gdalType=<Mock name='mock.gdal.GDT_Float32' id='140289904747856'>, initValue=0, burnValue=1, burnAttribute=None, allTouched=False, filterSQL=None, noDataValue=None, filename='', driver=None, options=None)[source]

Returns a Raster that is the rasterization of self into the given grid as.

Parameters:
  • grid (hubdc.core.Grid) –
  • gdalType (int) – one of the GDAL data types gdal.GDT_*
  • initValue (int) – value to pre-initialize the output array
  • burnValue (int) – value to burn into the output array for all objects; exclusive with burnAttribute
  • burnAttribute (str) – identifies an attribute field on the features to be used for a burn-in value; exclusive with burnValue
  • allTouched (bool) – whether to enable that all pixels touched by lines or polygons will be updated, not just those on the line render path, or whose center point is within the polygon
  • filterSQL (str) – set an SQL WHERE clause which will be used to filter vector features
  • noDataValue (float) – output raster no data value
  • filename (str) – output filename
  • driver (hubdc.core.RasterDriver) –
  • options (list) – raster creation options
Returns:

Return type:

hubdc.core.RasterDataset

reproject(projection, filename='', driver=MemoryDriver(), **kwargs)[source]

Returns a reprojection of self into the given projection. Optional kwargs are passed to gdal.VectorTranslateOptions.

setMetadataDict(metadataDict)[source]

Set the metadata dictionary

setMetadataDomain(metadataDomain, domain)[source]

Set the metadata domain

setMetadataItem(key, value, domain='')[source]

Set a metadata item. value can be a string, a number or a list of strings or numbers.

setSpatialFilter(geometry: hubdc.core.Geometry)[source]
translate(filename='', driver=MemoryDriver(), **kwargs)[source]

Returns a translation of self. Optional kwargs are passed to gdal.VectorTranslateOptions.

unsetSpatialFilter()[source]
zsize()[source]

Returns number of layers (i.e. 1).

class hubdc.core.VectorDriver(name)[source]

Bases: object

Class for managing OGR Drivers

delete(filename)[source]

Delete/unlink file given by filename.

equal(other)[source]

Returns whether self is equal to the other driver.

classmethod fromFilename(filename)[source]
name()[source]

Returns the driver name.

ogrDriver() → <Mock name='mock.ogr.Driver' id='140289914495056'>[source]

Returns the OGR driver object.

prepareCreation(filename)[source]

Deletes filename if it already exist and creates subfolders if needed.

class hubdc.core.VectorLayer(qgsVectorLayer)[source]

Bases: object

mapViewer()[source]
qgsLayer()[source]
show()[source]
class hubdc.core.VrtDriver[source]

Bases: hubdc.core.RasterDriver

VRT driver.

hubdc.core.buildOverviews(filename, levels=None, minsize=1024, resampling='average')[source]

Build image overviews (a.k.a. image pyramid) for raster given by filename. If the list of overview levels is not specified, overviews are generated for levels of powers of 2 (i.e. levels=[2, 4, 8…]) up to the level where the size of the overview is smaller than minsize.

Parameters:
  • filename (str) – input filename
  • minsize (int) – defines the levels (powers of 2) in the case where levels is None
  • levels (Union[Tuple, List]) – list of overview levels
  • resampling (str) – one of those: 'average', 'gauss', 'cubic', 'cubicspline', 'lanczos', 'average_mp', 'average_magphase', 'mode'
hubdc.core.createVRTDataset(rasterDatasetsOrFilenames, filename='', **kwargs)[source]

Creates a virtual raster file (VRT) from raster datasets or filenames given by rastersOrFilenames.

Parameters:
  • filename (str) – output filename
  • rastersOrFilenames (Union[Tuple, List]) – list of filenames or rasters
  • kwargs – all additional keyword arguments are passed to gdal.BuildVRTOptions
Returns:

Return type:

hubdc.core.RasterDataset

hubdc.core.openRasterDataset(filename, eAccess=<Mock name='mock.gdal.GA_ReadOnly' id='140289912902992'>)[source]

Opens the raster given by filename.

Parameters:
  • filename (str) – input filename
  • eAccess (int) – access mode gdal.GA_ReadOnly or gdal.GA_Update
Returns:

Return type:

hubdc.core.RasterDataset

hubdc.core.openVectorDataset(filename, layerNameOrIndex=None, update=False) → hubdc.core.VectorDataset[source]

Opens the vector layer given by filename and layerNameOrIndex.

Parameters:
  • filename (str) – input filename
  • layerNameOrIndex (int | str) – layer index or name
  • update (bool) – whether to open in update mode
Returns:

Return type:

hubdc.core.VectorDataset