reVX.offshore.dist_to_ports_converter.DistToPortsConverter
- class DistToPortsConverter(excl_h5, hsds=False, chunks=(128, 128), replace=True)[source]
Bases:
ExclusionsConverter
Convert Distance to Ports 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
dist_to_ports_to_layer
(layer, dist_to_ports)Transfer geotiff exclusions to h5 confirming they match existing layers
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 dist_to_ports
parse_tiff
(geotiff[, excl_h5, chunks, ...])Extract exclusion layer from given geotiff, compare with excl_h5 if provided
write_geotiff
(geotiff, profile, values)Write values to geotiff with given profile
Attributes
Available exclusion layers in .h5 file
- dist_to_ports_to_layer(layer, dist_to_ports, check_tiff=True, transform_atol=0.01, coord_atol=0.001, description=None, scale_factor=None, dtype='float32')[source]
Transfer geotiff exclusions to h5 confirming they match existing layers
- Parameters:
layer (str) – Layer to create
dist_to_ports (str) – Path to directory containing distance to port geotiff files or a list of the distance to port geotiff filepaths
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 ‘float32’
- classmethod layers_to_h5(excl_h5, layers, chunks=(128, 128), replace=True, check_tiff=True, 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 dist_to_ports
- Parameters:
excl_h5 (str) – Path to .h5 file containing or to contain exclusion layers
layers (dict) – Dictionary mapping goetiffs to the layers to load
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
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