{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\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 geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To follow this tutorial, you need to install the [geemap] and [xarray_leaflet](https://github.com/davidbrochart/xarray_leaflet/tree/master/xarray_leaflet) Python packages. Use the following conda commands to create a conda env and install packages:\n", "\n", "- `conda create -n gee python`\n", "- `conda activate gee`\n", "- `conda install mamba -c conda-forge`\n", "- `mamba install geemap xarray_leaflet -c conda-forge`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import libraries" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Specify input raster datasets" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_dir = os.path.expanduser('~/Downloads')\n", "\n", "if not os.path.exists(out_dir):\n", " os.makedirs(out_dir)\n", "\n", "landsat = os.path.join(out_dir, 'landsat.tif')\n", "dem = os.path.join(out_dir, 'dem.tif')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Download samples raster datasets\n", "\n", "More datasets can be downloaded from https://viewer.nationalmap.gov/basic/" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if not os.path.exists(landsat):\n", " landsat_url = 'https://drive.google.com/file/d/1EV38RjNxdwEozjc9m0FcO3LFgAoAX1Uw/view?usp=sharing'\n", " geemap.download_from_gdrive(landsat_url, 'landsat.tif', out_dir, unzip=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if not os.path.exists(dem):\n", " dem_url = 'https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing'\n", " geemap.download_from_gdrive(dem_url, 'dem.tif', out_dir, unzip=False)" ] }, { "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": [ "Add local raster datasets to the map\n", "\n", "More colormap can be found at https://matplotlib.org/stable/tutorials/colors/colormaps.html" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.add_raster(dem, colormap='terrain', layer_name='DEM')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.add_raster(landsat, bands=[5, 4, 3], layer_name='Landsat')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display the map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }