103 split control
Creating a split-panel map
This notebook demonstrates how to add a split-panel map with geemap and folium. It also supports streamlit. Note that the ipyleaflet SplitControl does not support streamlit.
Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
In [2]:
Copied!
import ee
import folium
import geemap.foliumap as geemap
import ee
import folium
import geemap.foliumap as geemap
The split-panel map requires two layers: left_layer
and right_layer
. The layer instance can be a string representing a basemap, or an HTTP URL to a Cloud Optimized GeoTIFF (COG), or a folium TileLayer instance.
Using basemaps
In [3]:
Copied!
m = geemap.Map(height=500)
m.split_map(left_layer='TERRAIN', right_layer='OpenTopoMap')
m
m = geemap.Map(height=500)
m.split_map(left_layer='TERRAIN', right_layer='OpenTopoMap')
m
Out[3]:
Show available basemaps.
In [4]:
Copied!
# geemap.folium_basemaps.keys()
# geemap.folium_basemaps.keys()
Using COG
In [5]:
Copied!
m = geemap.Map(height=600, center=[39.4948, -108.5492], zoom=12)
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
url2 = 'https://opendata.digitalglobe.com/events/california-fire-2020/post-event/2020-08-14/pine-gulch-fire20/10300100AAC8DD00.tif'
m.split_map(url, url2)
m
m = geemap.Map(height=600, center=[39.4948, -108.5492], zoom=12)
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
url2 = 'https://opendata.digitalglobe.com/events/california-fire-2020/post-event/2020-08-14/pine-gulch-fire20/10300100AAC8DD00.tif'
m.split_map(url, url2)
m
Out[5]:
Using folium TileLayer
In [6]:
Copied!
m = geemap.Map(center=[40, -100], zoom=4)
url1 = 'https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2001_Land_Cover_L48/wms?'
url2 = 'https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?'
left_layer = folium.WmsTileLayer(
url=url1,
layers='NLCD_2001_Land_Cover_L48',
name='NLCD 2001',
attr='MRLC',
fmt="image/png",
transparent=True,
)
right_layer = folium.WmsTileLayer(
url=url2,
layers='NLCD_2019_Land_Cover_L48',
name='NLCD 2019',
attr='MRLC',
fmt="image/png",
transparent=True,
)
m.split_map(left_layer, right_layer)
m
m = geemap.Map(center=[40, -100], zoom=4)
url1 = 'https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2001_Land_Cover_L48/wms?'
url2 = 'https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?'
left_layer = folium.WmsTileLayer(
url=url1,
layers='NLCD_2001_Land_Cover_L48',
name='NLCD 2001',
attr='MRLC',
fmt="image/png",
transparent=True,
)
right_layer = folium.WmsTileLayer(
url=url2,
layers='NLCD_2019_Land_Cover_L48',
name='NLCD 2019',
attr='MRLC',
fmt="image/png",
transparent=True,
)
m.split_map(left_layer, right_layer)
m
Out[6]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Using Earth Engine layers
In [7]:
Copied!
m = geemap.Map(center=[39.3322, -106.7349], zoom=10)
m = geemap.Map(center=[39.3322, -106.7349], zoom=10)
In [8]:
Copied!
srtm = ee.Image("USGS/SRTMGL1_003")
hillshade = ee.Terrain.hillshade(srtm)
srtm = ee.Image("USGS/SRTMGL1_003")
hillshade = ee.Terrain.hillshade(srtm)
In [9]:
Copied!
vis = {
'min': 0,
'max': 5000,
'palette': ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
vis = {
'min': 0,
'max': 5000,
'palette': ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
In [10]:
Copied!
left_layer = geemap.ee_tile_layer(hillshade, name='Hillshade')
right_layer = geemap.ee_tile_layer(srtm, vis, name='DEM')
left_layer = geemap.ee_tile_layer(hillshade, name='Hillshade')
right_layer = geemap.ee_tile_layer(srtm, vis, name='DEM')
In [11]:
Copied!
m.split_map(left_layer, right_layer)
m
m.split_map(left_layer, right_layer)
m
Out[11]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Last update:
2022-03-14