RSGISLib Module¶
This namespace contains rsgislib Python bindings
Please be aware that the following variables have been defined to match enums within RSGISLib.
Data Types for images:
TYPE_UNDEFINED = 0
TYPE_8INT = 1
TYPE_16INT = 2
TYPE_32INT = 3
TYPE_64INT = 4
TYPE_8UINT = 5
TYPE_16UINT = 6
TYPE_32UINT = 7
TYPE_64UINT = 8
TYPE_32FLOAT = 9
TYPE_64FLOAT = 10
Methods for the Maximum Likelihood Classifier:
METHOD_SAMPLES = 0 # as calculated by ML
METHOD_AREA = 1 # priors set by the relative area
METHOD_EQUAL = 2 # priors all equal
METHOD_USERDEFINED = 3 # priors passed in to function
METHOD_WEIGHTED = 4 # priors by area but with a weight applied
Shape indexes used with RasterGIS:
SHAPE_SHAPENA = 0
SHAPE_SHAPEAREA = 1
SHAPE_ASYMMETRY = 2
SHAPE_BORDERINDEX = 3
SHAPE_BORDERLENGTH = 4
SHAPE_COMPACTNESS = 5
SHAPE_DENSITY = 6
SHAPE_ELLIPTICFIT = 7
SHAPE_LENGTH = 8
SHAPE_LENGTHWIDTH = 9
SHAPE_WIDTH = 10
SHAPE_MAINDIRECTION = 11
SHAPE_RADIUSLARGESTENCLOSEDELLIPSE = 12
SHAPE_RADIUSSMALLESTENCLOSEDELLIPSE = 13
SHAPE_RECTANGULARFIT = 14
SHAPE_ROUNDNESS = 15
SHAPE_SHAPEINDEX = 16
Methods of initialising KMEANS:
INITCLUSTER_RANDOM = 0
INITCLUSTER_DIAGONAL_FULL = 1
INITCLUSTER_DIAGONAL_STDDEV = 2
INITCLUSTER_DIAGONAL_FULL_ATTACH = 3
INITCLUSTER_DIAGONAL_STDDEV_ATTACH = 4
INITCLUSTER_KPP = 5
Methods of calculating distance:
DIST_UNDEFINED = 0
DIST_EUCLIDEAN = 1
DIST_MAHALANOBIS = 2
DIST_MANHATTEN = 3
DIST_MINKOWSKI = 4
DIST_CHEBYSHEV = 5
DIST_MUTUALINFO = 6
Methods of summerising data:
SUMTYPE_UNDEFINED = 0
SUMTYPE_MODE = 1
SUMTYPE_MEAN = 2
SUMTYPE_MEDIAN = 3
SUMTYPE_MIN = 4
SUMTYPE_MAX = 5
SUMTYPE_STDDEV = 6
SUMTYPE_COUNT = 7
SUMTYPE_RANGE = 8
SUMTYPE_SUM = 9
- Constants specifying how bands should be treated when sharpening (see rsgislib.imageutils)
SHARP_RES_IGNORE = 0
SHARP_RES_LOW = 1
SHARP_RES_HIGH = 2
-
exception
rsgislib.
RSGISPyException
(value)¶ A class representing the RSGIS exception.
Init for the RSGISPyException class
-
class
rsgislib.
RSGISPyUtils
¶ A class with useful utilities within RSGISLib.
-
bbox_equal
(bbox1, bbox2)¶ A function which tests whether two bboxes (xMin, xMax, yMin, yMax) are equal.
- Parameters
bbox1 – is a bbox (xMin, xMax, yMin, yMax)
bbox2 – is a bbox (xMin, xMax, yMin, yMax)
- Returns
boolean
-
bbox_intersection
(bbox1, bbox2)¶ A function which calculates the intersection of the two bboxes (xMin, xMax, yMin, yMax).
- Parameters
bbox1 – is a bbox (xMin, xMax, yMin, yMax)
bbox2 – is a bbox (xMin, xMax, yMin, yMax)
- Returns
bbox (xMin, xMax, yMin, yMax)
-
bboxes_intersection
(bboxes)¶ A function to find the intersection between a list of bboxes.
- Parameters
bboxes – a list of bboxes [(xMin, xMax, yMin, yMax)]
- Returns
bbox (xMin, xMax, yMin, yMax)
-
buffer_bbox
(bbox, buf)¶ Buffer the input BBOX by a set amount.
- Parameters
bbox – the bounding box (MinX, MaxX, MinY, MaxY)
buf – the amount of buffer by
- Returns
the buffered bbox (MinX, MaxX, MinY, MaxY)
-
calc_bbox_area
(bbox)¶ Calculate the area of the bbox.
- Parameters
bbox – bounding box (MinX, MaxX, MinY, MaxY)
- Returns
area in projection of the bbox.
-
check_str
(str_val, rm_non_ascii=False, rm_dashs=False, rm_spaces=False, rm_punc=False)¶ A function which can check a string removing spaces (replaced with underscores), remove punctuation and any non ascii characters.
- Parameters
str_val – the input string to be processed.
rm_non_ascii – If True (default False) remove any non-ascii characters from the string
rm_dashs – If True (default False) remove any dashs from the string and replace with underscores.
rm_spaces – If True (default False) remove any spaces from the string.
rm_punc – If True (default False) remove any punctuation (other than ‘_’ or ‘-‘) from the string.
- Returns
returns a string outputted from the processing.
-
clean_file_locks
(dir_path, timeout=3600)¶ A function which cleans up any remaining lock file (i.e., if an application has crashed). The timeout time will be compared with the time written within the file.
- Parameters
dir_path – the file path to search for lock files (i.e., “.*.lok”)
timeout – the time (in seconds) for the timeout. Default: 3600 (1 hours)
-
createVarList
(in_vals_lsts, val_dict=None)¶ A function which will produce a list of dictionaries with all the combinations of the input variables listed (i.e., the powerset).
- Parameters
in_vals_lsts – dictionary with each value having a list of values.
val_dict – variable used in iterative nature of function which lists the variable for which are still to be looped through. Would normally not be provided by the user as default is None. Be careful if you set as otherwise.
- Returns
list of dictionaries with the same keys are the input but only a single value will be associate with key rather than a list.
Example:
seg_vars_ranges = dict() seg_vars_ranges['k'] = [5, 10, 20, 30, 40, 50, 60, 80, 100, 120] seg_vars_ranges['d'] = [10, 20, 50, 100, 200, 1000, 10000] seg_vars_ranges['minsize'] = [5, 10, 20, 50, 100, 200] seg_vars = rsgis_utils.createVarList(seg_vars_ranges)
-
deleteDIR
(dirPath)¶ A function which will delete a directory, if files and other directories are within the path specified they will be recursively deleted as well. So be careful you don’t delete things within meaning it.
-
deleteFileWithBasename
(filePath)¶ Function to delete all the files which have a path and base name defined in the filePath attribute.
-
doGDALLayersHaveSameProj
(layer1, layer2)¶ A function which tests whether two gdal compatiable layers are in the same projection/coordinate system. This is done using the GDAL SpatialReference function AutoIdentifyEPSG. If the identified EPSG codes are different then False is returned otherwise True.
- Returns
boolean
-
doImageResMatch
(img1, img2)¶ A function to test whether two images have the same image pixel resolution.
- Returns
boolean
-
do_bboxes_intersect
(bbox1, bbox2)¶ A function which tests whether two bboxes (MinX, MaxX, MinY, MaxY) intersect.
- Parameters
bbox1 – The first bounding box (MinX, MaxX, MinY, MaxY)
bbox2 – The second bounding box (MinX, MaxX, MinY, MaxY)
- Returns
boolean (True they intersect; False they do not intersect)
-
does_bbox_contain
(bbox1, bbox2)¶ A function which tests whether bbox1 contains bbox2.
- Parameters
bbox1 – The first bounding box (MinX, MaxX, MinY, MaxY)
bbox2 – The second bounding box (MinX, MaxX, MinY, MaxY)
- Returns
boolean (True bbox1 contains bbox2; False bbox1 does not contain bbox2)
-
findCommonExtentOnGrid
(baseExtent, baseGrid, otherExtent, fullContain=True)¶ A function which calculates the common extent between two extents but defines output on grid with defined resolutions. Useful for finding common extent on a particular image grid.
- Parameters
baseExtent – is a bbox (xMin, xMax, yMin, yMax) providing the base for the grid on which output will be defined.
baseGrid – the size of the (square) grid on which output will be defined.
otherExtent – is a bbox (xMin, xMax, yMin, yMax) to be intersected with the baseExtent.
fullContain – is a boolean. True: moving output onto grid will increase size of bbox (i.e., intersection fully contained) False: move output onto grid will decrease size of bbox (i.e., bbox fully contained within intesection)
- Returns
bbox (xMin, xMax, yMin, yMax)
-
findExtentOnGrid
(baseExtent, baseGrid, fullContain=True)¶ A function which calculates the extent but defined on a grid with defined resolution. Useful for finding extent on a particular image grid.
- Parameters
baseExtent – is a bbox (xMin, xMax, yMin, yMax) providing the base for the grid on which output will be defined.
baseGrid – the size of the (square) grid on which output will be defined.
fullContain – is a boolean. True: moving output onto grid will increase size of bbox (i.e., intersection fully contained) False: move output onto grid will decrease size of bbox (i.e., bbox fully contained within intesection)
- Returns
bbox (xMin, xMax, yMin, yMax)
-
findExtentOnWholeNumGrid
(baseExtent, baseGrid, fullContain=True, round_vals=None)¶ A function which calculates the extent but defined on a grid with defined resolution. Useful for finding extent on a particular image grid.
- Parameters
baseExtent – is a bbox (xMin, xMax, yMin, yMax) providing the base for the grid on which output will be defined.
baseGrid – the size of the (square) grid on which output will be defined.
fullContain – is a boolean. True: moving output onto grid will increase size of bbox (i.e., intersection fully contained) False: move output onto grid will decrease size of bbox (i.e., bbox fully contained within intesection)
round_vals – specify whether outputted values should be rounded. None for no rounding (default) or integer for number of significant figures to round to.
- Returns
bbox (xMin, xMax, yMin, yMax)
-
findFile
(dirPath, fileSearch)¶ Search for a single file with a path using glob. Therefore, the file path returned is a true path. Within the fileSearch provide the file name with ‘*’ as wildcard(s).
- Returns
string
-
findFileNone
(dirPath, fileSearch)¶ Search for a single file with a path using glob. Therefore, the file path returned is a true path. Within the fileSearch provide the file name with ‘*’ as wildcard(s). Returns None is not found.
- Returns
string
-
find_bbox_union
(bboxes)¶ A function which finds the union of all the bboxes inputted.
- Parameters
bboxes – a list of bboxes [(xMin, xMax, yMin, yMax), (xMin, xMax, yMin, yMax)]
- Returns
bbox (xMin, xMax, yMin, yMax)
-
find_files_ext
(dir_path, ending)¶ Find all the files within a directory structure with a specific file ending. The files are return as dictionary using the file name as the dictionary key. This means you cannot have files with the same name within the structure.
- Parameters
dir_path – the base directory path within which to search.
ending – the file ending (e.g., .txt, or txt or .kea, kea).
- Returns
dict with file name as key
-
find_files_mpaths_ext
(dir_paths, ending)¶ Find all the files within a list of input directories and the structure beneath with a specific file ending. The files are return as dictionary using the file name as the dictionary key. This means you cannot have files with the same name within the structure.
- Parameters
dir_path – the base directory path within which to search.
ending – the file ending (e.g., .txt, or txt or .kea, kea).
- Returns
dict with file name as key
-
find_first_file
(dirPath, fileSearch, rtn_except=True)¶ Search for a single file with a path using glob. Therefore, the file path returned is a true path. Within the fileSearch provide the file name with ‘*’ as wildcard(s). :param dirPath: The directory within which to search, note that the search will be within
sub-directories within the base directory until a file meeting the search criteria are met.
- Parameters
fileSearch – The file search string in the file name and must contain a wild character (i.e., *).
rtn_except – if True then an exception will be raised if no file or multiple files are found (default). If False then None will be returned rather than an exception raised.
- Returns
The file found (or None if rtn_except=False)
-
getBBoxGrid
(bbox, x_size, y_size)¶ Create a grid with size x_size, y_size for the area represented by bbox.
- Parameters
bbox – a bounding box within which the grid will be created (xMin, xMax, yMin, yMax)
x_size – Output grid size in X axis (same unit as bbox).
y_size – Output grid size in Y axis (same unit as bbox).
- Returns
list of bounding boxes (xMin, xMax, yMin, yMax)
-
getEPSGCode
(gdalLayer)¶ Using GDAL to return the EPSG code for the input layer.
- Returns
EPSG code
-
getEPSGCodeFromWKT
(wktString)¶ Using GDAL to return the EPSG code for inputted WKT string.
- Returns
the EPSG code.
-
getEnvironmentVariable
(var)¶ A function to get an environmental variable, if variable is not present returns None.
- Returns
value of env var.
-
getFileExtension
(gdalformat)¶ A function to get the extension for a given file format (NOTE, currently only KEA, GTIFF, HFA, PCI and ENVI are supported).
- Returns
string
-
getGDALDataType
(rsgislib_datatype)¶ Convert from RSGIS data type to GDAL data type int.
- Returns
int
-
getGDALDataTypeFromImg
(inImg)¶ Returns the GDAL datatype ENUM (e.g., GDT_Float32) for the inputted raster file.
- Returns
ints
-
getGDALDataTypeNameFromImg
(inImg)¶ Returns the GDAL datatype ENUM (e.g., GDT_Float32) for the inputted raster file.
- Returns
int
-
getGDALFormatFromExt
(fileName)¶ Get GDAL format, based on filename
- Returns
string
-
getImageBBOX
(inImg)¶ A function to retrieve the bounding box in the spatial coordinates of the image.
- Returns
(MinX, MaxX, MinY, MaxY)
-
getImageBBOXInProj
(inImg, outEPSG)¶ A function to retrieve the bounding box in the spatial coordinates of the image.
- Returns
(MinX, MaxX, MinY, MaxY)
-
getImageBandCount
(inImg)¶ A function to retrieve the number of image bands in an image file.
- Returns
nBands
-
getImageBandStats
(img, band, compute=True)¶ A function which calls the GDAL function on the band selected to calculate the pixel stats (min, max, mean, standard deviation).
- Parameters
img – input image file path
band – specified image band for which stats are to be calculated (starts at 1).
compute – whether the stats should be calculated (True; Default) or an approximation or pre-calculated stats are OK (False).
- Returns
stats (min, max, mean, stddev)
-
getImageFiles
(inImg)¶ A function which returns a list of the files associated (e.g., header etc.) with the input image file.
- Returns
lists
-
getImageNoDataValue
(inImg, band=1)¶ A function to retrieve the no data value for the image (from band; default 1).
- Returns
number
-
getImageRes
(inImg)¶ A function to retrieve the image resolution.
- Returns
xRes, yRes
-
getImageSize
(inImg)¶ A function to retrieve the image size in pixels.
- Returns
xSize, ySize
-
getImgBandColourInterp
(inImg, band)¶ A function to get the colour interpretation for a specific band.
- Returns
is a GDALColorInterp value:
GCI_Undefined=0,
GCI_GrayIndex=1,
GCI_PaletteIndex=2,
GCI_RedBand=3,
GCI_GreenBand=4,
GCI_BlueBand=5,
GCI_AlphaBand=6,
GCI_HueBand=7,
GCI_SaturationBand=8,
GCI_LightnessBand=9,
GCI_CyanBand=10,
GCI_MagentaBand=11,
GCI_YellowBand=12,
GCI_BlackBand=13,
GCI_YCbCr_YBand=14,
GCI_YCbCr_CbBand=15,
GCI_YCbCr_CrBand=16,
GCI_Max=16
-
getNumpyCharCodesDataType
(rsgislib_datatype)¶ Convert from RSGISLib data type to numpy datatype
- Parameters
rsgis_datatype –
- Returns
numpy character code datatype
-
getNumpyDataType
(rsgislib_datatype)¶ Convert from RSGISLib data type to numpy datatype
- Parameters
rsgis_datatype –
- Returns
numpy datatype
-
getProjEPSGFromVec
(inVec, vecLyr=None)¶ A function which gets the EPSG projection from the inputted vector file.
- Parameters
inVec – is a string with the input vector file name and path.
vecLyr – is a string with the input vector layer name, if None then first layer read. (default: None)
- Returns
EPSG representation of projection
-
getProjWKTFromVec
(inVec, vecLyr=None)¶ A function which gets the WKT projection from the inputted vector file.
- Parameters
inVec – is a string with the input vector file name and path.
vecLyr – is a string with the input vector layer name, if None then first layer read. (default: None)
- Returns
WKT representation of projection
-
getRSGISLibDataType
(gdaltype)¶ Convert from GDAL data type string to RSGISLib data type int.
- Returns
int
-
getRSGISLibDataTypeFromImg
(inImg)¶ Returns the rsgislib datatype ENUM (e.g., rsgislib.TYPE_8INT) for the inputted raster file
- Returns
int
-
getUTMZone
(inImg)¶ A function which returns a string with the UTM (XXN | XXS) zone of the input image but only if it is projected within the UTM projection/coordinate system.
- Returns
string
-
getVecFeatCount
(inVec, layerName=None, computeCount=True)¶ Get a count of the number of features in the vector layers.
- Parameters
inVec – is a string with the input vector file name and path.
layerName – is the layer for which extent is to be calculated (Default: None) if None assume there is only one layer and that will be read.
computeCount – is a boolean which specifies whether the layer extent should be calculated (rather than estimated from header) even if that operation is computationally expensive.
- Returns
nfeats
-
getVecLayerExtent
(inVec, layerName=None, computeIfExp=True)¶ Get the extent of the vector layer.
- Parameters
inVec – is a string with the input vector file name and path.
layerName – is the layer for which extent is to be calculated (Default: None) if None assume there is only one layer and that will be read.
computeIfExp – is a boolean which specifies whether the layer extent should be calculated (rather than estimated from header) even if that operation is computationally expensive.
- Returns
boundary box is returned (MinX, MaxX, MinY, MaxY)
-
getWKTFromEPSGCode
(epsgCode)¶ Using GDAL to return the WKT string for inputted EPSG Code.
- Parameters
epsgCode – integer variable of the epsg code.
- Returns
string with WKT representation of the projection.
-
getWKTProjFromImage
(inImg)¶ A function which returns the WKT string representing the projection of the input image.
- Returns
string
-
get_days_since
(year, dayofyear, base_date)¶ Calculate the number of days from a base data to a defined year/day.
- Parameters
year – int with year XXXX (e.g., 2020)
dayofyear – int with the day within the year (1-365)
base_date – a datetime
- Returns
int (n days)
-
get_days_since_date
(year, month, day, base_date)¶ Calculate the number of days from a base data to a defined year/day.
- Parameters
year – int with year XXXX (e.g., 2020)
month – int month in year (1-12) (e.g., 6)
day – int with the day within the month (1-31) (e.g., 20)
base_date – a datetime
- Returns
int (n days)
-
get_dir_name
(in_file)¶ A function which returns just the name of the directory of the input file without the rest of the path.
- Parameters
in_file – string for the input file name and path
- Returns
directory name
-
get_file_basename
(filepath, checkvalid=False, n_comps=0)¶ Uses os.path module to return file basename (i.e., path and extension removed)
- Parameters
filepath – string for the input file name and path
checkvalid – if True then resulting basename will be checked for punctuation characters (other than underscores) and spaces, punctuation will be either removed and spaces changed to an underscore. (Default = False)
n_comps – if > 0 then the resulting basename will be split using underscores and the return based name will be defined using the n_comps components split by under scores.
- Returns
basename for file
-
get_file_lock
(input_file, sleep_period=1, wait_iters=120, use_except=False)¶ A function which gets a lock on a file.
The lock file will be a unix hidden file (i.e., starts with a .) and it will have .lok added to the end. E.g., for input file hello_world.txt the lock file will be .hello_world.txt.lok. The contents of the lock file will be the time and date of creation.
Using the default parameters (sleep 1 second and wait 120 iterations) if the lock isn’t available it will be retried every second for 120 seconds (i.e., 2 mins).
- Parameters
input_file – The input file for which the lock will be created.
sleep_period – time in seconds to sleep for, if the lock isn’t available. (Default=1 second)
wait_iters – the number of iterations to wait for before giving up. (Default=120)
use_except – Boolean. If True then an exception will be thrown if the lock is not available. If False (default) False will be returned if the lock is not successful.
- Returns
boolean. True: lock was successfully gained. False: lock was not gained.
-
get_files_mtime
(file_lst, dt_before=None, dt_after=None)¶ A function which subsets a list of files based on datetime of last modification. The function also does a check as to whether a file exists, files which don’t exist will be ignored.
- Parameters
file_lst – The list of file path - represented as strings.
dt_before – a datetime object with a date/time where files modified before this will be returned
dt_after – a datetime object with a date/time where files modified after this will be returned
-
get_osr_prj_obj
(epsg_code)¶ A function which returns an OSR SpatialReference object for a given EPSG code.
- Parameters
epsg_code – An EPSG code for the projection. Must be an integer.
- Returns
osr.SpatialReference object.
-
in_bounds
(x, lower, upper, upper_strict=False)¶ Checks whether a value is within specified bounds.
- Parameters
x – value or array of values to check.
lower – lower bound
upper – upper bound
upper_strict – True is less than upper; False is less than equal to upper
- Returns
boolean
-
isNumber
(strVal)¶ A function which tests whether the input string contains a number of not.
- Returns
boolean
-
isodd
(number)¶ A function which tests whether a number is odd
- Parameters
number – number value to test.
- Returns
True = input number is odd; False = input number is even
-
mixed_signs
(x)¶ Check whether a list of numbers has a mix of postive and negative values.
- Parameters
x – list of values.
- Returns
boolean
-
negative
(x)¶ Is the maximum number in the list negative. :param x: list of values
- Returns
boolean
-
numProcessCores
()¶ A functions which returns the number of processing cores available on the machine
- Returns
int
-
powerset_iter
(inset)¶ A function which returns an iterator (generator) for all the subsets of the inputted set (i.e., the powerset)
- Params inset
the input set for which the powerset will be produced
-
powerset_lst
(inset, min_items=0)¶ A function which returns a list for all the subsets of the inputted set (i.e., the powerset)
- Params inset
the input set for which the powerset will be produced
- Params min_items
Optional parameter specifying the minimum number of items in the output sets. If 0 or below then ignored. Default is 0.
-
readJSON2Dict
(input_file)¶ Read a JSON file. Will return a list or dict.
- Parameters
input_file – input JSON file path.
-
readTextFile2List
(file)¶ Read a text file into a list where each line is an element in the list.
- Parameters
file – File path to the input file.
- Returns
list
-
readTextFileNoNewLines
(file)¶ Read a text file into a single string removing new lines.
- Parameters
file – File path to the input file.
- Returns
string
-
release_file_lock
(input_file)¶ A function which releases a lock file for the input file.
- Parameters
input_file – The input file for which the lock will be created.
-
remove_repeated_chars
(str_val, repeat_char)¶ A function which removes repeated characters within a string for the specified character
- Parameters
str_val – The input string.
repeat_char – The character
- Returns
string without repeat_char
-
renameGDALLayer
(cFileName, oFileName)¶ Rename all the files associated with a GDAL layer.
- Parameters
cFileName – The current name of the GDAL layer.
oFileName – The output name of the GDAL layer.
-
reprojBBOX
(bbox, inProjObj, outProjObj)¶ A function to reproject a bounding box.
- Parameters
bbox – input bounding box (MinX, MaxX, MinY, MaxY)
inProjObj – an osr.SpatialReference() object representing input projection.
outProjObj – an osr.SpatialReference() object representing output projection.
- Returns
(MinX, MaxX, MinY, MaxY)
-
reprojBBOX_epsg
(bbox, inEPSG, outEPSG)¶ A function to reproject a bounding box.
- Parameters
bbox – input bounding box (MinX, MaxX, MinY, MaxY)
inEPSG – an EPSG code representing input projection.
outEPSG – an EPSG code representing output projection.
- Returns
(MinX, MaxX, MinY, MaxY)
-
reprojPoint
(inProjOSRObj, outProjOSRObj, x, y)¶ Reproject a point from ‘inProjOSRObj’ to ‘outProjOSRObj’ where they are gdal osgeo.osr.SpatialReference objects.
- Returns
x, y.
-
setImageNoDataValue
(inImg, noDataValue, band=None)¶ A function to set the no data value for an image. If band is not specified sets value for all bands.
-
setImgBandColourInterp
(inImg, band, clrItrpVal)¶ A function to set the colour interpretation for a specific band. input is a GDALColorInterp value:
GCI_Undefined=0,
GCI_GrayIndex=1,
GCI_PaletteIndex=2,
GCI_RedBand=3,
GCI_GreenBand=4,
GCI_BlueBand=5,
GCI_AlphaBand=6,
GCI_HueBand=7,
GCI_SaturationBand=8,
GCI_LightnessBand=9,
GCI_CyanBand=10,
GCI_MagentaBand=11,
GCI_YellowBand=12,
GCI_BlackBand=13,
GCI_YCbCr_YBand=14,
GCI_YCbCr_CbBand=15,
GCI_YCbCr_CrBand=16,
GCI_Max=16
-
set_envvars_lzw_gtiff_outs
(bigtiff=True)¶ Set environmental variables such that outputted GeoTIFF files are outputted as tiled and compressed.
- Parameters
bigtiff – If True GTIFF files will be outputted in big tiff format.
-
uidGenerator
(size=6)¶ A function which will generate a ‘random’ string of the specified length based on the UUID
- Parameters
size – the length of the returned string.
- Returns
string of length size.
-
unwrap_wgs84_bbox
(bbox)¶ A function which unwraps a bbox if it projected in WGS84 and over the 180/-180 boundary.
- Parameters
bbox – the bounding box (MinX, MaxX, MinY, MaxY)
- Returns
list of bounding boxes [(MinX, MaxX, MinY, MaxY), (MinX, MaxX, MinY, MaxY)…]
-
writeData2File
(data_val, out_file)¶ Write some data (a string or can be converted to a string using str(data_val) to an output text file.
- Parameters
data_val – Data to be written to the output file.
out_file – File path to the output file.
-
writeDict2JSON
(data_dict, out_file)¶ Write some data to a JSON file. The data would commonly be structured as a dict but could also be a list.
- Parameters
data_dict – The dict (or list) to be written to the output JSON file.
out_file – The file path to the output file.
-
writeList2File
(dataList, outFile)¶ Write a list a text file, one line per item.
- Parameters
dataList – List of values to be written to the output file.
out_file – File path to the output file.
-
zero_pad_num_str
(num_val, str_len=3, round_num=False, round_n_digts=0, integerise=False)¶ A function which zero pads a number to make a string
- Parameters
num_val – number value to be processed.
str_len – the number of characters in the output string.
round_num – boolean whether to round the input number value.
round_n_digts – If rounding, the number of digits following decimal points to round to.
integerise – boolean whether to integerise the input number
- Returns
string with the padded numeric value.
-
-
class
rsgislib.
RSGISTime
¶ Class to calculate run time for a function, format and print out (similar to for XML interface).
Need to call start before running function and end immediately after. Example:
t = RSGISTime() t.start() rsgislib.segmentation.clump(kMeansFileZonesNoSgls, initClumpsFile, gdalformat, False, 0) t.end()
Note, this is only designed to provide some general feedback, for benchmarking the timeit module is better suited.
-
calcDiff
(preceedStr='', postStr='')¶ Calculate time difference, format and print. :param preceedStr: A string which is printed ahead of time difference :param postStr: A string which is printed after the time difference
-
end
(reportDiff=True, preceedStr='', postStr='')¶ End timer and optionally print difference. If preceedStr or postStr have a value then they will be used instead of the generic wording around the time.
preceedStr + time + postStr
- Parameters
reportDiff – A boolean specifiying whether time difference should be printed to console.
preceedStr – A string which is printed ahead of time difference
postStr – A string which is printed after the time difference
-
start
(printStartTime=False)¶ Start timer, optionally printing start time
- Parameters
printStartTime – A boolean specifiying whether the start time should be printed to console.
-
-
class
rsgislib.
TQDMProgressBar
¶ Uses TQDM TermProgress to print a progress bar to the terminal
-
displayError
(text)¶
-
displayException
(trace)¶
-
displayInfo
(text)¶
-
displayWarning
(text)¶
-
reset
()¶
-
setLabelText
(text)¶
-
setProgress
(progress)¶
-
setTotalSteps
(steps)¶
-
wasCancelled
()¶
-
-
rsgislib.
getRSGISLibVersion
()¶ Calls rsgis-config to get the version number.