Time slider
Uncomment the following line to install beamgis if needed.¶
In [1]:
Copied!
# !pip install beamgis
# !pip install beamgis
In [2]:
Copied!
import beamgis
import os
import beamgis
import os
In [3]:
Copied!
# Set an environment variable with a specific key and value.
# This key is likely used for authentication or configuration purposes in the application.
os.environ["PLAK6d14428f432246128315488647ccf9b3"] = "12345"
# Set an environment variable with a specific key and value.
# This key is likely used for authentication or configuration purposes in the application.
os.environ["PLAK6d14428f432246128315488647ccf9b3"] = "12345"
In [4]:
Copied!
m = beamgis.Map(center=[38.2659, -103.2447], zoom=13)
m
m = beamgis.Map(center=[38.2659, -103.2447], zoom=13)
m
Out[4]:
In [5]:
Copied!
# Create a new map instance
m = beamgis.Map()
# Retrieve quarterly tiles from Planet using the provided API key
layers_dict = beamgis.planet_quarterly_tiles("PLAK6d14428f432246128315488647ccf9b3")
# Add a time slider to the map with the retrieved layers and a time interval of 1
m.add_time_slider(layers_dict, time_interval=1)
# Display the map
m
# Create a new map instance
m = beamgis.Map()
# Retrieve quarterly tiles from Planet using the provided API key
layers_dict = beamgis.planet_quarterly_tiles("PLAK6d14428f432246128315488647ccf9b3")
# Add a time slider to the map with the retrieved layers and a time interval of 1
m.add_time_slider(layers_dict, time_interval=1)
# Display the map
m
Out[5]:
In [6]:
Copied!
m = beamgis.Map()
m.clear_layers()
layers_dict = beamgis.basemap_xyz_tiles()
m.add_time_slider(layers_dict, time_interval=1)
m
m = beamgis.Map()
m.clear_layers()
layers_dict = beamgis.basemap_xyz_tiles()
m.add_time_slider(layers_dict, time_interval=1)
m
Out[6]:
Use the time slider to visualize COG assets found within STAC items.¶
In [7]:
Copied!
import ipyleaflet
import json
import requests
stac_api = "https://earth-search.aws.element84.com/v0"
search_endpoint = f"{stac_api}/search"
collection = "sentinel-s2-l2a-cogs"
payload = {
"bbox": [
-102.83340454101562,
49.77860375256143,
-102.41043090820312,
50.05273014900257,
],
"datetime": "2021-07-01T00:00:00Z/2021-10-01T12:31:12Z",
"collections": [collection],
"limit": 10,
"query": {"eo:cloud_cover": {"gte": 0, "lte": 10}},
}
headers = {"Content-Type": "application/json"}
response = requests.request(
"POST", search_endpoint, headers=headers, data=json.dumps(payload)
)
features = response.json()["features"]
features.sort(key=lambda x: x["properties"]["datetime"], reverse=False)
layers_dict = {}
for feature in features:
feature_id = feature["id"]
print(feature_id)
url = beamgis.stac_tile(
f"{stac_api}/collections/{collection}/items/{feature_id}", bands=["visual"]
)
tile_layer = ipyleaflet.TileLayer(
url=url,
name=feature_id,
)
layers_dict[feature_id] = tile_layer
m = beamgis.Map(center=[50.093079, -103.152825], zoom=11)
m.add_time_slider(layers_dict, time_interval=2)
m
import ipyleaflet
import json
import requests
stac_api = "https://earth-search.aws.element84.com/v0"
search_endpoint = f"{stac_api}/search"
collection = "sentinel-s2-l2a-cogs"
payload = {
"bbox": [
-102.83340454101562,
49.77860375256143,
-102.41043090820312,
50.05273014900257,
],
"datetime": "2021-07-01T00:00:00Z/2021-10-01T12:31:12Z",
"collections": [collection],
"limit": 10,
"query": {"eo:cloud_cover": {"gte": 0, "lte": 10}},
}
headers = {"Content-Type": "application/json"}
response = requests.request(
"POST", search_endpoint, headers=headers, data=json.dumps(payload)
)
features = response.json()["features"]
features.sort(key=lambda x: x["properties"]["datetime"], reverse=False)
layers_dict = {}
for feature in features:
feature_id = feature["id"]
print(feature_id)
url = beamgis.stac_tile(
f"{stac_api}/collections/{collection}/items/{feature_id}", bands=["visual"]
)
tile_layer = ipyleaflet.TileLayer(
url=url,
name=feature_id,
)
layers_dict[feature_id] = tile_layer
m = beamgis.Map(center=[50.093079, -103.152825], zoom=11)
m.add_time_slider(layers_dict, time_interval=2)
m
S2A_13UFR_20210710_0_L2A
S2B_13UFR_20210715_0_L2A
S2B_13UFR_20210718_0_L2A
S2A_13UFR_20210723_0_L2A
S2B_13UFR_20210725_0_L2A
S2A_13UFR_20210730_0_L2A
S2B_13UFR_20210814_0_L2A
S2A_13UFR_20210908_0_L2A
S2A_13UFR_20210918_0_L2A
S2A_13UFR_20210928_0_L2A
Out[7]:
In [ ]:
Copied!