|
72 | 72 | "metadata": {}, |
73 | 73 | "source": [ |
74 | 74 | "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)" |
76 | 76 | ] |
77 | 77 | }, |
78 | 78 | { |
|
82 | 82 | "outputs": [], |
83 | 83 | "source": [ |
84 | 84 | "# 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" |
86 | 86 |
|
87 | 87 | ] |
88 | 88 | }, |
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 | + { |
90 | 99 | "cell_type": "code", |
91 | 100 | "execution_count": null, |
92 | 101 | "metadata": {}, |
93 | 102 | "outputs": [], |
94 | 103 | "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" |
102 | 124 | ] |
103 | 125 | }, |
104 | | - |
105 | | - |
106 | 126 | { |
107 | 127 | "cell_type": "markdown", |
108 | 128 | "metadata": {}, |
|
0 commit comments