revrt.costs.layer_creator.LayerCreator#

class LayerCreator(io_handler, masks, input_layer_dir='.', output_tiff_dir='.', dtype='float32')[source]#

Bases: BaseLayerCreator

Build layer based on tiff and user config

Parameters:
  • io_handler (LayeredFile) – Layered file IO handler.

  • masks (Masks) – Masks instance that can be used to retrieve multiple types of masks.

  • input_layer_dir (path-like, optional) – Directory to search for input layers in, if not found in current directory. By default, '.'.

  • output_tiff_dir (path-like, optional) – Directory where cost layers should be saved as GeoTIFF. By default, ".".

  • dtype (np.dtype, optional) – Data type for final dataset. By default, float32.

Methods

build(layer_name, build_config[, ...])

Combine multiple GeoTIFFs and vectors to a raster layer

Attributes

cell_size

Size of cell in layer file

chunks

Layer chunks (no band dimension)

output_tiff_dir

Directory to store output GeoTIFFs in

shape

Layer shape

build(layer_name, build_config, values_are_costs_per_mile=False, write_to_file=True, description=None, tiff_chunks='file', nodata=None, lock=None, **profile_kwargs)[source]#

Combine multiple GeoTIFFs and vectors to a raster layer

Parameters:
  • layer_name (str) – Name of layer to use in H5 and for output tiff.

  • build_config (LayerBuildComponents) – Dict of LayerBuildConfig keyed by GeoTIFF/vector filenames.

  • values_are_costs_per_mile (bool, default False) – Option to convert values into costs per cell under the assumption that the resulting values are costs in $/mile. By default, False, which writes raw values to TIFF/H5.

  • write_to_file (bool, default True) – Option to write the layer to file after creation.

    ..IMPORTANT::

    This will overwrite existing layers with the same name already in the file.

    By default, True.

  • description (str, optional) – Optional description to store with this layer in the H5 file. By default, None.

  • tiff_chunks (int | str, default "file") – Chunk size to use when reading the GeoTIFF file. This will be passed down as the chunks argument to rioxarray.open_rasterio(). By default, "file".

  • nodata (int | float, optional) – Optional nodata value for output rasters. This value will be added to the layer’s attributes meta dictionary under the “nodata” key.

  • lock (bool | `dask.distributed.Lock`, optional) – Lock to use to write data to GeoTIFF using dask. If not supplied, a single process is used for writing data to disk. By default, None.

  • **profile_kwargs – Additional keyword arguments to pass into writing output rasters. The following attributes ar ignored (they are set using properties of the LayeredFile):

    • nodata

    • transform

    • crs

    • count

    • width

    • height

property cell_size#

Size of cell in layer file

Type:

float

property chunks#

Layer chunks (no band dimension)

Type:

tuple

property output_tiff_dir#

Directory to store output GeoTIFFs in

Type:

path-like

property shape#

Layer shape

Type:

tuple