Raster Analysis and Add Image or GIF¶
In [1]:
Copied!
# pip install geohub
# pip install geohub
In [2]:
Copied!
import geohub
m = geohub.Map()
url="https://i.imgur.com/06Q1fSz.png"
# url='../06Q1fSz.png',
bounds=((13, -130), (32, -100))
m.add_image(url, bounds)
#m.add_layers_control()
m.scroll_wheel_zoom = True
m
import geohub
m = geohub.Map()
url="https://i.imgur.com/06Q1fSz.png"
# url='../06Q1fSz.png',
bounds=((13, -130), (32, -100))
m.add_image(url, bounds)
#m.add_layers_control()
m.scroll_wheel_zoom = True
m
Out[2]:
In [3]:
Copied!
# Add gif
m = geohub.Map()
url="https://www.reactiongifs.com/r/cheering_minions.gif"
# url='../06Q1fSz.png',
bounds=((3, -100), (32, 10))
m.add_image(url, bounds)
#m.add_layers_control()
m
# Add gif
m = geohub.Map()
url="https://www.reactiongifs.com/r/cheering_minions.gif"
# url='../06Q1fSz.png',
bounds=((3, -100), (32, 10))
m.add_image(url, bounds)
#m.add_layers_control()
m
Out[3]:
In [4]:
Copied!
# pip install localtileserver
# pip install localtileserver
In [5]:
Copied!
m.layers
m.layers
Out[5]:
(TileLayer(attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', base=True, max_zoom=19, min_zoom=1, name='OpenStreetMap.Mapnik', options=['attribution', 'bounds', 'detect_retina', 'max_native_zoom', 'max_zoom', 'min_native_zoom', 'min_zoom', 'no_wrap', 'tile_size', 'tms', 'zoom_offset'], url='https://tile.openstreetmap.org/{z}/{x}/{y}.png'),
ImageOverlay(bounds=[(3, -100), (32, 10)], name='image', options=['attribution'], url='https://www.reactiongifs.com/r/cheering_minions.gif'))
In [6]:
Copied!
# import matplotlib.pyplot as plt
# from ipyleaflet import Map, ImageOverlay
# import matplotlib.pyplot as plt
# from ipyleaflet import Map, ImageOverlay
In [7]:
Copied!
import geohub
m = geohub.Map()
data = 'https://github.com/opengeos/datasets/releases/download/raster/srtm90.tif'
m.add_raster(data, name = 'DEM')
# m.add_layers_control()
m
import geohub
m = geohub.Map()
data = 'https://github.com/opengeos/datasets/releases/download/raster/srtm90.tif'
m.add_raster(data, name = 'DEM')
# m.add_layers_control()
m
Out[7]:
In [8]:
Copied!
import geohub
m = geohub.Map()
data = 'https://github.com/opengeos/datasets/releases/download/raster/srtm90.tif'
m.add_raster(data, name = 'DEM', colormap = 'terrain')
# m.add_layers_control()
m
import geohub
m = geohub.Map()
data = 'https://github.com/opengeos/datasets/releases/download/raster/srtm90.tif'
m.add_raster(data, name = 'DEM', colormap = 'terrain')
# m.add_layers_control()
m
Out[8]:
In [9]:
Copied!
import geohub
m = geohub.Map()
# Iterate over years from 1984 to 2022
for year in range(1984, 2023):
landsat_file = f"landsat/{year}.tif"
m.add_raster(landsat_file, name=str(year), colormap='terrain')
# Add the layers to the map
m
import geohub
m = geohub.Map()
# Iterate over years from 1984 to 2022
for year in range(1984, 2023):
landsat_file = f"landsat/{year}.tif"
m.add_raster(landsat_file, name=str(year), colormap='terrain')
# Add the layers to the map
m
Out[9]:
In [10]:
Copied!
import geohub
m = geohub.Map()
layers = {}
for year in range(1984, 2023):
landsat_file = f"landsat/{year}.tif"
layer_name = str(year)
layers[layer_name] = landsat_file
m.add_time_slider(layers=layers, time_intervals=list(range(1984, 2023)), position="bottomleft")
m
import geohub
m = geohub.Map()
layers = {}
for year in range(1984, 2023):
landsat_file = f"landsat/{year}.tif"
layer_name = str(year)
layers[layer_name] = landsat_file
m.add_time_slider(layers=layers, time_intervals=list(range(1984, 2023)), position="bottomleft")
m
Out[10]:
In [11]:
Copied!
from PIL import Image
import os
# Create a list to hold the images
images = []
# Iterate over years from 1984 to 2022
for year in range(1984, 2023):
landsat_file = f"landsat/{year}.tif"
# Open the image file
img = Image.open(landsat_file)
# Append the image to the list
images.append(img)
# Save the images as a GIF
images[0].save('landsat.gif', save_all=True, append_images=images[1:], loop=0, duration=200)
from PIL import Image
import os
# Create a list to hold the images
images = []
# Iterate over years from 1984 to 2022
for year in range(1984, 2023):
landsat_file = f"landsat/{year}.tif"
# Open the image file
img = Image.open(landsat_file)
# Append the image to the list
images.append(img)
# Save the images as a GIF
images[0].save('landsat.gif', save_all=True, append_images=images[1:], loop=0, duration=200)