Skip to content

Instantly share code, notes, and snippets.

@giswqs
Created March 24, 2021 15:41
Show Gist options
  • Save giswqs/2ed65b81dc09def920967a480dbfa8e7 to your computer and use it in GitHub Desktop.
Save giswqs/2ed65b81dc09def920967a480dbfa8e7 to your computer and use it in GitHub Desktop.
heremap.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {},
"cell_type": "markdown",
"source": "# ImageTileProvider\n\nImageTileProvider is used to add TileLayer from tile services provided by XYZ tile servers or WMTS servers."
},
{
"metadata": {},
"cell_type": "markdown",
"source": "<div class=\"alert alert-block alert-warning\">\n<b>Warning:</b> Before running below cells please make sure you have API key. \n Please see <a href=\"https://github.com/heremaps/here-map-widget-for-jupyter/blob/master/examples/README.md\">README.md</a> for more info on API key.\n</div>"
},
{
"metadata": {},
"cell_type": "markdown",
"source": "## XYZ TileLayer"
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import os\n# os.environ[\"LS_API_KEY\"] = \"MY-API-KEY\" # replace your API key here.",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import ee\nimport geemap",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "geemap.ee_initialize()",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "# Add Earth Engine dataset\ndem = 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']}",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "map_id_dict = ee.Image(dem).getMapId(vis_params)",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "url = map_id_dict[\"tile_fetcher\"].url_format",
"execution_count": null,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "from here_map_widget import Map, ImageTileProvider, TileLayer, ZoomControl\n\n\nm = Map(api_key=os.environ[\"LS_API_KEY\"], center=[39.40, -104.08], zoom=3)\n\nattribution = ('Google Earth Engine')\nprovider = ImageTileProvider(url=url, attribution=attribution)\nlayer = TileLayer(provider=provider)\nm.add_layer(layer)\nzc = ZoomControl(alignment=\"LEFT_TOP\")\nm.add_control(zc)\nm.layout.height=\"600px\"\nm",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.8.5",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"hide_input": false,
"varInspector": {
"window_display": false,
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"library": "var_list.py",
"delete_cmd_prefix": "del ",
"delete_cmd_postfix": "",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"library": "var_list.r",
"delete_cmd_prefix": "rm(",
"delete_cmd_postfix": ") ",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
]
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"base_numbering": 1,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"gist": {
"id": "",
"data": {
"description": "heremap.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment