{ "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": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap\n", "from geemap.algorithms import river" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create an interactive map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Find an image by ROI." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "point = ee.Geometry.Point([-88.08, 37.47])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "image = (\n", " ee.ImageCollection(\"LANDSAT/LC08/C01/T1_SR\")\n", " .filterBounds(point)\n", " .sort(\"CLOUD_COVER\")\n", " .first()\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add image to the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.addLayer(image, {'min': 0, 'max': 3000, 'bands': ['B5', 'B4', 'B3']}, \"Landsat\")\n", "Map.centerObject(image)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Extract river width for a single image." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "river.rwc(image, folder=\"export\", water_method='Jones2019')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add result to the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fc = ee.FeatureCollection(\"users/giswqs/public/river_width\")\n", "Map.addLayer(fc, {}, \"River width\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add [Global River Width Dataset](https://samapriya.github.io/awesome-gee-community-datasets/projects/grwl) to the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "water_mask = ee.ImageCollection(\n", " \"projects/sat-io/open-datasets/GRWL/water_mask_v01_01\"\n", ").median()\n", "Map.addLayer(water_mask, {'min': 11, 'max': 125, 'palette': 'blue'}, 'GRWL Water Mask')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "grwl_water_vector = ee.FeatureCollection(\n", " \"projects/sat-io/open-datasets/GRWL/water_vector_v01_01\"\n", ")\n", "Map.addLayer(\n", " grwl_water_vector.style(**{'fillColor': '00000000', 'color': 'FF5500'}),\n", " {},\n", " 'GRWL Vector',\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Find images by ROI." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "images = (\n", " ee.ImageCollection(\"LANDSAT/LC08/C01/T1_SR\")\n", " .filterBounds(point)\n", " .sort(\"CLOUD_COVER\")\n", " .limit(3)\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the list of image ids." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ids = images.aggregate_array(\"LANDSAT_ID\").getInfo()\n", "ids" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Extract river width for a list of images." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "river.rwc_batch(ids, folder=\"export\", water_method='Jones2019')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }