Add raster
Adding Raster Files¶
In [1]:
Copied!
import beamgis
import beamgis
Adding Raster to map¶
In [2]:
Copied!
# Display the map object in the Jupyter Notebook
m = beamgis.Map()
m
# Display the map object in the Jupyter Notebook
m = beamgis.Map()
m
Out[2]:
In [3]:
Copied!
# Define the url for the raster file
url = r"https://github.com/opengeos/datasets/releases/download/raster/dem_90m.tif"
# Define the url for the raster file
url = r"https://github.com/opengeos/datasets/releases/download/raster/dem_90m.tif"
In [4]:
Copied!
# Add the raster file to the map with a "terrain" colormap
m.add_raster(url, colormap="terrain", name="dem", opacity=0.5)
m.add_layer_control()
# Add the raster file to the map with a "terrain" colormap
m.add_raster(url, colormap="terrain", name="dem", opacity=0.5)
m.add_layer_control()
Displaying specific bands¶
In [5]:
Copied!
# Add new map
m_2 = beamgis.Map()
m_2
# Add new map
m_2 = beamgis.Map()
m_2
Out[5]:
In [6]:
Copied!
# Add the second raster file to the map
url_2 = "https://github.com/opengeos/datasets/releases/download/raster/LC09_039035_20240708_90m.tif"
# Add the second raster file to the map
url_2 = "https://github.com/opengeos/datasets/releases/download/raster/LC09_039035_20240708_90m.tif"
In [7]:
Copied!
# Add the raster file to the map with specific band indexes and opacity
m_2.add_raster(url_2, indexes=[5, 4, 3], name="landsat", opacity=0.2)
# Add the raster file to the map with specific band indexes and opacity
m_2.add_raster(url_2, indexes=[5, 4, 3], name="landsat", opacity=0.2)
Adding an image overlay¶
In [8]:
Copied!
# Create a new map object for adding an image overlay
image_m = beamgis.Map()
image_m
# Create a new map object for adding an image overlay
image_m = beamgis.Map()
image_m
Out[8]:
In [9]:
Copied!
# Define the URL for the image to be added to the map
image_url = "https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExZWFocm8xeng4aWQ1bXVmcmUyM2gzczlydmhjc2tyMWhhdzlnZzI3ayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/DMUFPG2niG1TW/giphy.gif"
# Define the geographical bounds for the image overlay
bounds = ((13, -150), (40, -120))
# Define the URL for the image to be added to the map
image_url = "https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExZWFocm8xeng4aWQ1bXVmcmUyM2gzczlydmhjc2tyMWhhdzlnZzI3ayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/DMUFPG2niG1TW/giphy.gif"
# Define the geographical bounds for the image overlay
bounds = ((13, -150), (40, -120))
In [10]:
Copied!
# Add an image overlay to the map using the specified image URL and geographical bounds
image_m.add_image(image_url, bounds)
# Add an image overlay to the map using the specified image URL and geographical bounds
image_m.add_image(image_url, bounds)
Adding a video overlay¶
In [11]:
Copied!
# Initialize a new map object for adding a video overlay
video_m = beamgis.Map(center=(40, -120), zoom=3)
video_m
# Initialize a new map object for adding a video overlay
video_m = beamgis.Map(center=(40, -120), zoom=3)
video_m
Out[11]:
In [12]:
Copied!
# Define the URL for the video to be added to the map
url = (
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
)
bounds = ((37.56238816, -122.515963), (37.563391708, -122.5130939))
# Define the URL for the video to be added to the map
url = (
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
)
bounds = ((37.56238816, -122.515963), (37.563391708, -122.5130939))
In [13]:
Copied!
# Add a video overlay to the map
video_m.add_video(url, bounds, name="drone")
# Add a video overlay to the map
video_m.add_video(url, bounds, name="drone")
Adding WMS Layer¶
In [14]:
Copied!
# Add new map
wms_m = beamgis.Map(center=(40, -100), zoom=5)
wms_m
# Add new map
wms_m = beamgis.Map(center=(40, -100), zoom=5)
wms_m
Out[14]:
In [15]:
Copied!
# Define the URL for the WMS service and the layers to be displayed
wms_url = "https://imagery.nationalmap.gov/arcgis/services/USGSNAIPPlus/ImageServer/WMSServer?"
# Define the URL for the WMS service and the layers to be displayed
wms_url = "https://imagery.nationalmap.gov/arcgis/services/USGSNAIPPlus/ImageServer/WMSServer?"
In [16]:
Copied!
# Add the WMS layer to the map
wms_m.add_wms_layer(
wms_url, name="natural color", layers="USGSNAIPPlus:NaturalColor", opacity=0.8
)
# Add the WMS layer to the map
wms_m.add_wms_layer(
wms_url, name="natural color", layers="USGSNAIPPlus:NaturalColor", opacity=0.8
)