{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "3YfuzRi6yXzE" }, "source": [ "\"Open\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "d0wqNr5WXzLD" }, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "E1Rtqogbv11h" }, "source": [ "## Import geemap library\n", "\n", "The [geemap](https://github.com/giswqs/geemap) Python package has two plotting backends: [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) and [folium](https://github.com/python-visualization/folium). A key difference between folium and ipyleaflet is that ipyleaflet is built upon ipywidgets and allows bidirectional communication between the front-end and the backend enabling the use of the map to capture user input, while folium is meant for displaying static data only ([source](https://blog.jupyter.org/interactive-gis-in-jupyter-with-ipyleaflet-52f9657fa7a)). Note that Google Colab currently does not support ipyleaflet ([source](https://github.com/googlecolab/colabtools/issues/60#issuecomment-596225619)). Therefore, if you are using geemap with Google Colab, geemap will automatically use the folium plotting backend." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "rA615jyCYE-z" }, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "bdWLuuJIwwas" }, "source": [ "## Create an interactive map" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "L-CTJwEAvYB0" }, "outputs": [], "source": [ "Map = geemap.Map()" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "ECKnyMyvw6wa" }, "source": [ "## Add Earth Engine data" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "1b8yWFIFvfaZ" }, "outputs": [], "source": [ "# Add Earth Engine dataset\n", "image = ee.Image('USGS/SRTMGL1_003')\n", "\n", "# Set visualization parameters.\n", "vis_params = {\n", " 'min': 0,\n", " 'max': 4000,\n", " 'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}\n", "\n", "# Print the elevation of Mount Everest.\n", "xy = ee.Geometry.Point([86.9250, 27.9881])\n", "elev = image.sample(xy, 30).first().get('elevation').getInfo()\n", "print('Mount Everest elevation (m):', elev)\n", "\n", "# Add Earth Engine layers to Map\n", "Map.addLayer(image, vis_params, 'DEM')\n", "Map.addLayer(xy, {'color': 'red'}, 'Mount Everest')\n", "\n", "# Center the map based on an Earth Engine object or coordinates (longitude, latitude)\n", "# Map.centerObject(xy, 4)\n", "Map.setCenter(86.9250, 27.9881, 4)" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "At6VGzwlxNGb" }, "source": [ "## Display the map" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": {}, "colab_type": "code", "id": "IlO11sRAYKCu" }, "outputs": [], "source": [ "Map.addLayerControl() \n", "Map" ] } ], "metadata": { "colab": { "authorship_tag": "ABX9TyMRdgU6/oIRBcgoHSqYrQ+N", "name": "geemap_colab.ipynb", "provenance": [] }, "hide_input": false, "kernelspec": { "display_name": "Python 3", "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.8.5" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Table of Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": true }, "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 }