revrt.costs.cli.build_routing_layer_file#
- build_routing_layer_file(routing_file, template_file=None, input_layer_dir='.', output_tiff_dir='.', masks_dir='.', layers=None, dry_costs=None, merge_friction_and_barriers=None, validate_masks=False, max_workers=1, memory_limit_per_worker='auto', create_kwargs=None, log_directory=None)[source]#
Create a layered file with cost, barrier, and friction layers
This function creates a cost layers file that is ultimately used to compute routes between points. The layers that are created and added to the file are determined based on the input config file. If the layered file does not already exist, it will be created based on the provided template file. The config file can specify three types of actions: building custom layers, building dry cost layers, and merging friction and barriers. At least one of these actions must be specified in the config file. See the documentation for more details on each type of action.
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 (
*.tifor*.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 (
listofLayerConfig, 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,Nonevalidate_masks (
bool, optional) – Whether to validate that any loaded masks have appropriate values. This breaks the lazy (Dask) loading of the masks, so it it is not recommended to use this if you know your masks are valid. By default,False.max_workers (
int, optional) – Number of parallel workers to use for file creation. IfNoneor >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. IfNoneor0, 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 tocreate_new()when creating a new layered file. Do not includetemplate_file; it will be ignored. By default,None.log_directory (path-like, optional) – Directory to save Dask performance reports in. If
None, Dask performance reports will not be generated. By default,None.