unisaacarroyov giswqs commited on
Commit
507d98b
·
0 Parent(s):

Duplicate from giswqs/voila-geospatial

Browse files

Co-authored-by: Qiusheng Wu <[email protected]>

.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.github/workflows/sync-hf.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ # to run this workflow manually from the Actions tab
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ sync-to-hub:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ lfs: true
17
+ - name: Push to hub
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push https://giswqs:[email protected]/spaces/giswqs/voila-geospatial main
.gitignore ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+ Aptfile
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ pip-wheel-metadata/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ .python-version
87
+
88
+ # pipenv
89
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
90
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
91
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
92
+ # install all needed dependencies.
93
+ #Pipfile.lock
94
+
95
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
96
+ __pypackages__/
97
+
98
+ # Celery stuff
99
+ celerybeat-schedule
100
+ celerybeat.pid
101
+
102
+ # SageMath parsed files
103
+ *.sage.py
104
+
105
+ # Environments
106
+ .env
107
+ .venv
108
+ env/
109
+ venv/
110
+ ENV/
111
+ env.bak/
112
+ venv.bak/
113
+
114
+ # Spyder project settings
115
+ .spyderproject
116
+ .spyproject
117
+
118
+ # Rope project settings
119
+ .ropeproject
120
+
121
+ # mkdocs documentation
122
+ /site
123
+
124
+ # mypy
125
+ .mypy_cache/
126
+ .dmypy.json
127
+ dmypy.json
128
+
129
+ # Pyre type checker
130
+ .pyre/
Dockerfile ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM jupyter/base-notebook:latest
2
+
3
+ RUN mamba install -c conda-forge leafmap geemap mapwidget geopandas localtileserver voila nodejs -y && \
4
+ fix-permissions "${CONDA_DIR}" && \
5
+ fix-permissions "/home/${NB_USER}"
6
+
7
+ # COPY requirements.txt .
8
+ # RUN pip install --no-cache-dir -r requirements.txt
9
+
10
+ RUN mkdir ./notebooks
11
+ COPY /notebooks ./notebooks
12
+
13
+ COPY run.sh .
14
+
15
+ ENV PROJ_LIB='/opt/conda/share/proj'
16
+
17
+ USER root
18
+ RUN chown -R ${NB_UID} ${HOME}
19
+ USER ${NB_USER}
20
+
21
+ RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
22
+
23
+ EXPOSE 8866
24
+
25
+ CMD ["/bin/bash", "run.sh"]
README.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Voila Geospatial
3
+ emoji: 🦀
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ app_port: 8866
10
+ duplicated_from: giswqs/voila-geospatial
11
+ ---
12
+
13
+ ## Links
14
+
15
+ - GitHub: <https://github.com/opengeos/voila-geospatial>
16
+ - Hugging Face: <https://huggingface.co/spaces/giswqs/voila-geospatial/tree/main>
17
+ - Web App: <https://giswqs-voila-geospatial.hf.space>
18
+
19
+ ## How to deploy this app to Hugging Face Spaces
20
+
21
+ 1. Go to <https://huggingface.co/spaces/giswqs/voila-geospatial/tree/main> and duplicate the space to your own space.
22
+
23
+ ![](https://i.imgur.com/4ib5BzB.png)
24
+
25
+ 2. Set environment variables as needed. For example, if you use Google Earth Engine, you need to set `EARTHENGINE_TOKEN` to your Earth Engine token. The token value should be copied from the following file depending on your operating system:
26
+
27
+ ```text
28
+ Windows: C:\\Users\\USERNAME\\.config\\earthengine\\credentials
29
+ Linux: /home/USERNAME/.config/earthengine/credentials
30
+ MacOS: /Users/USERNAME/.config/earthengine/credentials
31
+ ```
32
+
33
+ Simply open the file and copy **ALL** the content to the `EARTHENGINE_TOKEN` environment variable.
34
+
35
+ ![](https://i.imgur.com/i04gzyH.png)
36
+
37
+ ![](https://i.imgur.com/Ex37Ut7.png)
38
+
39
+ 3. After the space is built successfully, click the `Embed this Space` menu and find the `Direct URL` for the app, such as <https://giswqs-voila-geospatial.hf.space>.
40
+
41
+ ![](https://i.imgur.com/V2Lp0dP.png)
42
+
43
+ ![](https://i.imgur.com/klhR5FL.png)
44
+
45
+ 4. Add your own notebooks to the `notebooks` folder and wait for the app to be rebuilt.
46
+
47
+ 5. To hide the source code from the notebook, modify `run.sh` and set `--strip_sources=True`.
notebooks/bqplot.ipynb ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/[email protected]\";\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/[email protected]/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/[email protected]\";\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/[email protected]?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/[email protected]\";\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/[email protected]?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/[email protected]/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/[email protected]/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 ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/openlayers.ipynb ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ voila
2
+ geemap
3
+ leafmap
4
+
run.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ voila --Voila.ip=0.0.0.0 --no-browser --strip_sources=True --enable_nbextensions=True --MappingKernelManager.cull_interval=60 --MappingKernelManager.cull_idle_timeout=120 --NotebookClient.iopub_timeout=30 notebooks/