Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ee
- import geemap
- import os
- from geemap import cartoee
- import matplotlib.pyplot as plt
- %matplotlib inline
- lon = [lat here]
- lat = [lon here]
- start_date = 1981
- end_date = 2000
- point = ee.Geometry.Point(lon, lat)
- years = ee.List.sequence(start_date, end_date)
- def get_image(years):
- start = ee.Date.fromYMD(start_date, 1, 1)
- end = ee.Date.fromYMD(end_date, 12, 31)
- image = (ee.ImageCollection("ECMWF/ERA5/DAILY")
- .filterBounds(point)
- .filterDate(start, end)
- .select('total_precipitation')
- .first()
- )
- return ee.Image(image)
- collection = ee.ImageCollection(years.map(get_image))
- vis_params = {
- 'min': 0,
- 'max': 0.1,
- 'palette': ['#FFFFFF', '#00FFFF', '#0080FF', '#DA00FF', '#FFA400', '#FF0000']
- }
- image = ee.Image(collection.first())
- geomPoly = ee.Geometry.BBox(10, 10, 10, 10); #dummy coordinates of BB
- region = image.clip(geomPoly)
- Map.addLayer(region, vis_params, 'First Image')
- Map.setCenter(lon, lat, 4)
- fig = plt.figure(figsize=(10, 8))
- selection = [10, 10, 10, 10]
- ax = cartoee.get_map(region, region=selection, vis_params=vis_params)
- ax.set_title(label="South Asia")
- cartoee.get_image_collection_gif(
- ee_ic = collection,
- out_dir=os.path.expanduser("~/Downloads/timelapse"),
- out_gif="animation.gif",
- vis_params=vis_params,
- region=selection,
- fps=3,
- mp4=True,
- plot_title="South Asia | Precipitation",
- date_format="YYYY-MM-dd",
- fig_size=(10, 8),
- dpi_plot=100,
- file_format="png",
- verbose=True
- )
Advertisement
Add Comment
Please, Sign In to add comment