{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "\"Open\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 geemap" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap\n", "from geemap.algorithms import river" ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "Create an interactive map." ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "Find an image by ROI." ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "point = ee.Geometry.Point([-88.08, 37.47])" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "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", "id": "8", "metadata": {}, "source": [ "Add image to the map." ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "Map.addLayer(image, {\"min\": 0, \"max\": 3000, \"bands\": [\"B5\", \"B4\", \"B3\"]}, \"Landsat\")\n", "Map.centerObject(image)" ] }, { "cell_type": "markdown", "id": "10", "metadata": {}, "source": [ "Extract river width for a single image." ] }, { "cell_type": "code", "execution_count": null, "id": "11", "metadata": {}, "outputs": [], "source": [ "river.rwc(image, folder=\"export\", water_method=\"Jones2019\")" ] }, { "cell_type": "markdown", "id": "12", "metadata": {}, "source": [ "Add result to the map." ] }, { "cell_type": "code", "execution_count": null, "id": "13", "metadata": {}, "outputs": [], "source": [ "fc = ee.FeatureCollection(\"users/giswqs/public/river_width\")\n", "Map.addLayer(fc, {}, \"River width\")" ] }, { "cell_type": "markdown", "id": "14", "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, "id": "15", "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, "id": "16", "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", "id": "17", "metadata": {}, "source": [ "Find images by ROI." ] }, { "cell_type": "code", "execution_count": null, "id": "18", "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", "id": "19", "metadata": {}, "source": [ "Get the list of image ids." ] }, { "cell_type": "code", "execution_count": null, "id": "20", "metadata": {}, "outputs": [], "source": [ "ids = images.aggregate_array(\"LANDSAT_ID\").getInfo()\n", "ids" ] }, { "cell_type": "markdown", "id": "21", "metadata": {}, "source": [ "Extract river width for a list of images." ] }, { "cell_type": "code", "execution_count": null, "id": "22", "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 }