get_archived_rio_path(archive_path: str | CloudPath | Path, file_regex: str, as_list: bool = False) list | CloudPath | Path[source]#

Get archived file path from inside the archive, to be read with rasterio:

  • zip+file://{zip_path}!{file_name}

  • tar+file://{tar_path}!{file_name}

See here for more information.


It wont be readable by pandas, geopandas or xmltree !


If as_list is False, it will only return the first file matched !

You can use this site to build your regex.

>>> arch_path = 'D:/path/to/'
>>> file_regex = '.*dir.*file_name'  # Use .* for any character
>>> path = get_archived_tif_path(arch_path, file_regex)
<open DatasetReader name='zip+file://D:/path/to/!dir/filename.tif' mode='r'>
  • archive_path (AnyPathStrType) – Archive path

  • file_regex (str) – File regex (used by re) as it can be found in the getmembers() list

  • as_list (bool) – If true, returns a list (including all found files). If false, returns only the first match


Band path that can be read by rasterio

Return type:

Union[list, str]