RSGISLib

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 summarising 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

Options for interpolating raster data:

  • INTERP_NEAREST_NEIGHBOUR = 0

  • INTERP_BILINEAR = 1

  • INTERP_CUBIC = 2

  • INTERP_CUBICSPLINE = 3

  • INTERP_LANCZOS = 4

  • INTERP_AVERAGE = 5

  • INTERP_MODE = 6

  • INTERP_MIN = 7

  • INTERP_MAX = 8

  • INTERP_MEDIAN = 9

  • INTERP_Q1 = 10

  • INTERP_Q3 = 11

  • INTERP_SUM = 12

Options for image stretching / normalisation:

  • IMG_STRETCH_NONE = 0

  • IMG_STRETCH_USER = 1

  • IMG_STRETCH_LINEAR = 2

  • IMG_STRETCH_STDEV = 3

  • IMG_STRETCH_CUMULATIVE = 4

Options for vector geometry types:

  • GEOM_PT = 1

  • GEOM_LINE = 2

  • GEOM_POLY = 3

  • GEOM_MPT = 4

  • GEOM_MLINE = 5

  • GEOM_MPOLY = 6

Available thresholding methods:

  • THRES_METH_NONE = 0

  • THRES_METH_OTSU = 1

  • THRES_METH_YEN = 2

  • THRES_METH_ISODATA = 3

  • THRES_METH_CROSS_ENT = 4

  • THRES_METH_LI = 5

  • THRES_METH_KURT_SKEW = 6

Options for classification datasets:

  • CLS_ALL_DATA = 0

  • CLS_TRAIN_DATA = 1

  • CLS_VALID_DATA = 2

  • CLS_TEST_DATA = 3

Options for classification hyperparameter optimisation:
  • OPT_MTHD_UNDEFINED = 0

  • OPT_MTHD_BAYESOPT = 1

  • OPT_MTHD_OPTUNA = 2

  • OPT_MTHD_SKOPT = 3

  • OPT_MTHD_RANDOM = 4

  • OPT_MTHD_GRID = 5

Options for calculating correlation:
  • STATS_CORR_UNDEFINED = 0

  • STATS_CORR_PEARSONS = 1

  • STATS_CORR_SPEARMAN = 2

  • STATS_CORR_KENDALL_TAU = 3

  • STATS_CORR_POINT_BISERIAL = 4

Options for logical combination of data: LOGIC_AND = 1 LOGIC_OR = 2

class rsgislib.RSGISGDALErrorHandler

A class representing a generic GDAL Error Handler which can be used to pick up GDAL warnings rather than just failure errors.

Init for RSGISGDALErrorHandler. Class attributes are err_level, err_no and err_msg

handler(err_level, err_no, err_msg)

The handler function which is called with the error information.

Parameters:
  • err_level – The level of the error

  • err_no – The error number

  • err_msg – The message (string) associated with the error.

exception rsgislib.RSGISPyException(value: str)

A class representing the RSGISLib exception.

Init for the RSGISPyException class

class rsgislib.RSGISTime

Class to calculate run time for a function, format and print out.

Need to call start before running function and end immediately after.

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.

calc_diff(precede_str: str = '', post_str: str = '')

Calculate time difference, format and print.

Parameters:
  • precede_str – A string which is printed ahead of time difference

  • post_str – A string which is printed after the time difference

end(report_diff: bool = True, precede_str: str = '', post_str: str = '')

End timer and optionally print difference. If precedeStr or postStr have a value then they will be used instead of the generic wording around the time.

“{precede_str} {time} {post_str}”

Parameters:
  • report_diff – A boolean specifying whether time difference should be printed to console.

  • precede_str – A string which is printed ahead of time difference

  • post_str – A string which is printed after the time difference

start(print_start_time: bool = False)

Start timer, optionally printing start time

Parameters:

print_start_time – A boolean specifying 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: str)
displayException(trace)
displayInfo(text: str)
displayWarning(text: str)
reset()
setLabelText(text: str)
setProgress(progress: int)
setTotalSteps(steps: int)
wasCancelled()
rsgislib.get_gdal_datatype(rsgislib_datatype: int) int

Convert from RSGIS data type to GDAL data type int.

Returns:

int

rsgislib.get_gdal_interp_type(rsgis_interp_method: int)
rsgislib.get_install_base_path() PurePath

A function which returns the base path for the RSGISLib installation. This can be used to find files stored in share etc. installed alongside the RSGISLib source code.

Returns:

a pathlib.PurePath object with the base path of the RSGISLib installation.

rsgislib.get_numpy_char_codes_datatype(rsgislib_datatype: int) str

Convert from RSGISLib data type to numpy datatype

Parameters:

rsgis_datatype

Returns:

numpy character code datatype

rsgislib.get_numpy_datatype(rsgislib_datatype: int) int

Convert from RSGISLib data type to numpy datatype

Parameters:

rsgis_datatype

Returns:

numpy datatype

rsgislib.get_rsgislib_datatype(gdal_type: int) int

Convert from GDAL data type string to RSGISLib data type int.

Returns:

int

rsgislib.get_rsgislib_version() str

Calls rsgis-config to get the version number.

Returns:

string with the rsgislib version number

rsgislib.is_notebook()

A function to find if running within a python notebook. If running within a jupyter notebook then can use a different progress bar.

Returns:

boolean: True: within notebook