{ "cells": [ { "cell_type": "markdown", "id": "0", "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, "id": "1", "metadata": {}, "outputs": [], "source": [ "# !pip install -U geemap geedim" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "Add a Landsat imagery to the map" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "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", "id": "5", "metadata": {}, "source": [ "Specify a region of interest." ] }, { "cell_type": "code", "execution_count": null, "id": "6", "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", "id": "7", "metadata": {}, "source": [ "Create a fishnet." ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "fishnet = geemap.fishnet(region, h_interval=4.0, v_interval=4.0, delta=0.5)" ] }, { "cell_type": "markdown", "id": "9", "metadata": {}, "source": [ "Add the fishnet to the map." ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "style = {\"color\": \"ffff00ff\", \"fillColor\": \"00000000\"}\n", "Map.addLayer(fishnet.style(**style), {}, \"Fishnet\")" ] }, { "cell_type": "markdown", "id": "11", "metadata": {}, "source": [ "Download images by the fishnet cells in parallel." ] }, { "cell_type": "code", "execution_count": null, "id": "12", "metadata": {}, "outputs": [], "source": [ "geemap.download_ee_image_tiles_parallel(\n", " image, fishnet, out_dir=\"tiles\", scale=1000, crs=\"EPSG:3857\"\n", ")" ] }, { "cell_type": "markdown", "id": "13", "metadata": {}, "source": [ "The parallel downloading above takes ~10 seconds. The serial downloading below takes ~60 seconds." ] }, { "cell_type": "code", "execution_count": null, "id": "14", "metadata": {}, "outputs": [], "source": [ "geemap.download_ee_image_tiles(\n", " image, fishnet, out_dir=\"tiles\", scale=1000, crs=\"EPSG:3857\"\n", ")" ] }, { "cell_type": "markdown", "id": "15", "metadata": {}, "source": [ "![](https://i.imgur.com/L1IH3fq.png)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }