{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "![Saudia XYZ logo](http://alasmari.net/saudia-logo.png)\n", "***Code:*** Time Slider
\n", "***Main Source:*** Geemap
\n", "***Edited by:*** Saudia.xyz" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# geemap.update_package()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizing weather data" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e0f8a620ffb941d6b129111396568afc", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map(center=[24, 45], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=HBox(children=(Tog…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Map = geemap.Map(center=(24, 45), zoom=5)\n", "\n", "collection = ee.ImageCollection('NOAA/GFS0P25') \\\n", " .filterDate('2018-12-22', '2018-12-23') \\\n", " .limit(24) \\\n", " .select('temperature_2m_above_ground')\n", "\n", "vis_params = {\n", " 'min': -40.0,\n", " 'max': 35.0,\n", " 'palette': ['blue', 'purple', 'cyan', 'green', 'yellow', 'red']\n", "}\n", "\n", "first_image = collection.first()\n", "\n", "Map.addLayer(first_image, vis_params, \"First image\", False)\n", "Map.setCenter(45, 24, 5)\n", "Map" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00']\n" ] } ], "source": [ "labels = [str(n).zfill(2) + \":00\" for n in range(0, 24)]\n", "print(labels)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "Map.add_time_slider(collection, vis_params, labels=labels, time_interval=1, opacity=0.8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizing vegetation data" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f6c9d5c979824dadab119d60485f43a0", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map(center=[24, 45], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=HBox(children=(Tog…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Map = geemap.Map(center=(24, 45), zoom=5)\n", "\n", "collection = ee.ImageCollection('MODIS/MCD43A4_006_NDVI') \\\n", " .filter(ee.Filter.date('2018-04-01', '2018-05-01')) \\\n", " .select(\"NDVI\")\\\n", "\n", "vis_params = {\n", " 'min': 0.0,\n", " 'max': 1.0,\n", " 'palette': [\n", " 'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',\n", " '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',\n", " '012E01', '011D01', '011301'\n", " ],\n", "}\n", "\n", "first_image = collection.first()\n", "\n", "Map.addLayer(first_image, vis_params, \"First image\", False)\n", "Map.setCenter(45, 24, 5)\n", "Map" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "Map.add_time_slider(collection, vis_params, time_interval=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizing Landsat imagery" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a3121854ca6f49848aa77581c24fbcdf", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map(center=[24, 45], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=HBox(children=(Tog…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Map = geemap.Map(center=(24, 45), zoom=5)\n", "\n", "bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B7']\n", "image = ee.Image('LE7_TOA_5YEAR/1999_2003').select(bands)\n", "vis_params = {'min': 20, 'max': 200, 'gamma': 2.0}\n", "\n", "Map.add_time_slider(image, vis_params, time_interval=1)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualizing Sentinel-2 imagery" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6e6b1da497864856a84b3d98d2741c67", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Map(center=[24.5, 46.5], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=HBox(children=…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Map = geemap.Map(center=[24.5, 46.5], zoom=9)\n", "\n", "S2 = ee.ImageCollection('COPERNICUS/S2_SR') \\\n", " .filterBounds(ee.Geometry.Point([46.5, 24.5])) \\\n", " .filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10)\n", "\n", "vis_params = {\"min\": 0,\n", " \"max\": 4000,\n", " \"bands\": [\"B8\", \"B4\", \"B3\"]}\n", "\n", "Map.addLayer(S2, {}, \"Sentinel-2\", False)\n", "Map.add_time_slider(S2, vis_params)\n", "Map" ] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.4" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }