{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed.\n", "\n", "[Landsat 9](https://landsat.gsfc.nasa.gov/satellites/landsat-9) was successfully launched on Sept. 27, 2021. USGS has been providing Landsat data to the public since Feb. 10, 2022. Landsat 9 data can be downloaded from [EarthExplorer](https://earthexplorer.usgs.gov). The Earth Engine team has been ingesting Landsat 9 into the Public Data Catalog. As of Feb. 14, 2022, although Landsat 9 data have not been publicly listed on the [Earth Engine Datasets](https://developers.google.com/earth-engine/datasets) page, you can access the data through `ee.ImageCollection('LANDSAT/LC09/C02/T1_L2')` ." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import libraries." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create an interactive map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Find out how many Landsat imgaes are available." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "collection = ee.ImageCollection('LANDSAT/LC09/C02/T1_L2')\n", "print(collection.size().getInfo())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a median composite." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "median = collection.median()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Apply scaling factors. See https://developers.google.com/earth-engine/datasets/catalog/LANDSAT_LC08_C02_T1_L2#bands" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def apply_scale_factors(image):\n", " opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2)\n", " thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0)\n", " return image.addBands(opticalBands, None, True).addBands(thermalBands, None, True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "dataset = apply_scale_factors(median)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Specify visualization parameters." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis_natural = {\n", " 'bands': ['SR_B4', 'SR_B3', 'SR_B2'],\n", " 'min': 0.0,\n", " 'max': 0.3,\n", "}\n", "\n", "vis_nir = {\n", " 'bands': ['SR_B5', 'SR_B4', 'SR_B3'],\n", " 'min': 0.0,\n", " 'max': 0.3,\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add data layers to the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.addLayer(dataset, vis_natural, 'True color (432)')\n", "Map.addLayer(dataset, vis_nir, 'Color infrared (543)')\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/USPMXzw.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create linked maps for visualizing images with different band combinations. For more information on common band combinations of Landsat 8/9, see https://gisgeography.com/landsat-8-bands-combinations/" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Specify visualization parameters." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis_params = [\n", " {'bands': ['SR_B4', 'SR_B3', 'SR_B2'], 'min': 0, 'max': 0.3},\n", " {'bands': ['SR_B5', 'SR_B4', 'SR_B3'], 'min': 0, 'max': 0.3},\n", " {'bands': ['SR_B7', 'SR_B6', 'SR_B4'], 'min': 0, 'max': 0.3},\n", " {'bands': ['SR_B6', 'SR_B5', 'SR_B2'], 'min': 0, 'max': 0.3},\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Specify labels for each layers." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "labels = [\n", " 'Natural Color (4, 3, 2)',\n", " 'Color Infrared (5, 4, 3)',\n", " 'Short-Wave Infrared (7, 6 4)',\n", " 'Agriculture (6, 5, 2)',\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create linked maps." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.linked_maps(\n", " rows=2,\n", " cols=2,\n", " height=\"400px\",\n", " center=[40, -100],\n", " zoom=4,\n", " ee_objects=[dataset],\n", " vis_params=vis_params,\n", " labels=labels,\n", " label_position=\"topright\",\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/c4FsGBI.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a split-panel map for comparing Landsat 8 and 9 images.\n", "\n", "Retrieve two sample images." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "landsat8 = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_015043_20130402')\n", "landsat9 = ee.Image('LANDSAT/LC09/C02/T1_L2/LC09_015043_20211231')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Apply scaling factors." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "landsat8 = apply_scale_factors(landsat8)\n", "landsat9 = apply_scale_factors(landsat9)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Generate Earth Engine layers." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "left_layer = geemap.ee_tile_layer(landsat8, vis_natural, 'Landsat 8')\n", "right_layer = geemap.ee_tile_layer(landsat9, vis_natural, 'Landsat 9')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a split-panel map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map.split_map(left_layer, right_layer)\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/i6lUYHF.png)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }