notebooks/bqplot.ipynb DELETED
@@ -1,135 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "metadata": {},
7
- "outputs": [],
8
- "source": [
9
- "from bqplot import pyplot as plt\n",
10
- "import ipywidgets as widgets\n",
11
- "import numpy as np"
12
- ]
13
- },
14
- {
15
- "cell_type": "code",
16
- "execution_count": null,
17
- "metadata": {},
18
- "outputs": [],
19
- "source": [
20
- "# generate some fake \n",
21
- "n = 2000\n",
22
- "x = np.linspace(0.0, 10.0, n)\n",
23
- "np.random.seed(0)\n",
24
- "y = np.cumsum(np.random.randn(n)*10).astype(int)"
25
- ]
26
- },
27
- {
28
- "cell_type": "code",
29
- "execution_count": null,
30
- "metadata": {},
31
- "outputs": [],
32
- "source": [
33
- "fig_hist = plt.figure( title='Histogram')\n",
34
- "hist = plt.hist(y, bins=25)"
35
- ]
36
- },
37
- {
38
- "cell_type": "code",
39
- "execution_count": null,
40
- "metadata": {},
41
- "outputs": [],
42
- "source": [
43
- "hist.bins = 10;"
44
- ]
45
- },
46
- {
47
- "cell_type": "code",
48
- "execution_count": null,
49
- "metadata": {},
50
- "outputs": [],
51
- "source": [
52
- "slider = widgets.IntSlider(description='Bins number', min=1, max=100, v_model=30)"
53
- ]
54
- },
55
- {
56
- "cell_type": "code",
57
- "execution_count": null,
58
- "metadata": {
59
- "scrolled": false
60
- },
61
- "outputs": [],
62
- "source": [
63
- "widgets.link((hist, 'bins'), (slider, 'value'))\n",
64
- "\n",
65
- "fig_lines = plt.figure( title='Line Chart')\n",
66
- "lines = plt.plot(x, y)\n",
67
- "\n",
68
- "fig_lines.layout.width = 'auto'\n",
69
- "fig_lines.layout.height = 'auto'\n",
70
- "fig_hist.layout.width = 'auto'\n",
71
- "fig_hist.layout.height = 'auto'\n",
72
- "\n",
73
- "grid_layout = widgets.GridspecLayout(5, 3)\n",
74
- "\n",
75
- "grid_layout[:2, :] = fig_lines\n",
76
- "grid_layout[2:4, :] = fig_hist\n",
77
- "grid_layout[4, 1] = slider\n",
78
- "\n",
79
- "grid_layout.layout.height = '1000px'\n",
80
- "\n",
81
- "grid_layout"
82
- ]
83
- },
84
- {
85
- "cell_type": "code",
86
- "execution_count": null,
87
- "metadata": {},
88
- "outputs": [],
89
- "source": [
90
- "selector = plt.brush_int_selector()\n",
91
- "def update_range(*ignore):\n",
92
- " if selector.selected is not None and len(selector.selected) == 2:\n",
93
- " xmin, xmax = selector.selected\n",
94
- " mask = (x > xmin) & (x < xmax)\n",
95
- " hist.sample = y[mask]\n",
96
- "selector.observe(update_range, 'selected') "
97
- ]
98
- },
99
- {
100
- "cell_type": "code",
101
- "execution_count": null,
102
- "metadata": {},
103
- "outputs": [],
104
- "source": []
105
- }
106
- ],
107
- "metadata": {
108
- "kernelspec": {
109
- "display_name": "Python 3",
110
- "language": "python",
111
- "name": "python3"
112
- },
113
- "language_info": {
114
- "codemirror_mode": {
115
- "name": "ipython",
116
- "version": 3
117
- },
118
- "file_extension": ".py",
119
- "mimetype": "text/x-python",
120
- "name": "python",
121
- "nbconvert_exporter": "python",
122
- "pygments_lexer": "ipython3",
123
- "version": "3.7.3"
124
- },
125
- "widgets": {
126
- "application/vnd.jupyter.widget-state+json": {
127
- "state": {},
128
- "version_major": 2,
129
- "version_minor": 0
130
- }
131
- }
132
- },
133
- "nbformat": 4,
134
- "nbformat_minor": 4
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/cesium.ipynb DELETED
@@ -1,138 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {},
6
- "source": [
7
- "[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/giswqs/mapwidget/blob/master/docs/examples/cesium.ipynb)\n",
8
- "[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/giswqs/mapwidget&urlpath=lab/tree/mapwidget/docs/examples/cesium.ipynb&branch=master)\n",
9
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/mapwidget/blob/master/docs/examples/cesium.ipynb)"
10
- ]
11
- },
12
- {
13
- "cell_type": "code",
14
- "execution_count": null,
15
- "metadata": {},
16
- "outputs": [],
17
- "source": [
18
- "# %pip install mapwidget"
19
- ]
20
- },
21
- {
22
- "cell_type": "code",
23
- "execution_count": null,
24
- "metadata": {},
25
- "outputs": [],
26
- "source": [
27
- "import os\n",
28
- "import mapwidget.cesium as mapwidget"
29
- ]
30
- },
31
- {
32
- "cell_type": "markdown",
33
- "metadata": {},
34
- "source": [
35
- "You need a Cesium access token to use the Cesium widget. First, [sign up](https://ion.cesium.com/signup/) for a free Cesium account. Then, you can create a token by following the instructions [here](https://cesium.com/learn/ion/cesium-ion-access-tokens/). Set `CESIUM_TOKEN` as an environment variable to use the Cesium widget. Alternatively, uncomment the following code block and replace `YOUR-CESIUM-TOKEN` with your Cesium access token."
36
- ]
37
- },
38
- {
39
- "cell_type": "code",
40
- "execution_count": null,
41
- "metadata": {},
42
- "outputs": [],
43
- "source": [
44
- "if os.environ.get('CESIUM_TOKEN') is None:\n",
45
- " token = 'YOUR-CESIUM-TOKEN'\n",
46
- "else:\n",
47
- " token = os.environ.get('CESIUM_TOKEN')"
48
- ]
49
- },
50
- {
51
- "cell_type": "markdown",
52
- "metadata": {},
53
- "source": [
54
- "San Francisco"
55
- ]
56
- },
57
- {
58
- "cell_type": "code",
59
- "execution_count": null,
60
- "metadata": {},
61
- "outputs": [],
62
- "source": [
63
- "m = mapwidget.Map(center=[37.655, -122.4175], altitude=400, height='600px', token=token)\n",
64
- "m"
65
- ]
66
- },
67
- {
68
- "cell_type": "markdown",
69
- "metadata": {},
70
- "source": [
71
- "![](https://i.imgur.com/gK2wA4p.gif)"
72
- ]
73
- },
74
- {
75
- "cell_type": "markdown",
76
- "metadata": {},
77
- "source": [
78
- "New York City"
79
- ]
80
- },
81
- {
82
- "cell_type": "code",
83
- "execution_count": null,
84
- "metadata": {},
85
- "outputs": [],
86
- "source": [
87
- "m = mapwidget.Map(center=[40.70605, -74.01177], altitude=600, height='600px', token=token)\n",
88
- "m"
89
- ]
90
- },
91
- {
92
- "cell_type": "markdown",
93
- "metadata": {},
94
- "source": [
95
- "![](https://i.imgur.com/6quoDtN.gif)"
96
- ]
97
- },
98
- {
99
- "cell_type": "code",
100
- "execution_count": null,
101
- "metadata": {},
102
- "outputs": [],
103
- "source": [
104
- "m.center"
105
- ]
106
- },
107
- {
108
- "cell_type": "code",
109
- "execution_count": null,
110
- "metadata": {},
111
- "outputs": [],
112
- "source": [
113
- "m.zoom"
114
- ]
115
- }
116
- ],
117
- "metadata": {
118
- "kernelspec": {
119
- "display_name": "Python 3",
120
- "language": "python",
121
- "name": "python3"
122
- },
123
- "language_info": {
124
- "codemirror_mode": {
125
- "name": "ipython",
126
- "version": 3
127
- },
128
- "file_extension": ".py",
129
- "mimetype": "text/x-python",
130
- "name": "python",
131
- "nbconvert_exporter": "python",
132
- "pygments_lexer": "ipython3",
133
- "version": "3.10.8"
134
- }
135
- },
136
- "nbformat": 4,
137
- "nbformat_minor": 4
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/esm.ipynb DELETED
@@ -1,354 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "attachments": {},
5
- "cell_type": "markdown",
6
- "metadata": {},
7
- "source": [
8
- "[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/giswqs/mapwidget/blob/master/docs/examples/esm.ipynb)\n",
9
- "[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/giswqs/mapwidget&urlpath=lab/tree/mapwidget/docs/examples/esm.ipynb&branch=master)\n",
10
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/mapwidget/blob/master/docs/examples/esm.ipynb)"
11
- ]
12
- },
13
- {
14
- "cell_type": "code",
15
- "execution_count": null,
16
- "metadata": {},
17
- "outputs": [],
18
- "source": [
19
- "# %pip install mapwidget"
20
- ]
21
- },
22
- {
23
- "cell_type": "code",
24
- "execution_count": null,
25
- "metadata": {},
26
- "outputs": [],
27
- "source": [
28
- "import os\n",
29
- "import anywidget\n",
30
- "import traitlets"
31
- ]
32
- },
33
- {
34
- "attachments": {},
35
- "cell_type": "markdown",
36
- "metadata": {},
37
- "source": [
38
- "## Leaflet"
39
- ]
40
- },
41
- {
42
- "cell_type": "code",
43
- "execution_count": null,
44
- "metadata": {},
45
- "outputs": [],
46
- "source": [
47
- "class MapWidget(anywidget.AnyWidget):\n",
48
- " _esm = \"\"\"\n",
49
- " import * as L from \"https://esm.sh/leaflet@1.9.3\";\n",
50
- " export function render(view) {\n",
51
- " \n",
52
- " let center = view.model.get(\"center\");\n",
53
- " let zoom = view.model.get(\"zoom\");\n",
54
- " let width = view.model.get(\"width\");\n",
55
- " let height = view.model.get(\"height\");\n",
56
- " \n",
57
- " const container = document.createElement(\"div\"); \n",
58
- " container.style.width = width; \n",
59
- " container.style.height = height;\n",
60
- " \n",
61
- " const map = L.map(container).setView(center, zoom);\n",
62
- " L.tileLayer(\"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\", {\n",
63
- " attribution: 'Map data &copy; <a href=\"https://www.openstreetmap.org/\">OpenStreetMap</a> contributors',\n",
64
- " maxZoom: 24,\n",
65
- " }).addTo(map);\n",
66
- " \n",
67
- " view.el.appendChild(container);\n",
68
- " }\n",
69
- " \"\"\"\n",
70
- "\n",
71
- " _css = \"https://unpkg.com/leaflet@1.9.3/dist/leaflet.css\"\n",
72
- "\n",
73
- " center = traitlets.List([20, 0]).tag(sync=True, o=True)\n",
74
- " zoom = traitlets.Int(2).tag(sync=True, o=True)\n",
75
- " width = traitlets.Unicode(\"100%\").tag(sync=True, o=True)\n",
76
- " height = traitlets.Unicode(\"600px\").tag(sync=True, o=True)\n",
77
- "\n",
78
- "\n",
79
- "m = MapWidget(center=[20, 0], zoom=2, height='600px')\n",
80
- "m"
81
- ]
82
- },
83
- {
84
- "attachments": {},
85
- "cell_type": "markdown",
86
- "metadata": {},
87
- "source": [
88
- "## Maplibre"
89
- ]
90
- },
91
- {
92
- "cell_type": "code",
93
- "execution_count": null,
94
- "metadata": {},
95
- "outputs": [],
96
- "source": [
97
- "class MapWidget(anywidget.AnyWidget):\n",
98
- " _esm = \"\"\"\n",
99
- " import maplibregl from \"https://esm.sh/maplibre-gl@2.4.0\";\n",
100
- "\n",
101
- " export function render(view) {\n",
102
- " \n",
103
- " let center = view.model.get(\"center\");\n",
104
- " center.reverse();\n",
105
- " let zoom = view.model.get(\"zoom\");\n",
106
- " let width = view.model.get(\"width\");\n",
107
- " let height = view.model.get(\"height\");\n",
108
- "\n",
109
- " const div = document.createElement(\"div\");\n",
110
- " div.style.width = width;\n",
111
- " div.style.height = height;\n",
112
- "\n",
113
- " const map = new maplibregl.Map({\n",
114
- " container: div,\n",
115
- " style: 'https://demotiles.maplibre.org/style.json', // stylesheet location\n",
116
- " center: center, // starting position [lng, lat]\n",
117
- " zoom: zoom // starting zoom\n",
118
- " });\n",
119
- " view.el.appendChild(div);\n",
120
- " }\n",
121
- " \"\"\"\n",
122
- " _css = \"https://esm.sh/maplibre-gl@2.4.0?css\"\n",
123
- "\n",
124
- " center = traitlets.List([20, 0]).tag(sync=True, o=True)\n",
125
- " zoom = traitlets.Int(2).tag(sync=True, o=True)\n",
126
- " width = traitlets.Unicode(\"100%\").tag(sync=True, o=True)\n",
127
- " height = traitlets.Unicode(\"600px\").tag(sync=True, o=True)\n",
128
- "\n",
129
- "\n",
130
- "m = MapWidget(center=[20, 0], zoom=2)\n",
131
- "m"
132
- ]
133
- },
134
- {
135
- "attachments": {},
136
- "cell_type": "markdown",
137
- "metadata": {},
138
- "source": [
139
- "## Mapbox"
140
- ]
141
- },
142
- {
143
- "cell_type": "code",
144
- "execution_count": null,
145
- "metadata": {},
146
- "outputs": [],
147
- "source": [
148
- "class MapWidget(anywidget.AnyWidget):\n",
149
- " _esm = \"\"\"\n",
150
- " import mapboxgl from \"https://esm.sh/mapbox-gl@2.13.0\";\n",
151
- "\n",
152
- " export function render(view) {\n",
153
- " let center = view.model.get(\"center\");\n",
154
- " center.reverse();\n",
155
- " let zoom = view.model.get(\"zoom\");\n",
156
- " let width = view.model.get(\"width\");\n",
157
- " let height = view.model.get(\"height\");\n",
158
- "\n",
159
- " const div = document.createElement(\"div\");\n",
160
- " div.style.width = width;\n",
161
- " div.style.height = height;\n",
162
- "\n",
163
- " let token = view.model.get(\"token\");\n",
164
- "\n",
165
- " mapboxgl.accessToken = token;\n",
166
- " const map = new mapboxgl.Map({\n",
167
- " container: div,\n",
168
- " style: \"mapbox://styles/mapbox/streets-v12\",\n",
169
- " center: center,\n",
170
- " zoom: zoom,\n",
171
- " });\n",
172
- " view.el.appendChild(div);\n",
173
- " }\n",
174
- "\n",
175
- " \"\"\"\n",
176
- " _css = \"https://esm.sh/mapbox-gl@2.13.0?css\"\n",
177
- "\n",
178
- " default_token = os.environ.get('MAPBOX_TOKEN')\n",
179
- " token = traitlets.Unicode(default_token).tag(sync=True)\n",
180
- " center = traitlets.List([20, 0]).tag(sync=True, o=True)\n",
181
- " zoom = traitlets.Int(2).tag(sync=True, o=True)\n",
182
- " width = traitlets.Unicode('100%').tag(sync=True, o=True)\n",
183
- " height = traitlets.Unicode('600px').tag(sync=True, o=True)\n",
184
- "\n",
185
- "\n",
186
- "m = MapWidget(center=[20, 0], zoom=2)\n",
187
- "m"
188
- ]
189
- },
190
- {
191
- "attachments": {},
192
- "cell_type": "markdown",
193
- "metadata": {},
194
- "source": [
195
- "## Cesium"
196
- ]
197
- },
198
- {
199
- "cell_type": "code",
200
- "execution_count": null,
201
- "metadata": {},
202
- "outputs": [],
203
- "source": [
204
- "class MapWidget(anywidget.AnyWidget):\n",
205
- " _esm = \"\"\"\n",
206
- " function loadScript(src) {\n",
207
- " return new Promise((resolve, reject) => {\n",
208
- " let script = Object.assign(document.createElement(\"script\"), {\n",
209
- " type: \"text/javascript\",\n",
210
- " async: true,\n",
211
- " src: src,\n",
212
- " });\n",
213
- " script.addEventListener(\"load\", resolve);\n",
214
- " script.addEventListener(\"error\", reject);\n",
215
- " document.body.appendChild(script);\n",
216
- " });\n",
217
- " };\n",
218
- " \n",
219
- " await loadScript(\"https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Cesium.js\");\n",
220
- " \n",
221
- " export function render(view) {\n",
222
- " \n",
223
- " let width = view.model.get(\"width\");\n",
224
- " let height = view.model.get(\"height\");\n",
225
- " \n",
226
- " const div = document.createElement(\"div\");\n",
227
- " div.style.width = width;\n",
228
- " div.style.height = height;\n",
229
- " \n",
230
- " Cesium.Ion.defaultAccessToken = view.model.get(\"token\");\n",
231
- "\n",
232
- " const viewer = new Cesium.Viewer(div, {\n",
233
- " terrainProvider: Cesium.createWorldTerrain()\n",
234
- " }); \n",
235
- "\n",
236
- " const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings()); \n",
237
- "\n",
238
- " viewer.camera.flyTo({\n",
239
- " destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),\n",
240
- " orientation : {\n",
241
- " heading : Cesium.Math.toRadians(0.0),\n",
242
- " pitch : Cesium.Math.toRadians(-15.0),\n",
243
- " }\n",
244
- " });\n",
245
- " \n",
246
- " view.el.appendChild(div);\n",
247
- " }\n",
248
- " \"\"\"\n",
249
- " # make sure to include styles\n",
250
- " _css = \"https://cesium.com/downloads/cesiumjs/releases/1.103/Build/Cesium/Widgets/widgets.css\"\n",
251
- " default_token = os.environ.get('CESIUM_TOKEN')\n",
252
- " token = traitlets.Unicode(default_token).tag(sync=True)\n",
253
- " width = traitlets.Unicode('100%').tag(sync=True, o=True)\n",
254
- " height = traitlets.Unicode('600px').tag(sync=True, o=True)\n",
255
- "\n",
256
- "\n",
257
- "m = MapWidget()\n",
258
- "m"
259
- ]
260
- },
261
- {
262
- "attachments": {},
263
- "cell_type": "markdown",
264
- "metadata": {},
265
- "source": [
266
- "## OpenLayers"
267
- ]
268
- },
269
- {
270
- "cell_type": "code",
271
- "execution_count": null,
272
- "metadata": {},
273
- "outputs": [],
274
- "source": [
275
- "class MapWidget(anywidget.AnyWidget):\n",
276
- " _esm = \"\"\"\n",
277
- " function loadScript(src) {\n",
278
- " return new Promise((resolve, reject) => {\n",
279
- " let script = Object.assign(document.createElement(\"script\"), {\n",
280
- " type: \"text/javascript\",\n",
281
- " async: true,\n",
282
- " src: src,\n",
283
- " });\n",
284
- " script.addEventListener(\"load\", resolve);\n",
285
- " script.addEventListener(\"error\", reject);\n",
286
- " document.body.appendChild(script);\n",
287
- " });\n",
288
- " };\n",
289
- " \n",
290
- " await loadScript(\"https://cdn.jsdelivr.net/npm/ol@v7.3.0/dist/ol.js\");\n",
291
- " \n",
292
- " export function render(view) {\n",
293
- " \n",
294
- " let center = view.model.get(\"center\");\n",
295
- " center.reverse();\n",
296
- " let zoom = view.model.get(\"zoom\");\n",
297
- " let width = view.model.get(\"width\");\n",
298
- " let height = view.model.get(\"height\");\n",
299
- "\n",
300
- " const div = document.createElement(\"div\");\n",
301
- " div.style.width = width;\n",
302
- " div.style.height = height;\n",
303
- " \n",
304
- " var map = new ol.Map({\n",
305
- " target: div,\n",
306
- " layers: [\n",
307
- " new ol.layer.Tile({\n",
308
- " source: new ol.source.OSM()\n",
309
- " })\n",
310
- " ],\n",
311
- " view: new ol.View({\n",
312
- " center: ol.proj.fromLonLat(center),\n",
313
- " zoom: zoom\n",
314
- " })\n",
315
- " });\n",
316
- " view.el.appendChild(div);\n",
317
- " }\n",
318
- " \"\"\"\n",
319
- " # make sure to include styles\n",
320
- " _css = \"https://cdn.jsdelivr.net/npm/ol@v7.3.0/ol.css\"\n",
321
- " center = traitlets.List([20, 0]).tag(sync=True, o=True)\n",
322
- " zoom = traitlets.Int(2).tag(sync=True, o=True)\n",
323
- " width = traitlets.Unicode('100%').tag(sync=True, o=True)\n",
324
- " height = traitlets.Unicode('600px').tag(sync=True, o=True)\n",
325
- "\n",
326
- "\n",
327
- "m = MapWidget(center=[20, 0], zoom=2)\n",
328
- "m"
329
- ]
330
- }
331
- ],
332
- "metadata": {
333
- "kernelspec": {
334
- "display_name": "geo",
335
- "language": "python",
336
- "name": "python3"
337
- },
338
- "language_info": {
339
- "codemirror_mode": {
340
- "name": "ipython",
341
- "version": 3
342
- },
343
- "file_extension": ".py",
344
- "mimetype": "text/x-python",
345
- "name": "python",
346
- "nbconvert_exporter": "python",
347
- "pygments_lexer": "ipython3",
348
- "version": "3.10.8"
349
- },
350
- "orig_nbformat": 4
351
- },
352
- "nbformat": 4,
353
- "nbformat_minor": 2
354
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/geemap.ipynb DELETED
@@ -1,72 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "1ae5f776",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import ee\n",
11
- "import geemap"
12
- ]
13
- },
14
- {
15
- "cell_type": "code",
16
- "execution_count": null,
17
- "id": "3d7e1415",
18
- "metadata": {},
19
- "outputs": [],
20
- "source": [
21
- "Map = geemap.Map(center=(40, -100), zoom=4, height='800px')\n",
22
- "# Add Earth Engine dataset\n",
23
- "dem = ee.Image('USGS/SRTMGL1_003')\n",
24
- "landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(\n",
25
- " ['B1', 'B2', 'B3', 'B4', 'B5', 'B7']\n",
26
- ")\n",
27
- "states = ee.FeatureCollection(\"TIGER/2018/States\")\n",
28
- "\n",
29
- "# Set visualization parameters.\n",
30
- "vis_params = {\n",
31
- " 'min': 0,\n",
32
- " 'max': 4000,\n",
33
- " 'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],\n",
34
- "}\n",
35
- "\n",
36
- "# Add Earth Engine layers to Map\n",
37
- "Map.addLayer(dem, vis_params, 'SRTM DEM', True, 0.5)\n",
38
- "Map.addLayer(\n",
39
- " landsat7,\n",
40
- " {'bands': ['B4', 'B3', 'B2'], 'min': 20, 'max': 200, 'gamma': 2.0},\n",
41
- " 'Landsat 7',\n",
42
- ")\n",
43
- "Map.addLayer(states, {}, \"US States\")\n",
44
- "Map.add_layer_manager()\n",
45
- "Map.add_inspector()\n",
46
- "\n",
47
- "Map"
48
- ]
49
- }
50
- ],
51
- "metadata": {
52
- "kernelspec": {
53
- "display_name": "Python 3",
54
- "language": "python",
55
- "name": "python3"
56
- },
57
- "language_info": {
58
- "codemirror_mode": {
59
- "name": "ipython",
60
- "version": 3
61
- },
62
- "file_extension": ".py",
63
- "mimetype": "text/x-python",
64
- "name": "python",
65
- "nbconvert_exporter": "python",
66
- "pygments_lexer": "ipython3",
67
- "version": "3.10.9"
68
- }
69
- },
70
- "nbformat": 4,
71
- "nbformat_minor": 5
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/leaflet.ipynb DELETED
@@ -1,159 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "attachments": {},
5
- "cell_type": "markdown",
6
- "metadata": {},
7
- "source": [
8
- "[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/giswqs/mapwidget/blob/master/docs/examples/leaflet.ipynb)\n",
9
- "[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/giswqs/mapwidget&urlpath=lab/tree/mapwidget/docs/examples/leaflet.ipynb&branch=master)\n",
10
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/mapwidget/blob/master/docs/examples/leaflet.ipynb)"
11
- ]
12
- },
13
- {
14
- "cell_type": "code",
15
- "execution_count": null,
16
- "metadata": {},
17
- "outputs": [],
18
- "source": [
19
- "# %pip install mapwidget"
20
- ]
21
- },
22
- {
23
- "cell_type": "code",
24
- "execution_count": null,
25
- "metadata": {},
26
- "outputs": [],
27
- "source": [
28
- "import mapwidget"
29
- ]
30
- },
31
- {
32
- "cell_type": "code",
33
- "execution_count": null,
34
- "metadata": {},
35
- "outputs": [],
36
- "source": [
37
- "m = mapwidget.Map()\n",
38
- "m"
39
- ]
40
- },
41
- {
42
- "cell_type": "code",
43
- "execution_count": null,
44
- "metadata": {},
45
- "outputs": [],
46
- "source": [
47
- "m.basemap"
48
- ]
49
- },
50
- {
51
- "cell_type": "code",
52
- "execution_count": null,
53
- "metadata": {},
54
- "outputs": [],
55
- "source": [
56
- "m.add_basemap('HYBRID')"
57
- ]
58
- },
59
- {
60
- "cell_type": "code",
61
- "execution_count": null,
62
- "metadata": {},
63
- "outputs": [],
64
- "source": [
65
- "m.add_basemap('OpenTopoMap')"
66
- ]
67
- },
68
- {
69
- "cell_type": "code",
70
- "execution_count": null,
71
- "metadata": {},
72
- "outputs": [],
73
- "source": [
74
- "from mapwidget.basemaps import get_basemap_list\n",
75
- "\n",
76
- "print(len(get_basemap_list()))"
77
- ]
78
- },
79
- {
80
- "cell_type": "code",
81
- "execution_count": null,
82
- "metadata": {},
83
- "outputs": [],
84
- "source": [
85
- "get_basemap_list()[:10]"
86
- ]
87
- },
88
- {
89
- "cell_type": "code",
90
- "execution_count": null,
91
- "metadata": {},
92
- "outputs": [],
93
- "source": [
94
- "m.clicked_latlng"
95
- ]
96
- },
97
- {
98
- "cell_type": "code",
99
- "execution_count": null,
100
- "metadata": {},
101
- "outputs": [],
102
- "source": [
103
- "m.center"
104
- ]
105
- },
106
- {
107
- "cell_type": "code",
108
- "execution_count": null,
109
- "metadata": {},
110
- "outputs": [],
111
- "source": [
112
- "m.bounds"
113
- ]
114
- },
115
- {
116
- "cell_type": "code",
117
- "execution_count": null,
118
- "metadata": {},
119
- "outputs": [],
120
- "source": [
121
- "m.zoom"
122
- ]
123
- },
124
- {
125
- "attachments": {},
126
- "cell_type": "markdown",
127
- "metadata": {},
128
- "source": [
129
- "![](https://i.imgur.com/4zt3wUk.gif)"
130
- ]
131
- }
132
- ],
133
- "metadata": {
134
- "kernelspec": {
135
- "display_name": "Python 3 (ipykernel)",
136
- "language": "python",
137
- "name": "python3"
138
- },
139
- "language_info": {
140
- "codemirror_mode": {
141
- "name": "ipython",
142
- "version": 3
143
- },
144
- "file_extension": ".py",
145
- "mimetype": "text/x-python",
146
- "name": "python",
147
- "nbconvert_exporter": "python",
148
- "pygments_lexer": "ipython3",
149
- "version": "3.10.8"
150
- },
151
- "vscode": {
152
- "interpreter": {
153
- "hash": "31f05ea183a4718249d13ada7f166c6bdba1d00716247af5c11c23af8d5923f1"
154
- }
155
- }
156
- },
157
- "nbformat": 4,
158
- "nbformat_minor": 4
159
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/leafmap.ipynb DELETED
@@ -1,71 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "id": "a058f796",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import leafmap"
11
- ]
12
- },
13
- {
14
- "cell_type": "code",
15
- "execution_count": 5,
16
- "id": "57967f3a",
17
- "metadata": {},
18
- "outputs": [
19
- {
20
- "data": {
21
- "application/vnd.jupyter.widget-view+json": {
22
- "model_id": "18da37ed564c4610bd772f1179896df8",
23
- "version_major": 2,
24
- "version_minor": 0
25
- },
26
- "text/plain": [
27
- "Map(center=[20, 0], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_text…"
28
- ]
29
- },
30
- "metadata": {},
31
- "output_type": "display_data"
32
- }
33
- ],
34
- "source": [
35
- "m = leafmap.Map(height='800px')\n",
36
- "m.add_basemap('OpenTopoMap')\n",
37
- "# m.split_map('TERRAIN', 'OpenTopoMap')\n",
38
- "m"
39
- ]
40
- },
41
- {
42
- "cell_type": "code",
43
- "execution_count": null,
44
- "id": "80bf53d8",
45
- "metadata": {},
46
- "outputs": [],
47
- "source": []
48
- }
49
- ],
50
- "metadata": {
51
- "kernelspec": {
52
- "display_name": "Python 3",
53
- "language": "python",
54
- "name": "python3"
55
- },
56
- "language_info": {
57
- "codemirror_mode": {
58
- "name": "ipython",
59
- "version": 3
60
- },
61
- "file_extension": ".py",
62
- "mimetype": "text/x-python",
63
- "name": "python",
64
- "nbconvert_exporter": "python",
65
- "pygments_lexer": "ipython3",
66
- "version": "3.10.9"
67
- }
68
- },
69
- "nbformat": 4,
70
- "nbformat_minor": 5
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/mapbox.ipynb DELETED
@@ -1,295 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "attachments": {},
5
- "cell_type": "markdown",
6
- "metadata": {},
7
- "source": [
8
- "[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/giswqs/mapwidget/blob/master/docs/examples/mapbox.ipynb)\n",
9
- "[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/giswqs/mapwidget&urlpath=lab/tree/mapwidget/docs/examples/mapbox.ipynb&branch=master)\n",
10
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/mapwidget/blob/master/docs/examples/mapbox.ipynb)"
11
- ]
12
- },
13
- {
14
- "cell_type": "code",
15
- "execution_count": null,
16
- "metadata": {},
17
- "outputs": [],
18
- "source": [
19
- "# %pip install mapwidget"
20
- ]
21
- },
22
- {
23
- "cell_type": "code",
24
- "execution_count": null,
25
- "metadata": {},
26
- "outputs": [],
27
- "source": [
28
- "import mapwidget.mapbox as mapwidget"
29
- ]
30
- },
31
- {
32
- "attachments": {},
33
- "cell_type": "markdown",
34
- "metadata": {},
35
- "source": [
36
- "You need a Mapbox access token to use the Mapbox widget. First, [sign up](https://account.mapbox.com/auth/signup/) for a free Mapbox account. Then, you can create a token by following the instructions [here](https://docs.mapbox.com/api/accounts/tokens/). Set `Mapbox_TOKEN` as an environment variable to use the Mapbox widget. Alternatively, uncomment the following code block and replace `YOUR-API-TOKEN` with your Mapbox access token."
37
- ]
38
- },
39
- {
40
- "cell_type": "code",
41
- "execution_count": null,
42
- "metadata": {},
43
- "outputs": [],
44
- "source": [
45
- "# import os\n",
46
- "# os.environ['MAPBOX_TOKEN'] = 'YOUR-API-TOKEN'"
47
- ]
48
- },
49
- {
50
- "cell_type": "code",
51
- "execution_count": null,
52
- "metadata": {},
53
- "outputs": [],
54
- "source": [
55
- "m = mapwidget.Map(center=[20, 0], zoom=2, height='600px')\n",
56
- "m"
57
- ]
58
- },
59
- {
60
- "attachments": {},
61
- "cell_type": "markdown",
62
- "metadata": {},
63
- "source": [
64
- "![](https://i.imgur.com/1PbtnQE.gif)"
65
- ]
66
- },
67
- {
68
- "cell_type": "code",
69
- "execution_count": null,
70
- "metadata": {},
71
- "outputs": [],
72
- "source": [
73
- "m.clicked_latlng"
74
- ]
75
- },
76
- {
77
- "cell_type": "code",
78
- "execution_count": null,
79
- "metadata": {},
80
- "outputs": [],
81
- "source": [
82
- "m.zoom"
83
- ]
84
- },
85
- {
86
- "cell_type": "code",
87
- "execution_count": null,
88
- "metadata": {},
89
- "outputs": [],
90
- "source": [
91
- "m.center"
92
- ]
93
- },
94
- {
95
- "cell_type": "code",
96
- "execution_count": null,
97
- "metadata": {},
98
- "outputs": [],
99
- "source": [
100
- "m.bounds"
101
- ]
102
- },
103
- {
104
- "cell_type": "code",
105
- "execution_count": null,
106
- "metadata": {},
107
- "outputs": [],
108
- "source": [
109
- "esm = \"\"\"\n",
110
- "\n",
111
- " const map = new mapboxgl.Map({\n",
112
- " container: 'map',\n",
113
- " zoom: 14,\n",
114
- " center: [-114.26608, 32.7213],\n",
115
- " pitch: 80,\n",
116
- " bearing: 41,\n",
117
- " // Choose from Mapbox's core styles, or make your own style with Mapbox Studio\n",
118
- " style: 'mapbox://styles/mapbox/satellite-streets-v12'\n",
119
- " });\n",
120
- "\n",
121
- " map.on('style.load', () => {\n",
122
- " map.addSource('mapbox-dem', {\n",
123
- " 'type': 'raster-dem',\n",
124
- " 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',\n",
125
- " 'tileSize': 512,\n",
126
- " 'maxzoom': 14\n",
127
- " });\n",
128
- " // add the DEM source as a terrain layer with exaggerated height\n",
129
- " map.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });\n",
130
- " });\n",
131
- "\n",
132
- "\n",
133
- "\"\"\""
134
- ]
135
- },
136
- {
137
- "cell_type": "code",
138
- "execution_count": null,
139
- "metadata": {},
140
- "outputs": [],
141
- "source": [
142
- "m.set_esm(esm)\n",
143
- "m"
144
- ]
145
- },
146
- {
147
- "attachments": {},
148
- "cell_type": "markdown",
149
- "metadata": {},
150
- "source": [
151
- "![](https://i.imgur.com/xvdrvpx.png)"
152
- ]
153
- },
154
- {
155
- "cell_type": "code",
156
- "execution_count": null,
157
- "metadata": {},
158
- "outputs": [],
159
- "source": [
160
- "esm = \"\"\"\n",
161
- "\n",
162
- " (async () => {\n",
163
- " const map = new mapboxgl.Map({\n",
164
- " container: 'map',\n",
165
- " zoom: 13,\n",
166
- " center: [6.6301, 45.35625],\n",
167
- " pitch: 80,\n",
168
- " bearing: 160,\n",
169
- " interactive: false,\n",
170
- " // Choose from Mapbox's core styles, or make your own style with Mapbox Studio\n",
171
- " style: 'mapbox://styles/mapbox/satellite-v9'\n",
172
- " });\n",
173
- "\n",
174
- " await map.once('style.load');\n",
175
- "\n",
176
- " // Add daytime fog\n",
177
- " map.setFog({\n",
178
- " 'range': [-1, 2],\n",
179
- " 'horizon-blend': 0.3,\n",
180
- " 'color': 'white',\n",
181
- " 'high-color': '#add8e6',\n",
182
- " 'space-color': '#d8f2ff',\n",
183
- " 'star-intensity': 0.0\n",
184
- " });\n",
185
- "\n",
186
- " // Add 3D terrain\n",
187
- " map.addSource('mapbox-dem', {\n",
188
- " 'type': 'raster-dem',\n",
189
- " 'url': 'mapbox://mapbox.terrain-rgb',\n",
190
- " 'tileSize': 512,\n",
191
- " 'maxzoom': 14\n",
192
- " });\n",
193
- " map.setTerrain({\n",
194
- " 'source': 'mapbox-dem',\n",
195
- " 'exaggeration': 1.5\n",
196
- " });\n",
197
- "\n",
198
- " // Run a timing loop to switch between day and night\n",
199
- " await map.once('idle');\n",
200
- "\n",
201
- " let lastTime = 0.0;\n",
202
- " let animationTime = 0.0;\n",
203
- " let cycleTime = 0.0;\n",
204
- " let night = true;\n",
205
- "\n",
206
- " const initialBearing = map.getBearing();\n",
207
- "\n",
208
- " function frame(time) {\n",
209
- " const elapsedTime = (time - lastTime) / 1000.0;\n",
210
- "\n",
211
- " animationTime += elapsedTime;\n",
212
- " cycleTime += elapsedTime;\n",
213
- "\n",
214
- " if (cycleTime >= 10.0) {\n",
215
- " if (night) {\n",
216
- " // night fog styling\n",
217
- " map.setFog({\n",
218
- " 'range': [-1, 2],\n",
219
- " 'horizon-blend': 0.3,\n",
220
- " 'color': '#242B4B',\n",
221
- " 'high-color': '#161B36',\n",
222
- " 'space-color': '#0B1026',\n",
223
- " 'star-intensity': 0.8\n",
224
- " });\n",
225
- " } else {\n",
226
- " // day fog styling\n",
227
- " map.setFog({\n",
228
- " 'range': [-1, 2],\n",
229
- " 'horizon-blend': 0.3,\n",
230
- " 'color': 'white',\n",
231
- " 'high-color': '#add8e6',\n",
232
- " 'space-color': '#d8f2ff',\n",
233
- " 'star-intensity': 0.0\n",
234
- " });\n",
235
- " }\n",
236
- "\n",
237
- " night = !night;\n",
238
- " cycleTime = 0.0;\n",
239
- " }\n",
240
- "\n",
241
- " const rotation = initialBearing + animationTime * 2.0;\n",
242
- " map.setBearing(rotation % 360);\n",
243
- "\n",
244
- " lastTime = time;\n",
245
- "\n",
246
- " window.requestAnimationFrame(frame);\n",
247
- " }\n",
248
- "\n",
249
- " window.requestAnimationFrame(frame);\n",
250
- " })();\n",
251
- "\n",
252
- "\"\"\""
253
- ]
254
- },
255
- {
256
- "cell_type": "code",
257
- "execution_count": null,
258
- "metadata": {},
259
- "outputs": [],
260
- "source": [
261
- "m.set_esm(esm)\n",
262
- "m"
263
- ]
264
- },
265
- {
266
- "attachments": {},
267
- "cell_type": "markdown",
268
- "metadata": {},
269
- "source": [
270
- "![](https://i.imgur.com/ZRRUK3v.png)"
271
- ]
272
- }
273
- ],
274
- "metadata": {
275
- "kernelspec": {
276
- "display_name": "Python 3 (ipykernel)",
277
- "language": "python",
278
- "name": "python3"
279
- },
280
- "language_info": {
281
- "codemirror_mode": {
282
- "name": "ipython",
283
- "version": 3
284
- },
285
- "file_extension": ".py",
286
- "mimetype": "text/x-python",
287
- "name": "python",
288
- "nbconvert_exporter": "python",
289
- "pygments_lexer": "ipython3",
290
- "version": "3.10.8"
291
- }
292
- },
293
- "nbformat": 4,
294
- "nbformat_minor": 4
295
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/maplibre.ipynb DELETED
@@ -1,288 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "metadata": {},
6
- "source": [
7
- "[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/giswqs/mapwidget/blob/master/docs/examples/maplibre.ipynb)\n",
8
- "[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/giswqs/mapwidget&urlpath=lab/tree/mapwidget/docs/examples/maplibre.ipynb&branch=master)\n",
9
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/mapwidget/blob/master/docs/examples/maplibre.ipynb)"
10
- ]
11
- },
12
- {
13
- "cell_type": "code",
14
- "execution_count": null,
15
- "metadata": {},
16
- "outputs": [],
17
- "source": [
18
- "# %pip install mapwidget"
19
- ]
20
- },
21
- {
22
- "cell_type": "code",
23
- "execution_count": null,
24
- "metadata": {},
25
- "outputs": [],
26
- "source": [
27
- "import mapwidget.maplibre as mapwidget"
28
- ]
29
- },
30
- {
31
- "cell_type": "code",
32
- "execution_count": null,
33
- "metadata": {},
34
- "outputs": [],
35
- "source": [
36
- "m = mapwidget.Map(center=[20, 0], zoom=2, height='600px')\n",
37
- "m"
38
- ]
39
- },
40
- {
41
- "cell_type": "markdown",
42
- "metadata": {},
43
- "source": [
44
- "![](https://i.imgur.com/Pxi43kg.png)"
45
- ]
46
- },
47
- {
48
- "cell_type": "code",
49
- "execution_count": null,
50
- "metadata": {},
51
- "outputs": [],
52
- "source": [
53
- "m.center"
54
- ]
55
- },
56
- {
57
- "cell_type": "code",
58
- "execution_count": null,
59
- "metadata": {},
60
- "outputs": [],
61
- "source": [
62
- "m.zoom"
63
- ]
64
- },
65
- {
66
- "cell_type": "code",
67
- "execution_count": null,
68
- "metadata": {},
69
- "outputs": [],
70
- "source": [
71
- "m.bounds"
72
- ]
73
- },
74
- {
75
- "cell_type": "code",
76
- "execution_count": null,
77
- "metadata": {},
78
- "outputs": [],
79
- "source": [
80
- "m.clicked_latlng"
81
- ]
82
- },
83
- {
84
- "cell_type": "code",
85
- "execution_count": null,
86
- "metadata": {},
87
- "outputs": [],
88
- "source": [
89
- "esm = \"\"\"\n",
90
- "\n",
91
- " var videoStyle = {\n",
92
- " 'version': 8,\n",
93
- " 'sources': {\n",
94
- " 'satellite': {\n",
95
- " 'type': 'raster',\n",
96
- " 'url':\n",
97
- " 'https://api.maptiler.com/tiles/satellite/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL',\n",
98
- " 'tileSize': 256\n",
99
- " },\n",
100
- " 'video': {\n",
101
- " 'type': 'video',\n",
102
- " 'urls': [\n",
103
- " 'https://static-assets.mapbox.com/mapbox-gl-js/drone.mp4',\n",
104
- " 'https://static-assets.mapbox.com/mapbox-gl-js/drone.webm'\n",
105
- " ],\n",
106
- " 'coordinates': [\n",
107
- " [-122.51596391201019, 37.56238816766053],\n",
108
- " [-122.51467645168304, 37.56410183312965],\n",
109
- " [-122.51309394836426, 37.563391708549425],\n",
110
- " [-122.51423120498657, 37.56161849366671]\n",
111
- " ]\n",
112
- " }\n",
113
- " },\n",
114
- " 'layers': [\n",
115
- " {\n",
116
- " 'id': 'background',\n",
117
- " 'type': 'background',\n",
118
- " 'paint': {\n",
119
- " 'background-color': 'rgb(4,7,14)'\n",
120
- " }\n",
121
- " },\n",
122
- " {\n",
123
- " 'id': 'satellite',\n",
124
- " 'type': 'raster',\n",
125
- " 'source': 'satellite'\n",
126
- " },\n",
127
- " {\n",
128
- " 'id': 'video',\n",
129
- " 'type': 'raster',\n",
130
- " 'source': 'video'\n",
131
- " }\n",
132
- " ]\n",
133
- " };\n",
134
- "\n",
135
- " var map = new maplibregl.Map({\n",
136
- " container: 'map',\n",
137
- " minZoom: 14,\n",
138
- " zoom: 17,\n",
139
- " center: [-122.514426, 37.562984],\n",
140
- " bearing: -96,\n",
141
- " style: videoStyle\n",
142
- " });\n",
143
- "\n",
144
- " var playingVideo = true;\n",
145
- "\n",
146
- " map.on('click', function () {\n",
147
- " playingVideo = !playingVideo;\n",
148
- "\n",
149
- " if (playingVideo) map.getSource('video').play();\n",
150
- " else map.getSource('video').pause();\n",
151
- " });\n",
152
- "\n",
153
- "\"\"\""
154
- ]
155
- },
156
- {
157
- "cell_type": "code",
158
- "execution_count": null,
159
- "metadata": {},
160
- "outputs": [],
161
- "source": [
162
- "m.set_esm(esm)\n",
163
- "m"
164
- ]
165
- },
166
- {
167
- "cell_type": "markdown",
168
- "metadata": {},
169
- "source": [
170
- "![](https://i.imgur.com/o2ZHeTL.gif)"
171
- ]
172
- },
173
- {
174
- "cell_type": "code",
175
- "execution_count": null,
176
- "metadata": {},
177
- "outputs": [],
178
- "source": [
179
- "esm = \"\"\"\n",
180
- "\n",
181
- " var map = (window.map = new maplibregl.Map({\n",
182
- " container: 'map',\n",
183
- " zoom: 12,\n",
184
- " center: [11.39085, 47.27574],\n",
185
- " pitch: 52,\n",
186
- " hash: true,\n",
187
- " style: {\n",
188
- " version: 8,\n",
189
- " sources: {\n",
190
- " osm: {\n",
191
- " type: 'raster',\n",
192
- " tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png'],\n",
193
- " tileSize: 256,\n",
194
- " attribution: '&copy; OpenStreetMap Contributors',\n",
195
- " maxzoom: 19\n",
196
- " },\n",
197
- " terrainSource: {\n",
198
- " type: 'raster-dem',\n",
199
- " url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',\n",
200
- " tileSize: 256\n",
201
- " },\n",
202
- " hillshadeSource: {\n",
203
- " type: 'raster-dem',\n",
204
- " url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',\n",
205
- " tileSize: 256\n",
206
- " }\n",
207
- " },\n",
208
- " layers: [\n",
209
- " {\n",
210
- " id: 'osm',\n",
211
- " type: 'raster',\n",
212
- " source: 'osm'\n",
213
- " },\n",
214
- " {\n",
215
- " id: 'hills',\n",
216
- " type: 'hillshade',\n",
217
- " source: 'hillshadeSource',\n",
218
- " layout: { visibility: 'visible' },\n",
219
- " paint: { 'hillshade-shadow-color': '#473B24' }\n",
220
- " }\n",
221
- " ],\n",
222
- " terrain: {\n",
223
- " source: 'terrainSource',\n",
224
- " exaggeration: 1\n",
225
- " }\n",
226
- " },\n",
227
- " maxZoom: 18,\n",
228
- " maxPitch: 85\n",
229
- " }));\n",
230
- "\n",
231
- " map.addControl(\n",
232
- " new maplibregl.NavigationControl({\n",
233
- " visualizePitch: true,\n",
234
- " showZoom: true,\n",
235
- " showCompass: true\n",
236
- " })\n",
237
- " );\n",
238
- "\n",
239
- " map.addControl(\n",
240
- " new maplibregl.TerrainControl({\n",
241
- " source: 'terrainSource',\n",
242
- " exaggeration: 1\n",
243
- " })\n",
244
- " );\n",
245
- "\n",
246
- "\"\"\""
247
- ]
248
- },
249
- {
250
- "cell_type": "code",
251
- "execution_count": null,
252
- "metadata": {},
253
- "outputs": [],
254
- "source": [
255
- "m.set_esm(esm)\n",
256
- "m"
257
- ]
258
- },
259
- {
260
- "cell_type": "markdown",
261
- "metadata": {},
262
- "source": [
263
- "![](https://i.imgur.com/TTN1mx5.png)"
264
- ]
265
- }
266
- ],
267
- "metadata": {
268
- "kernelspec": {
269
- "display_name": "Python 3",
270
- "language": "python",
271
- "name": "python3"
272
- },
273
- "language_info": {
274
- "codemirror_mode": {
275
- "name": "ipython",
276
- "version": 3
277
- },
278
- "file_extension": ".py",
279
- "mimetype": "text/x-python",
280
- "name": "python",
281
- "nbconvert_exporter": "python",
282
- "pygments_lexer": "ipython3",
283
- "version": "3.10.8"
284
- }
285
- },
286
- "nbformat": 4,
287
- "nbformat_minor": 4
288
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/nlcd_app.ipynb DELETED
@@ -1,214 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "a6624f5d-8d87-41e1-949e-e01ea4bfd1fd",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "# Import libraries\n",
11
- "import ee\n",
12
- "import geemap"
13
- ]
14
- },
15
- {
16
- "cell_type": "code",
17
- "execution_count": null,
18
- "id": "5b37a322-6723-4eef-b248-eca735b2fb11",
19
- "metadata": {},
20
- "outputs": [],
21
- "source": [
22
- "# Create an interactive map by specifying the center (lat, lon) and zoom level (1-18).\n",
23
- "Map = geemap.Map(center=[40, -100], zoom=4, height=\"800px\")\n",
24
- "Map"
25
- ]
26
- },
27
- {
28
- "cell_type": "code",
29
- "execution_count": null,
30
- "id": "8b939af3-e209-44fd-94cb-48027334ad71",
31
- "metadata": {},
32
- "outputs": [],
33
- "source": [
34
- "# Import the NLCD collection.\n",
35
- "dataset = ee.ImageCollection('USGS/NLCD_RELEASES/2019_REL/NLCD')\n",
36
- "\n",
37
- "# Filter the collection to the 2016 product.\n",
38
- "nlcd2019 = dataset.filter(ee.Filter.eq('system:index', '2019')).first()\n",
39
- "\n",
40
- "# Select the land cover band.\n",
41
- "landcover = nlcd2019.select('landcover')\n",
42
- "\n",
43
- "# Display land cover on the map.\n",
44
- "Map.addLayer(landcover, {}, 'NLCD 2019')"
45
- ]
46
- },
47
- {
48
- "cell_type": "code",
49
- "execution_count": null,
50
- "id": "bc45b8da",
51
- "metadata": {},
52
- "outputs": [],
53
- "source": [
54
- "# Add the NLCD legend to the map.\n",
55
- "Map.add_legend(title='NLCD Land Cover Classification', builtin_legend='NLCD')"
56
- ]
57
- },
58
- {
59
- "cell_type": "code",
60
- "execution_count": null,
61
- "id": "76b01ae9-d730-417f-88ff-143d0d4c20d6",
62
- "metadata": {},
63
- "outputs": [],
64
- "source": [
65
- "# # To add a custom legend to the map, uncomment the following code and modify the legend dictionary.\n",
66
- "# legend_dict = {\n",
67
- "# '11 Open Water': '466b9f',\n",
68
- "# '12 Perennial Ice/Snow': 'd1def8',\n",
69
- "# '21 Developed, Open Space': 'dec5c5',\n",
70
- "# '22 Developed, Low Intensity': 'd99282',\n",
71
- "# '23 Developed, Medium Intensity': 'eb0000',\n",
72
- "# '24 Developed High Intensity': 'ab0000',\n",
73
- "# '31 Barren Land (Rock/Sand/Clay)': 'b3ac9f',\n",
74
- "# '41 Deciduous Forest': '68ab5f',\n",
75
- "# '42 Evergreen Forest': '1c5f2c',\n",
76
- "# '43 Mixed Forest': 'b5c58f',\n",
77
- "# '51 Dwarf Scrub': 'af963c',\n",
78
- "# '52 Shrub/Scrub': 'ccb879',\n",
79
- "# '71 Grassland/Herbaceous': 'dfdfc2',\n",
80
- "# '72 Sedge/Herbaceous': 'd1d182',\n",
81
- "# '73 Lichens': 'a3cc51',\n",
82
- "# '74 Moss': '82ba9e',\n",
83
- "# '81 Pasture/Hay': 'dcd939',\n",
84
- "# '82 Cultivated Crops': 'ab6c28',\n",
85
- "# '90 Woody Wetlands': 'b8d9eb',\n",
86
- "# '95 Emergent Herbaceous Wetlands': '6c9fb8'\n",
87
- "# }\n",
88
- "# Map.add_legend(legend_title=\"NLCD Land Cover Classification\", legend_dict=legend_dict)"
89
- ]
90
- },
91
- {
92
- "cell_type": "code",
93
- "execution_count": null,
94
- "id": "44c16a8e-7d13-4e46-bfaf-12178aa1b0be",
95
- "metadata": {},
96
- "outputs": [],
97
- "source": [
98
- "# # Print the list of system ids of all available NLCD images.\n",
99
- "# dataset.aggregate_array(\"system:id\").getInfo()"
100
- ]
101
- },
102
- {
103
- "cell_type": "code",
104
- "execution_count": null,
105
- "id": "a49fbecc-b0bf-4010-83b1-8628f5b05459",
106
- "metadata": {},
107
- "outputs": [],
108
- "source": [
109
- "# Select the seven NLCD epoches after 2000.\n",
110
- "years = ['2001', '2004', '2006', '2008', '2011', '2013', '2016', '2019']"
111
- ]
112
- },
113
- {
114
- "cell_type": "code",
115
- "execution_count": null,
116
- "id": "cf361b54",
117
- "metadata": {},
118
- "outputs": [],
119
- "source": [
120
- "# Get an NLCD image by year.\n",
121
- "def getNLCD(year):\n",
122
- " # Import the NLCD collection.\n",
123
- " dataset = ee.ImageCollection('USGS/NLCD_RELEASES/2019_REL/NLCD')\n",
124
- "\n",
125
- " # Filter the collection by year.\n",
126
- " nlcd = dataset.filter(ee.Filter.eq('system:index', year)).first()\n",
127
- " \n",
128
- " # Select the land cover band.\n",
129
- " landcover = nlcd.select('landcover');\n",
130
- " return landcover"
131
- ]
132
- },
133
- {
134
- "cell_type": "code",
135
- "execution_count": null,
136
- "id": "6c0bbf8a-d4c9-402e-b0ff-b53f14d836bf",
137
- "metadata": {},
138
- "outputs": [],
139
- "source": [
140
- "## Create an NLCD image collection for the selected years.\n",
141
- "collection = ee.ImageCollection(ee.List(years).map(lambda year: getNLCD(year)))"
142
- ]
143
- },
144
- {
145
- "cell_type": "code",
146
- "execution_count": null,
147
- "id": "3dcd6df2",
148
- "metadata": {},
149
- "outputs": [],
150
- "source": [
151
- "# # Print the list of system ids of selected NLCD images.\n",
152
- "# collection.aggregate_array('system:id').getInfo()"
153
- ]
154
- },
155
- {
156
- "cell_type": "code",
157
- "execution_count": null,
158
- "id": "0a5eac53",
159
- "metadata": {},
160
- "outputs": [],
161
- "source": [
162
- "# Create a list of labels to populate the dropdown list. \n",
163
- "labels = [f'NLCD {year}' for year in years]\n",
164
- "# labels"
165
- ]
166
- },
167
- {
168
- "cell_type": "code",
169
- "execution_count": null,
170
- "id": "78e89ca5",
171
- "metadata": {},
172
- "outputs": [],
173
- "source": [
174
- "# Add a split-panel map for visualizing NLCD land cover change.\n",
175
- "Map.ts_inspector(left_ts=collection, right_ts=collection, left_names=labels, right_names=labels)\n",
176
- "# Map"
177
- ]
178
- }
179
- ],
180
- "metadata": {
181
- "kernelspec": {
182
- "display_name": "Python 3",
183
- "language": "python",
184
- "name": "python3"
185
- },
186
- "language_info": {
187
- "codemirror_mode": {
188
- "name": "ipython",
189
- "version": 3
190
- },
191
- "file_extension": ".py",
192
- "mimetype": "text/x-python",
193
- "name": "python",
194
- "nbconvert_exporter": "python",
195
- "pygments_lexer": "ipython3",
196
- "version": "3.10.8"
197
- },
198
- "toc": {
199
- "base_numbering": 1,
200
- "nav_menu": {},
201
- "number_sections": true,
202
- "sideBar": true,
203
- "skip_h1_title": false,
204
- "title_cell": "Table of Contents",
205
- "title_sidebar": "Contents",
206
- "toc_cell": false,
207
- "toc_position": {},
208
- "toc_section_display": true,
209
- "toc_window_display": false
210
- }
211
- },
212
- "nbformat": 4,
213
- "nbformat_minor": 5
214
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
notebooks/openlayers.ipynb DELETED
@@ -1,112 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "attachments": {},
5
- "cell_type": "markdown",
6
- "metadata": {},
7
- "source": [
8
- "[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/giswqs/mapwidget/blob/master/docs/examples/openlayers.ipynb)\n",
9
- "[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/giswqs/mapwidget&urlpath=lab/tree/mapwidget/docs/examples/openlayers.ipynb&branch=master)\n",
10
- "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/giswqs/mapwidget/blob/master/docs/examples/openlayers.ipynb)"
11
- ]
12
- },
13
- {
14
- "cell_type": "code",
15
- "execution_count": null,
16
- "metadata": {},
17
- "outputs": [],
18
- "source": [
19
- "# %pip install mapwidget"
20
- ]
21
- },
22
- {
23
- "cell_type": "code",
24
- "execution_count": null,
25
- "metadata": {},
26
- "outputs": [],
27
- "source": [
28
- "import mapwidget.openlayers as mapwidget"
29
- ]
30
- },
31
- {
32
- "cell_type": "code",
33
- "execution_count": null,
34
- "metadata": {},
35
- "outputs": [],
36
- "source": [
37
- "m = mapwidget.Map(center=[20, 0], zoom=2, height='600px')\n",
38
- "m"
39
- ]
40
- },
41
- {
42
- "attachments": {},
43
- "cell_type": "markdown",
44
- "metadata": {},
45
- "source": [
46
- "![](https://i.imgur.com/CqP4Ehm.png)"
47
- ]
48
- },
49
- {
50
- "cell_type": "code",
51
- "execution_count": null,
52
- "metadata": {},
53
- "outputs": [],
54
- "source": [
55
- "m.clicked_latlng"
56
- ]
57
- },
58
- {
59
- "cell_type": "code",
60
- "execution_count": null,
61
- "metadata": {},
62
- "outputs": [],
63
- "source": [
64
- "m.center"
65
- ]
66
- },
67
- {
68
- "cell_type": "code",
69
- "execution_count": null,
70
- "metadata": {},
71
- "outputs": [],
72
- "source": [
73
- "m.zoom"
74
- ]
75
- },
76
- {
77
- "cell_type": "code",
78
- "execution_count": null,
79
- "metadata": {},
80
- "outputs": [],
81
- "source": [
82
- "m.bounds"
83
- ]
84
- }
85
- ],
86
- "metadata": {
87
- "kernelspec": {
88
- "display_name": "Python 3 (ipykernel)",
89
- "language": "python",
90
- "name": "python3"
91
- },
92
- "language_info": {
93
- "codemirror_mode": {
94
- "name": "ipython",
95
- "version": 3
96
- },
97
- "file_extension": ".py",
98
- "mimetype": "text/x-python",
99
- "name": "python",
100
- "nbconvert_exporter": "python",
101
- "pygments_lexer": "ipython3",
102
- "version": "3.10.8"
103
- },
104
- "vscode": {
105
- "interpreter": {
106
- "hash": "31f05ea183a4718249d13ada7f166c6bdba1d00716247af5c11c23af8d5923f1"
107
- }
108
- }
109
- },
110
- "nbformat": 4,
111
- "nbformat_minor": 4
112
- }