forked from jupyter-widgets/ipyleaflet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add image service layers to address jupyter-widgets#932 (jupyter-widg…
…ets#933) * Adding image service layers to address jupyter-widgets#932 * drop comments on imageservice options * review updates docs: add options to `format`, `pixel_type`, `no_data_interpretation` and `endpoint` feat: add function for handling mouse clicks refactor: remove columbia glacier example remove transparency option (defunct) * add whitespace to fix linting error * update projection names following Beto's review proj changes in notebook * Fix proj for image service example * JS lint fixes * docstring edits for review comments
- Loading branch information
1 parent
7b71f20
commit aabb752
Showing
10 changed files
with
837 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Image Service | ||
============= | ||
|
||
Example | ||
------- | ||
|
||
.. jupyter-execute:: | ||
|
||
from ipyleaflet import Map, ImageService, basemaps | ||
|
||
im = ImageService( | ||
url='https://landsat.arcgis.com/arcgis/rest/services/Landsat/PS/ImageServer', | ||
rendering_rule={"rasterFunction":"Pansharpened Enhanced with DRA"}, | ||
format='jpgpng', | ||
attribution='United States Geological Survey (USGS), National Aeronautics and Space Administration (NASA)' | ||
) | ||
|
||
m = Map(basemap=basemaps.Esri.WorldTopoMap, center=(47.655548, -122.303200), zoom=12) | ||
|
||
m.add(im) | ||
|
||
m | ||
|
||
Usage | ||
----- | ||
|
||
By default, options like ``format``, ``band_ids``, ``time``, ``rendering_rule`` are appended to the request URL when making the image service layer request. | ||
|
||
Attributes | ||
---------- | ||
|
||
.. autoclass:: ipyleaflet.leaflet.ImageService | ||
:members: |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ Layers | |
popup | ||
wms_layer | ||
image_video_overlay | ||
image_service | ||
antpath | ||
polyline | ||
polygon | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Using an Image Service\n", | ||
"\n", | ||
"This notebook shows how you can overlay images from an ESRI Image Server on a Leaflet map" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ipywidgets import Dropdown\n", | ||
"from ipyleaflet import (\n", | ||
" Map,\n", | ||
" basemaps,\n", | ||
" basemap_to_tiles,\n", | ||
" ImageService,\n", | ||
" projections,\n", | ||
" WidgetControl\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# ArcticDEM\n", | ||
"# note that we need to use the same projection for the image service layer and the map.\n", | ||
"m1 = Map(\n", | ||
" center=(90, 0),\n", | ||
" zoom=4,\n", | ||
" basemap=basemaps.Esri.ArcticOceanBase,\n", | ||
" crs=projections.EPSG5936.ESRIBasemap,\n", | ||
")\n", | ||
"# add arctic ocean reference basemap\n", | ||
"tl1 = basemap_to_tiles(basemaps.Esri.ArcticOceanReference)\n", | ||
"m1.add(tl1)\n", | ||
"\n", | ||
"# create a widget control for the raster function\n", | ||
"raster_functions = [\n", | ||
" \"Aspect Map\",\n", | ||
" \"Contour 25\",\n", | ||
" \"Hillshade Elevation Tinted\",\n", | ||
" \"Hillshade Gray\",\n", | ||
" \"Height Ellipsoidal\",\n", | ||
" \"Height Orthometric\",\n", | ||
" \"Slope Map\"]\n", | ||
"raster_dropdown1 = Dropdown(\n", | ||
" value=raster_functions[3],\n", | ||
" options=raster_functions,\n", | ||
" description=\"Raster:\",\n", | ||
")\n", | ||
"\n", | ||
"# add image service layer with ArcticDEM\n", | ||
"url = 'https://elevation2.arcgis.com/arcgis/rest/services/Polar/ArcticDEM/ImageServer'\n", | ||
"rendering_rule = {\"rasterFunction\": raster_dropdown1.value}\n", | ||
"im1 = ImageService(url=url,\n", | ||
" format='jpgpng', rendering_rule=rendering_rule,\n", | ||
" attribution='Esri, PGC, UMN, NSF, NGA, DigitalGlobe',\n", | ||
" crs=projections.EPSG5936.ESRIBasemap)\n", | ||
"m1.add(im1) \n", | ||
"\n", | ||
"# add control for raster function\n", | ||
"widget_control1 = WidgetControl(widget=raster_dropdown1, position=\"topright\")\n", | ||
"m1.add(widget_control1)\n", | ||
"\n", | ||
"# set the rendering rule\n", | ||
"def set_raster_function1(sender):\n", | ||
" im1.rendering_rule = {\"rasterFunction\": raster_dropdown1.value}\n", | ||
" # force redrawing of map by removing and adding layer\n", | ||
" m1.remove(im1)\n", | ||
" m1.add(im1)\n", | ||
"\n", | ||
"# watch raster function widget for changes\n", | ||
"raster_dropdown1.observe(set_raster_function1)\n", | ||
"m1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Reference Elevation Model of Antarctica (REMA)\n", | ||
"# note that we need to use the same projection for the image service layer and the map.\n", | ||
"m2 = Map(\n", | ||
" center=(-90, 0),\n", | ||
" zoom=3,\n", | ||
" basemap=basemaps.Esri.AntarcticBasemap,\n", | ||
" crs=projections.EPSG3031.ESRIBasemap,\n", | ||
")\n", | ||
"\n", | ||
"# create a widget control for the raster function\n", | ||
"raster_functions = [\n", | ||
" \"Aspect Map\",\n", | ||
" \"Contour 25\",\n", | ||
" \"Hillshade Elevation Tinted\",\n", | ||
" \"Hillshade Gray\",\n", | ||
" \"Height Orthometric\",\n", | ||
" \"Slope Degrees Map\"]\n", | ||
"raster_dropdown2 = Dropdown(\n", | ||
" value=raster_functions[3],\n", | ||
" options=raster_functions,\n", | ||
" description=\"Raster:\",\n", | ||
")\n", | ||
"\n", | ||
"# add image service layer with REMA imagery\n", | ||
"url = 'https://elevation2.arcgis.com/arcgis/rest/services/Polar/AntarcticDEM/ImageServer'\n", | ||
"rendering_rule = {\"rasterFunction\": raster_dropdown2.value}\n", | ||
"im2 = ImageService(url=url,\n", | ||
" format='jpgpng', rendering_rule=rendering_rule,\n", | ||
" attribution='Esri, PGC, UMN, NSF, NGA, DigitalGlobe',\n", | ||
" crs=projections.EPSG3031.ESRIBasemap)\n", | ||
"m2.add(im2)\n", | ||
"\n", | ||
"# add control for raster function\n", | ||
"widget_control2 = WidgetControl(widget=raster_dropdown2, position=\"topright\")\n", | ||
"m2.add(widget_control2)\n", | ||
"\n", | ||
"# set the rendering rule\n", | ||
"def set_raster_function2(sender):\n", | ||
" im2.rendering_rule = {\"rasterFunction\": raster_dropdown2.value}\n", | ||
" # force redrawing of map by removing and adding layer\n", | ||
" m2.remove(im2)\n", | ||
" m2.add(im2)\n", | ||
"\n", | ||
"# watch raster function widget for changes\n", | ||
"raster_dropdown2.observe(set_raster_function2)\n", | ||
"m2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.10.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.