revrt.costs.cli.build_routing_layers#
- build_routing_layers(routing_file, template_file=None, input_layer_dir='.', output_tiff_dir='.', masks_dir='.', layers=None, dry_costs=None, merge_friction_and_barriers=None, max_workers=1, memory_limit_per_worker='auto', create_kwargs=None)[source]#
Create costs, barriers, and frictions from a config file
You can re-run this function on an existing file to add new layers without overwriting existing layers or needing to change your original config.
- Parameters:
routing_file (path-like) – Path to GeoTIFF/Zarr file to store cost layers in. If the file does not exist, it will be created based on the template_file input.
template_file (path-like, optional) – Path to template GeoTIFF (
*.tif
or*.tiff
) or Zarr (*.zarr
) file containing the profile and transform to be used for the layered costs file. IfNone
, then the routing_file is assumed to exist on disk already. By default,None
.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,
"."
.masks_dir (path-like, optional) – Directory for storing/finding mask GeoTIFFs (wet, dry, landfall, wet+, dry+). By default,
"."
.layers (
list
ofLayerConfig
, optional) – Configuration for layers to be built and added to the file. At least one of layers, dry_costs, or merge_friction_and_barriers must be defined. By default,None
.dry_costs (
DryCosts
, optional) – Configuration for dry cost layers to be built and added to the file. At least one of layers, dry_costs, or merge_friction_and_barriers must be defined. By default,None
.merge_friction_and_barriers (
MergeFrictionBarriers
, optional) – Configuration for merging friction and barriers and adding to the layered costs file. At least one of layers, dry_costs, or merge_friction_and_barriers must be defined. By default,None
max_workers (
int
, optional) – Number of parallel workers to use for file creation. IfNone
or >1, processing is performed in parallel using Dask. By default,1
.memory_limit_per_worker (
str
,float
,int
, orNone
, default"auto"
) – Sets the memory limit per worker. This only applies ifmax_workers != 1
. IfNone
or0
, no limit is applied. If"auto"
, the total system memory is split evenly between the workers. If a float, that fraction of the system memory is used per worker. If a string giving a number of bytes (like “1GiB”), that amount is used per worker. If an int, that number of bytes is used per worker. By default,"auto"
create_kwargs (
dict
, optional) – Additional keyword arguments to pass toLayeredFile.create_new()
when creating a new layered file. Do not includetemplate_file
; it will be ignored. By default,None
.