56 download ned
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [2]:
Copied!
# !pip install geopandas rasterio
# !pip install geopandas rasterio
In [3]:
Copied!
import os
import leafmap
import shutil
import sys
import os
import leafmap
import shutil
import sys
In [4]:
Copied!
m = leafmap.Map(center=[40, -100], zoom=4)
m
m = leafmap.Map(center=[40, -100], zoom=4)
m
Out[4]:
In [5]:
Copied!
region = m.user_roi_bounds()
if region is None:
region = [-115.9689, 35.9758, -115.3619, 36.4721]
print(region)
region = m.user_roi_bounds()
if region is None:
region = [-115.9689, 35.9758, -115.3619, 36.4721]
print(region)
The folium plotting backend does not support this function. [-115.9689, 35.9758, -115.3619, 36.4721]
In [6]:
Copied!
leafmap.download_ned(region, return_url=True)
leafmap.download_ned(region, return_url=True)
In [7]:
Copied!
out_dir = "data"
os.makedirs(out_dir, exist_ok=True)
out_dir = "data"
os.makedirs(out_dir, exist_ok=True)
In [8]:
Copied!
if "google.colab" in sys.modules:
leafmap.download_ned(region, out_dir)
if "google.colab" in sys.modules:
leafmap.download_ned(region, out_dir)
In [9]:
Copied!
if "google.colab" in sys.modules:
mosaic = "mosaic.tif"
leafmap.mosaic(images=out_dir, output=mosaic)
if "google.colab" in sys.modules:
mosaic = "mosaic.tif"
leafmap.mosaic(images=out_dir, output=mosaic)
In [10]:
Copied!
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)
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)
In [11]:
Copied!
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))
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))