Skip to content

Commit a773f30

Browse files
authored
remove tileserver, use openlayers (#245)
1 parent 2902fdf commit a773f30

2 files changed

Lines changed: 32 additions & 13 deletions

File tree

workshop/jupyter/content/notebooks/05-raster-data.ipynb

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"metadata": {},
7373
"source": [
7474
"A typical use case for using gdal in python is resampling a grid and creating overviews, so the tiff can be used as a\n",
75-
"Cloud Optimized GeoTiff"
75+
"Cloud Optimized GeoTiff (COG)"
7676
]
7777
},
7878
{
@@ -82,27 +82,47 @@
8282
"outputs": [],
8383
"source": [
8484
"# Resample\n",
85-
"gdal.Warp('temp/output_3857_cog.tif','../data/world.rgb.tif',dstSRS='EPSG:3857',format='COG')\n"
85+
"gdal.Warp('../data/output_4326_cog.tif','../data/world.rgb.tif',dstSRS='EPSG:4326',format='COG')\n"
8686

8787
]
8888
},
89-
{
89+
{
90+
"cell_type": "markdown",
91+
"metadata": {},
92+
"source": [
93+
"The COG format is optimal for storing large grid files in the cloud. Clients such as GDAL and OpenLayers are able\n",
94+
"to fetch and render parts of the file, without downloading the full file. Below is an example using OpenLayers to\n",
95+
"interact with the generated COG."
96+
]
97+
},
98+
{
9099
"cell_type": "code",
91100
"execution_count": null,
92101
"metadata": {},
93102
"outputs": [],
94103
"source": [
95-
"# Display COG in a viewer \n",
96-
"from localtileserver import TileClient, get_leaflet_tile_layer \n",
97-
"from ipyleaflet import Map \n",
98-
"client = TileClient('temp/output_3857_cog.tif') \n",
99-
"m = Map() \n",
100-
"m.add(get_leaflet_tile_layer(client)) \n",
101-
"m\n"
104+
"from IPython.display import HTML\n",
105+
"\n",
106+
"HTML('''\n",
107+
"<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/ol@latest/ol.css'>\n",
108+
"<script src='https://cdn.jsdelivr.net/npm/geotiff@3.0.5/dist-browser/geotiff.min.js'></script>\n",
109+
"<script src='https://cdn.jsdelivr.net/npm/ol@latest/dist/ol.js' onload='createMap()'></script>\n",
110+
"<div id='map' style='width:100%; height:400px'></div>\n",
111+
"<script>\n",
112+
"function createMap() {\n",
113+
" new ol.Map({\n",
114+
" target: 'map',\n",
115+
" layers: [\n",
116+
" new ol.layer.Tile({source: new ol.source.OSM()}),\n",
117+
" new ol.layer.WebGLTile({source: new ol.source.GeoTIFF({sources: [{url: '/files/content/data/output_4326_cog.tif'}]}),opacity: 0.8})\n",
118+
" ],\n",
119+
" view: new ol.View({center: ol.proj.fromLonLat([18, 45]), zoom: 6})\n",
120+
"})};\n",
121+
"</script>\n",
122+
"''')\n",
123+
"\n"
102124
]
103125
},
104-
105-
106126
{
107127
"cell_type": "markdown",
108128
"metadata": {},

workshop/jupyter/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ geopandas
77
descartes
88
folium
99
bokeh
10-
localtileserver
1110
ipyleaflet
1211
pydeck
1312
pygeometa # >0.7 removed by Just

0 commit comments

Comments
 (0)