{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\n", "\n", "**Downloading Earth Engine images in parallel**\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install -U geemap geedim" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add a Landsat imagery to the map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map(center=[40, -100], zoom=4)\n", "image = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(['B4', 'B3', 'B2'])\n", "Map.addLayer(image, {'min': 20, 'max': 200, 'gamma': 2.0}, 'Landsat')\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Specify a region of interest." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "region = ee.Geometry.BBox(-112.5439, 34.0891, -85.0342, 49.6858)\n", "Map.addLayer(region, {}, 'ROI')\n", "Map.centerObject(region)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a fishnet." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fishnet = geemap.fishnet(region, h_interval=4.0, v_interval=4.0, delta=0.5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add the fishnet to the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "style = {'color': 'ffff00ff', 'fillColor': '00000000'}\n", "Map.addLayer(fishnet.style(**style), {}, 'Fishnet')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Download images by the fishnet cells in parallel." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.download_ee_image_tiles_parallel(\n", " image, fishnet, out_dir='tiles', scale=1000, crs='EPSG:3857')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The parallel downloading above takes ~10 seconds. The serial downloading below takes ~60 seconds." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.download_ee_image_tiles(\n", " image, fishnet, out_dir='tiles', scale=1000, crs='EPSG:3857'\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/L1IH3fq.png)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.9" } }, "nbformat": 4, "nbformat_minor": 5 }