{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "To follow this tutorial, you will need to [sign up](https://datapane.com/accounts/signup/) for an account with , then install and authenticate the `datapane` Python package. More information can be found [here](https://docs.datapane.com/tutorials/tut-getting-started). \n", "\n", "- `pip install datapane`\n", "- `datapane login`\n", "- `datapane ping`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee \n", "import geemap.eefolium as geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create a map centered at (lat, lon).\n", "Map = geemap.Map(center=[40, -100], zoom=4)\n", "\n", "# Use an elevation dataset and terrain functions to create\n", "# a custom visualization of topography.\n", "\n", "# Load a global elevation image.\n", "elev = ee.Image('USGS/GMTED2010')\n", "\n", "# Zoom to an area of interest.\n", "Map.setCenter(-121.069, 50.709, 6)\n", "\n", "# Add the elevation to the map.\n", "Map.addLayer(elev, {}, 'elev')\n", "\n", "# Use the terrain algorithms to compute a hillshade with 8-bit values.\n", "shade = ee.Terrain.hillshade(elev)\n", "Map.addLayer(shade, {}, 'hillshade', False)\n", "\n", "# Create a \"sea\" variable to be used for cartographic purposes\n", "sea = elev.lte(0)\n", "Map.addLayer(sea.mask(sea), {'palette':'000022'}, 'sea', False)\n", "\n", "# Create a custom elevation palette from hex strings.\n", "elevationPalette = ['006600', '002200', 'fff700', 'ab7634', 'c4d0ff', 'ffffff']\n", "# Use these visualization parameters, customized by location.\n", "visParams = {'min': 1, 'max': 3000, 'palette': elevationPalette}\n", "\n", "# Create a mosaic of the sea and the elevation data\n", "visualized = ee.ImageCollection([\n", " # Mask the elevation to get only land\n", " elev.mask(sea.Not()).visualize(**visParams),\n", " # Use the sea mask directly to display sea.\n", " sea.mask(sea).visualize(**{'palette':'000022'})\n", "]).mosaic()\n", "\n", "# Note that the visualization image doesn't require visualization parameters.\n", "Map.addLayer(visualized, {}, 'elev palette', False)\n", "\n", "# Convert the visualized elevation to HSV, first converting to [0, 1] data.\n", "hsv = visualized.divide(255).rgbToHsv()\n", "# Select only the hue and saturation bands.\n", "hs = hsv.select(0, 1)\n", "# Convert the hillshade to [0, 1] data, as expected by the HSV algorithm.\n", "v = shade.divide(255)\n", "# Create a visualization image by converting back to RGB from HSV.\n", "# Note the cast to byte in order to export the image correctly.\n", "rgb = hs.addBands(v).hsvToRgb().multiply(255).byte()\n", "Map.addLayer(rgb, {}, 'styled')\n", "\n", "states = ee.FeatureCollection('TIGER/2018/States')\n", "Map.addLayer(ee.Image().paint(states, 0, 2), {}, \"US States\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Add layer control to the map.\n", "Map.setControlVisibility()\n", "# Display the map.\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map.publish(name='gee_folium_map', headline='Terrain Visualization', visibility='PUBLIC', overwrite=True)" ] } ], "metadata": { "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.2" }, "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": { "height": "calc(100% - 180px)", "left": "10px", "top": "150px", "width": "318px" }, "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 }