{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"geemap_colab.ipynb","provenance":[],"authorship_tag":"ABX9TyMRdgU6/oIRBcgoHSqYrQ+N"},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"markdown","metadata":{"id":"3YfuzRi6yXzE","colab_type":"text"},"source":["\n"," \n"," \n"," \n","
View source on GitHubNotebook Viewer Run in Google Colab
"]},{"cell_type":"markdown","metadata":{"id":"caAZzvnSuwDi","colab_type":"text"},"source":["## Install geemap"]},{"cell_type":"code","metadata":{"id":"d0wqNr5WXzLD","colab_type":"code","colab":{}},"source":["!pip install geemap"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"E1Rtqogbv11h","colab_type":"text"},"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, you should use `import geemap.eefolium as geemap`."]},{"cell_type":"code","metadata":{"id":"rA615jyCYE-z","colab_type":"code","colab":{}},"source":["import ee\n","import geemap.eefolium as geemap"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"bdWLuuJIwwas","colab_type":"text"},"source":["## Create an interactive map"]},{"cell_type":"code","metadata":{"id":"L-CTJwEAvYB0","colab_type":"code","colab":{}},"source":["Map = geemap.Map()\n","# Map"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"ECKnyMyvw6wa","colab_type":"text"},"source":["## Add Earth Engine data"]},{"cell_type":"code","metadata":{"id":"1b8yWFIFvfaZ","colab_type":"code","colab":{}},"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)"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"At6VGzwlxNGb","colab_type":"text"},"source":["## Display the map"]},{"cell_type":"code","metadata":{"id":"IlO11sRAYKCu","colab_type":"code","colab":{}},"source":["Map.addLayerControl() \n","Map"],"execution_count":null,"outputs":[]}]}