Created
June 30, 2020 22:15
-
-
Save giswqs/62774e84ec50cfb63875134ce45dd111 to your computer and use it in GitHub Desktop.
geemap-datapane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "import folium\nimport datapane as dp \nimport geemap.eefolium as geemap\nimport ee\nimport os\n\n# # ee_token = os.environ['EARTHENGINE_TOKEN']\n# secret = dp.Variable.get(name='EARTHENGINE_TOKEN')\n# # secret = dp.Variable.get(name='EARTHENGINE_TOKEN', owner='giswqs')\n# ee_token = secret.value\n\n# credential = '{\"refresh_token\":\"%s\"}' % ee_token\n# credential_file_path = os.path.expanduser(\"~/.config/earthengine/\")\n# os.makedirs(credential_file_path, exist_ok=True)\n# with open(credential_file_path + 'credentials', 'w') as file:\n# file.write(credential)\n\n# m = folium.Map(location=[45.5236, -122.6750])\nee.Initialize()\nMap = geemap.Map(center=[40,-100], zoom=4)\nMap.add_basemap('ROADMAP') # Add Google Map\n\n# Add Earth Engine dataset\nimage = ee.Image('USGS/SRTMGL1_003')\n\n# Set visualization parameters.\nvis_params = {\n 'min': 0,\n 'max': 4000,\n 'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}\n\n# Print the elevation of Mount Everest.\nxy = ee.Geometry.Point([86.9250, 27.9881])\nelev = image.sample(xy, 30).first().get('elevation').getInfo()\nprint('Mount Everest elevation (m):', elev)\n\n# Add Earth Engine layers to Map\nMap.addLayer(image, vis_params, 'DEM')\nMap.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)\nMap.setCenter(86.9250, 27.9881, 4)\n\n# Map.addLayerControl() # This line is not needed for ipyleaflet-based Map.\nMap.setControlVisibility()\n\n# dp.Report(dp.Plot(Map)).publish(name='geemap_folium_map')\ndp.Report(dp.Plot(Map)).preview(width='100%')", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Mount Everest elevation (m): 8729\n", | |
"name": "stdout" | |
}, | |
{ | |
"output_type": "execute_result", | |
"execution_count": 1, | |
"data": { | |
"text/plain": "<IPython.lib.display.IFrame at 0x7f8f5995be50>", | |
"text/html": "\n <iframe\n width=\"100%\"\n height=\"500\"\n src=\"dp-tmp-de23rmqj/dp-tmp-k7yf26y9.html\"\n frameborder=\"0\"\n allowfullscreen\n ></iframe>\n " | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": true, | |
"base_numbering": 1, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Table of Contents", | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": true | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.8.2", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "geemap-datapane", | |
"public": true | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment