# !pip install leafmap # !pip install geopandas rasterio import os import leafmap import shutil import sys m = leafmap.Map(center=[40, -100], zoom=4) m region = m.user_roi_bounds() if region is None: region = [-115.9689, 35.9758, -115.3619, 36.4721] print(region) leafmap.download_ned(region, return_url=True) out_dir = "data" os.makedirs(out_dir, exist_ok=True) if "google.colab" in sys.modules: leafmap.download_ned(region, out_dir) if "google.colab" in sys.modules: mosaic = "mosaic.tif" leafmap.mosaic(images=out_dir, output=mosaic) if "google.colab" in sys.modules and (m.user_roi is not None): image = "dem.tif" leafmap.clip_image(mosaic, mask=m.user_roi, output=image) out_dir = "/content/drive/MyDrive/Data" if os.path.exists(out_dir) and os.path.exists(image): shutil.copyfile(image, os.path.join(out_dir, image))