{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\n", "\n", "**Download images directly to a local computer**\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" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import ee\n", "import geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download a single image" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "image = ee.ImageCollection(\"LANDSAT/LC08/C02/T1_TOA\").first()\n", "Map.addLayer(image, {}, 'Landsat')\n", "Map.centerObject(image)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.download_ee_image(image, \"landsat.tif\", scale=100)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download an image collection" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_dir = os.path.expanduser('~/Downloads')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "loc = ee.Geometry.Point(-99.2222, 46.7816)\n", "collection = (\n", " ee.ImageCollection('USDA/NAIP/DOQQ')\n", " .filterBounds(loc)\n", " .filterDate('2008-01-01', '2020-01-01')\n", " .filter(ee.Filter.listContains(\"system:band_names\", \"N\"))\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.download_ee_image_collection(collection, out_dir, scale=10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download image by tile" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "\n", "image = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003')\n", "\n", "landsat_vis = {'bands': ['B4', 'B3', 'B2'], 'gamma': 2}\n", "Map.addLayer(image, landsat_vis, \"LE7_TOA_5YEAR/1999_2003\", True, 1)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "region = ee.Geometry.BBox(-115.6339, 35.7529, -113.9338, 36.7012)\n", "Map.centerObject(region)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "features = geemap.fishnet(region, rows=2, cols=2)\n", "Map.addLayer(features, {}, 'Grids')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.download_ee_image_tiles(\n", " image, features, out_dir, prefix=\"landsat_\", crs=\"EPSG:3857\", scale=30\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }