reVX.setbacks.setbacks_converter.SetbacksConverter
- class SetbacksConverter(excl_h5, hsds=False, chunks=(128, 128), replace=True)[source]
Bases:
ExclusionsConverter
Convert setbacks goetiff(s) to excl .h5 layers
- Parameters:
excl_h5 (str) – Path to .h5 file containing or to contain exclusion layers
hsds (bool, optional) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS, by default False
chunks (tuple, optional) – Chunk size of exclusions in .h5 and Geotiffs, by default (128, 128)
replace (bool, optional) – Flag to replace existing layers if needed, by default True
Methods
extract_all_layers
(excl_h5, out_dir[, ...])Extract all layers from exclusions .h5 file and save to disk as GeoTiffs
extract_layers
(excl_h5, layers[, chunks, hsds])Extract given layers from exclusions .h5 file and save to disk as GeoTiffs
geotiff_to_layer
(layer, geotiff[, ...])Transfer geotiff exclusions to h5 confirming they match existing layers
layer_to_geotiff
(layer, geotiff)Extract desired layer from .h5 file and write to geotiff .tif
layers_to_h5
(excl_h5, layers[, chunks, ...])Create exclusions .h5 file, or load layers into existing exclusion .h5 file from provided setbacks
parse_tiff
(geotiff[, excl_h5, chunks, ...])Extract exclusion layer from given geotiff, compare with excl_h5 if provided
setbacks_to_layer
(layer, setbacks[, ...])Transfer geotiff setbacks to h5 confirming they match existing layers
write_geotiff
(geotiff, profile, values)Write values to geotiff with given profile
Attributes
Available exclusion layers in .h5 file
- setbacks_to_layer(layer, setbacks, check_tiff=True, is_inclusion_layer=False, transform_atol=0.01, coord_atol=0.001, description=None, scale_factor=None, dtype='uint8')[source]
Transfer geotiff setbacks to h5 confirming they match existing layers
- Parameters:
layer (str) – Name of layer to create of replace.
setbacks (str) – Path to geotiff file or directory containing multiple geotiff files to be merged.
check_tiff (bool, optional) – Flag to check tiff profile and coordinates against exclusion .h5 profile and coordinates, by default True.
is_inclusion_layer (bool, optional) – Flag indicating wether this layer should be an inclusion layer instead of an exclusion mask, by default False.
transform_atol (float, optional) – Absolute tolerance parameter when comparing geotiff transform data, by default 0.01
coord_atol (float, optional.) – Absolute tolerance parameter when comparing new un-projected geotiff coordinates against previous coordinates, by default 0.001.
description (str, optional) – Description of exclusion layer, by default None.
scale_factor (int | float, optional) – Scale factor to use to scale geotiff data when added to the .h5 file, by default None, which does not apply any scaling.
dtype (str, optional) – Dtype to save geotiff data as in the .h5 file. Only used when ‘scale_factor’ is not None, by default ‘uint8’
- classmethod layers_to_h5(excl_h5, layers, chunks=(128, 128), replace=True, check_tiff=True, are_inclusion_layers=False, transform_atol=0.01, coord_atol=0.001, descriptions=None, scale_factors=None)[source]
Create exclusions .h5 file, or load layers into existing exclusion .h5 file from provided setbacks
- Parameters:
excl_h5 (str) – Path to .h5 file containing or to contain exclusion layers
layers (dict | list) – Dictionary where keys are layer names and values are paths to the corresponding geotiff files or paths to directories containing multiple geotiff files to be merged for each layer. If input is a list of paths to geotiff files, then the name of the layer is inferred from the geotiff file name.
chunks (tuple, optional) – Chunk size of exclusions in geotiff, by default (128, 128)
replace (bool, optional) – Flag to replace existing layers if needed, by default True
check_tiff (bool, optional) – Flag to check tiff profile and coordinates against exclusion .h5 profile and coordinates, by default True.
are_inclusion_layers (bool, optional) – Flag indicating wether the input layers should be treated as inclusion layers instead of exclusion masks, by default False.
transform_atol (float, optional) – Absolute tolerance parameter when comparing geotiff transform data, by default 0.01.
coord_atol (float, optional) – Absolute tolerance parameter when comparing new un-projected geotiff coordinates against previous coordinates, by default 0.001.
description (dict, optional) – Description of exclusion layers, by default None
scale_factor (dict, optional) – Scale factors and dtypes to use when scaling given layers, by default None
- classmethod extract_all_layers(excl_h5, out_dir, chunks=(128, 128), hsds=False)
Extract all layers from exclusions .h5 file and save to disk as GeoTiffs
- Parameters:
excl_h5 (str) – Path to .h5 file containing or to contain exclusion layers
out_dir (str) – Path to output directory into which layers should be saved as GeoTiffs
chunks (tuple) – Chunk size of exclusions in .h5 and Geotiffs
hsds (bool) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS
- classmethod extract_layers(excl_h5, layers, chunks=(128, 128), hsds=False)
Extract given layers from exclusions .h5 file and save to disk as GeoTiffs
- Parameters:
excl_h5 (str) – Path to .h5 file containing or to contain exclusion layers
layers (dict) – Dictionary mapping layers to geotiffs to create
chunks (tuple) – Chunk size of exclusions in .h5 and Geotiffs
hsds (bool) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS
- geotiff_to_layer(layer, geotiff, check_tiff=True, transform_atol=0.01, coord_atol=0.001, description=None, scale_factor=None, dtype='int16')
Transfer geotiff exclusions to h5 confirming they match existing layers
- Parameters:
layer (str) – Layer to extract
geotiff (str) – Path to geotiff file
check_tiff (bool, optional) – Flag to check tiff profile and coordinates against exclusion .h5 profile and coordinates, by default True
transform_atol (float, optional) – Absolute tolerance parameter when comparing geotiff transform data, by default 0.01
coord_atol (float, optional) – Absolute tolerance parameter when comparing new un-projected geotiff coordinates against previous coordinates, by default 0.001
description (str, optional) – Description of exclusion layer, by default None
scale_factor (int | float, optional) – Scale factor to use to scale geotiff data when added to the .h5 file, by default None
dtype (str, optional) – Dtype to save geotiff data as in the .h5 file. Only used when ‘scale_factor’ is not None, by default ‘int16’
- layer_to_geotiff(layer, geotiff)
Extract desired layer from .h5 file and write to geotiff .tif
- Parameters:
layer (str) – Layer to extract
geotiff (str) – Path to geotiff file
- property layers
Available exclusion layers in .h5 file
- Returns:
layers (list) – Available layers in .h5 file
- classmethod parse_tiff(geotiff, excl_h5=None, chunks=(128, 128), check_tiff=True, transform_atol=0.01, coord_atol=0.001)
Extract exclusion layer from given geotiff, compare with excl_h5 if provided
- Parameters:
geotiff (str) – Path to geotiff file
excl_h5 (str, optional) – Path to .h5 file containing exclusion layers, by default None
chunks (tuple, optional) – Chunk size of exclusions in Geotiff, by default (128, 128)
check_tiff (bool, optional) – Flag to check tiff profile and coordinates against exclusion .h5 profile and coordinates, by default True
transform_atol (float, optional) – Absolute tolerance parameter when comparing geotiff transform data, by default 0.01
coord_atol (float, optional) – Absolute tolerance parameter when comparing new un-projected geotiff coordinates against previous coordinates, by default 0.001
- Returns:
profile (dict) – Geotiff profile (attributes)
values (ndarray) – Geotiff data
- static write_geotiff(geotiff, profile, values)
Write values to geotiff with given profile
- Parameters:
geotiff (str) – Path to geotiff file to save data to
profile (dict) – Geotiff profile (attributes)
values (ndarray) – Geotiff data