diff --git a/docs/notebooks/32_local_tile.ipynb b/docs/notebooks/32_local_tile.ipynb index aa609fc831..7660faec4c 100644 --- a/docs/notebooks/32_local_tile.ipynb +++ b/docs/notebooks/32_local_tile.ipynb @@ -126,7 +126,7 @@ "metadata": {}, "outputs": [], "source": [ - "m.add_raster(dem, palette='viridis', layer_name=\"DEM\")" + "m.add_raster(dem, cmap='viridis', layer_name=\"DEM\")" ] }, { diff --git a/examples/notebooks/32_local_tile.ipynb b/examples/notebooks/32_local_tile.ipynb index aa609fc831..7660faec4c 100644 --- a/examples/notebooks/32_local_tile.ipynb +++ b/examples/notebooks/32_local_tile.ipynb @@ -126,7 +126,7 @@ "metadata": {}, "outputs": [], "source": [ - "m.add_raster(dem, palette='viridis', layer_name=\"DEM\")" + "m.add_raster(dem, cmap='viridis', layer_name=\"DEM\")" ] }, { diff --git a/leafmap/common.py b/leafmap/common.py index 5d57379d57..b46893389a 100644 --- a/leafmap/common.py +++ b/leafmap/common.py @@ -4386,19 +4386,37 @@ def download_file( url, output, quiet, proxy, speed, use_cookies, verify, id, fuzzy, resume ) - if unzip and output.endswith(".zip"): - with zipfile.ZipFile(output, "r") as zip_ref: - if not quiet: - print("Extracting files...") - if subfolder: - basename = os.path.splitext(os.path.basename(output))[0] - - output = os.path.join(out_dir, basename) - if not os.path.exists(output): - os.makedirs(output) - zip_ref.extractall(output) + if unzip: + if output.endswith(".zip"): + with zipfile.ZipFile(output, "r") as zip_ref: + if not quiet: + print("Extracting files...") + if subfolder: + basename = os.path.splitext(os.path.basename(output))[0] + + output = os.path.join(out_dir, basename) + if not os.path.exists(output): + os.makedirs(output) + zip_ref.extractall(output) + else: + zip_ref.extractall(os.path.dirname(output)) + elif output.endswith(".tar.gz") or output.endswith(".tar"): + if output.endswith(".tar.gz"): + mode = "r:gz" else: - zip_ref.extractall(os.path.dirname(output)) + mode = "r" + + with tarfile.open(output, mode) as tar_ref: + if not quiet: + print("Extracting files...") + if subfolder: + basename = os.path.splitext(os.path.basename(output))[0] + output = os.path.join(out_dir, basename) + if not os.path.exists(output): + os.makedirs(output) + tar_ref.extractall(output) + else: + tar_ref.extractall(os.path.dirname(output)) return os.path.abspath(output)