Raster Data Visualization¶
This notebook will show you examples on how to display Raster data, images, videos and WMS data.
LeafMap¶
This section will show how to use the LeafMap module.
Requirement¶
Load the LeafMap module.
In [1]:
Copied!
from cookiecutter_practice import LeafMap
from cookiecutter_practice import LeafMap
Displaying a Raster Data Layer¶
In [2]:
Copied!
lf = LeafMap.Map(zoom=5)
raster_path = ("https://storage.googleapis.com/philsa-space-data-dashboard/LandCoverAndLandUse/2022_LandCover_4326_new.tif")
lf.add_raster(
raster_path,
name="Land Cover and Land Use",
opacity=0.8,
attribution="© PhilSA | CC BY 4.0 | https://philsa.gov.ph/philippine-space-data-dashboard/",
)
lf.add_layer_control()
lf
lf = LeafMap.Map(zoom=5)
raster_path = ("https://storage.googleapis.com/philsa-space-data-dashboard/LandCoverAndLandUse/2022_LandCover_4326_new.tif")
lf.add_raster(
raster_path,
name="Land Cover and Land Use",
opacity=0.8,
attribution="© PhilSA | CC BY 4.0 | https://philsa.gov.ph/philippine-space-data-dashboard/",
)
lf.add_layer_control()
lf
Out[2]:
Displaying an Image Layer¶
In [3]:
Copied!
import rasterio
img_tiff = "https://storage.googleapis.com/dpad-bucket/D2/smi/D2_SMI_2020-03-22T053207_2020-03-22T235959_L1C_COG.tif"
# This will be used for retrieving the metadata of the image(e.g. Bounds)
img_raster = rasterio.open(img_tiff)
lf = LeafMap.Map(zoom=5)
lf.add_image("https://storage.googleapis.com/dpad-bucket/D2/thumbnail/D2_SMI_2020-03-22T053207_2020-03-22T235959_THUMB.png", bounds=((img_raster.bounds[1],img_raster.bounds[0]), (img_raster.bounds[3],img_raster.bounds[2])), name="SMI")
lf.add_layer_control()
lf
import rasterio
img_tiff = "https://storage.googleapis.com/dpad-bucket/D2/smi/D2_SMI_2020-03-22T053207_2020-03-22T235959_L1C_COG.tif"
# This will be used for retrieving the metadata of the image(e.g. Bounds)
img_raster = rasterio.open(img_tiff)
lf = LeafMap.Map(zoom=5)
lf.add_image("https://storage.googleapis.com/dpad-bucket/D2/thumbnail/D2_SMI_2020-03-22T053207_2020-03-22T235959_THUMB.png", bounds=((img_raster.bounds[1],img_raster.bounds[0]), (img_raster.bounds[3],img_raster.bounds[2])), name="SMI")
lf.add_layer_control()
lf
Out[3]:
Displaying a Video Layer¶
In [4]:
Copied!
lf = LeafMap.Map(zoom=5)
lf.add_video(
url="https://data.opengeos.org/patricia_nasa.mp4",
name="Patricia NASA Video",
bounds=((13, -130), (32, -100)),
autoplay=True,
loop=True
)
# Note: Video may not be visible when running the notebook in VSCode
lf.add_layer_control()
lf
lf = LeafMap.Map(zoom=5)
lf.add_video(
url="https://data.opengeos.org/patricia_nasa.mp4",
name="Patricia NASA Video",
bounds=((13, -130), (32, -100)),
autoplay=True,
loop=True
)
# Note: Video may not be visible when running the notebook in VSCode
lf.add_layer_control()
lf
Out[4]:
Displaying a WMS Layer¶
In [5]:
Copied!
lf = LeafMap.Map(zoom=2)
lf.add_wms_layer(
url="https://ows.terrestris.de/osm/service",
layers="OSM-WMS",
name="WMS Layer",
format="image/png",
transparent=True,
)
lf.add_layer_control()
lf
lf = LeafMap.Map(zoom=2)
lf.add_wms_layer(
url="https://ows.terrestris.de/osm/service",
layers="OSM-WMS",
name="WMS Layer",
format="image/png",
transparent=True,
)
lf.add_layer_control()
lf
Out[5]:
FoliumMap¶
This section will show how to use the FoliumMap module.
Requirement¶
Load the FoliumMap module.
In [6]:
Copied!
from cookiecutter_practice import FoliumMap
from cookiecutter_practice import FoliumMap
Displaying a Raster Data Layer¶
In [7]:
Copied!
fm = FoliumMap.Map(zoom=5)
raster_path = ("https://storage.googleapis.com/philsa-space-data-dashboard/LandCoverAndLandUse/2022_LandCover_4326_new.tif")
fm.add_raster(raster_path, name="Land Cover and Land Use", opacity=0.8)
fm.add_layer_control()
fm
fm = FoliumMap.Map(zoom=5)
raster_path = ("https://storage.googleapis.com/philsa-space-data-dashboard/LandCoverAndLandUse/2022_LandCover_4326_new.tif")
fm.add_raster(raster_path, name="Land Cover and Land Use", opacity=0.8)
fm.add_layer_control()
fm
Out[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Displaying an Image Layer¶
In [8]:
Copied!
import rasterio
img_tiff = "https://storage.googleapis.com/dpad-bucket/D2/smi/D2_SMI_2020-03-22T053207_2020-03-22T235959_L1C_COG.tif"
# This will be used for retrieving the metadata of the image(e.g. Bounds)
img_raster = rasterio.open(img_tiff)
fm = FoliumMap.Map(zoom=5)
fm.add_image("https://storage.googleapis.com/dpad-bucket/D2/thumbnail/D2_SMI_2020-03-22T053207_2020-03-22T235959_THUMB.png", bounds=((img_raster.bounds[1],img_raster.bounds[0]), (img_raster.bounds[3],img_raster.bounds[2])), name="SMI")
fm.add_layer_control()
fm
import rasterio
img_tiff = "https://storage.googleapis.com/dpad-bucket/D2/smi/D2_SMI_2020-03-22T053207_2020-03-22T235959_L1C_COG.tif"
# This will be used for retrieving the metadata of the image(e.g. Bounds)
img_raster = rasterio.open(img_tiff)
fm = FoliumMap.Map(zoom=5)
fm.add_image("https://storage.googleapis.com/dpad-bucket/D2/thumbnail/D2_SMI_2020-03-22T053207_2020-03-22T235959_THUMB.png", bounds=((img_raster.bounds[1],img_raster.bounds[0]), (img_raster.bounds[3],img_raster.bounds[2])), name="SMI")
fm.add_layer_control()
fm
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Displaying a Video Layer¶
In [9]:
Copied!
fm = FoliumMap.Map(zoom=5)
fm.add_video(url="https://data.opengeos.org/patricia_nasa.mp4", name="Patricia NASA Video", bounds=((13, -130), (32, -100)), autoplay=True, loop=True, opacity=0.8)
fm.add_layer_control()
fm
fm = FoliumMap.Map(zoom=5)
fm.add_video(url="https://data.opengeos.org/patricia_nasa.mp4", name="Patricia NASA Video", bounds=((13, -130), (32, -100)), autoplay=True, loop=True, opacity=0.8)
fm.add_layer_control()
fm
Out[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Displaying a WMS Layer¶
In [10]:
Copied!
fm = FoliumMap.Map(zoom=2)
fm.add_wms_layer(url="https://ows.terrestris.de/osm/service", layers="OSM-WMS", name="WMS Layer", format="image/png", transparent=True)
fm.add_layer_control()
fm
fm = FoliumMap.Map(zoom=2)
fm.add_wms_layer(url="https://ows.terrestris.de/osm/service", layers="OSM-WMS", name="WMS Layer", format="image/png", transparent=True)
fm.add_layer_control()
fm
Out[10]:
Make this Notebook Trusted to load map: File -> Trust Notebook