#!/usr/bin/env python # coding: utf-8 # # Digitales Daumenkino mit Satellitenbildern selbst erstellen # 16. Dezember 2021 - DGfK - CartoHack #08 # ### Installation benötigter Python Pakete # https://github.com/BostelmannLGLN/LGLN-OpenData-Notebooks/blob/main/requirements.txt # In[ ]: #!pip install -r requirements.txt # ### Imports # In[ ]: from pathlib import Path import rasterio from rasterio.plot import show import matplotlib.pyplot as plt from IPython.display import Video import animation, functions # In[ ]: tmp_path = Path('sentinel-2-tmp') # ### Geometrie der Kacheln für Niedersachsen laden # In[ ]: name, be_name, area, tiles = functions.load_tiles(region='NI', use_cos=True) #name, be_name, area, tiles = functions.load_tiles(region='NI', landkreis='Hannover', use_cos=True) #tiles.plot(edgecolor='black', figsize=(16, 16)) # ## Kachel und Zeitraum auswählen # TODO: Auswahl per Karte # In[ ]: tiles.explore() # ### Alles Auswählen # In[ ]: selected_tiles = tiles # ### Einzelne Kacheln Auswählen (Beispiele) # In[ ]: tile_nrs = ['8-25245768'] name = 'Hameln' # In[ ]: tile_nrs = ['8-25405800'] name = 'Hannover-Limmer' # In[ ]: tile_nrs = ['8-25485800'] name = 'Hannover-Eilenriede' # In[ ]: tile_nrs = ['8-25965736'] name = 'Harz (Okertalsperre)' # In[ ]: tile_nrs = ['8-25885736'] name = 'Clausthal-Zellerfeld' # In[ ]: selected_tiles = tiles[tiles['be8_nr'].isin(tile_nrs)] selected_tiles # ### Zeitraum und Dateiendung # In[ ]: # Datum date_str = '2021' # e.g. '20' or '2020' or '202009' or '20200921' # Dateiendung: z.B.: 'TCI_10m' oder '0m' channel = 'TCI_10m' # ## Kacheln vom COS laden # In[ ]: bucket = { 'endpoint_url': 'https://cloud.code-de.org:8080/swift/v1/AUTH_622a231224cb46c6982643e55e817c98/', 'name': 'tiles' } # In[ ]: selected_tiles, dates, tiles_count = functions.available_dates(selected_tiles, date_str, bucket) dates # ## Animation erstellen # In[ ]: logo_path = (Path('./logos/cartohack_logo_left.png'), Path('./logos/logo_right.png')) #dates = ['20170328','20210330'] # Beispiel Clausthal-Zellerfeld #dates = ['20160505', '20170719', '20180505', '20190425', '20200419', '20210509'] #Beispiel-Limmer for tile_nr in selected_tiles.index: animation_path = animation.animate_tiles_from_cos(tile_nr, dates, bucket_credentials=bucket, tmp_path=tmp_path, type='mp4', channel='TCI_10m', duration=0.4, add_bar=True, add_name=True, center_text='8 km x 8 km ', logo_path=logo_path, name=name) Video(animation_path, html_attributes='loop autoplay')