rhamon-garcia commited on
Commit
4c82f8a
·
verified ·
1 Parent(s): 63edcd1

Upload 22 files

Browse files
.gitattributes CHANGED
@@ -1,35 +1,35 @@
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
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
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
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *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 --force https://giswqs:[email protected]/spaces/giswqs/solara-geemap main
.gitignore ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+ private/
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
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
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/#use-with-ide
111
+ .pdm.toml
112
+
113
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ #.idea/
.pre-commit-config.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-toml
6
+ - id: check-yaml
7
+ - id: end-of-file-fixer
8
+ types: [python]
9
+ - id: trailing-whitespace
10
+ - id: requirements-txt-fixer
11
+ - id: check-added-large-files
12
+ args: ["--maxkb=500"]
13
+
14
+ - repo: https://github.com/psf/black
15
+ rev: 24.10.0
16
+ hooks:
17
+ - id: black-jupyter
18
+ language_version: python3
19
+
20
+ - repo: https://github.com/codespell-project/codespell
21
+ rev: v2.3.0
22
+ hooks:
23
+ - id: codespell
24
+ args:
25
+ [
26
+ "--ignore-words-list=gis,timeseries,sav,slowy",
27
+ "--skip=*.json,*.csv",
28
+ ]
29
+
30
+ - repo: https://github.com/kynan/nbstripout
31
+ rev: 0.7.1
32
+ hooks:
33
+ - id: nbstripout
Dockerfile ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM jupyter/base-notebook:latest
2
+
3
+ RUN mamba install -c conda-forge leafmap geopandas localtileserver -y && \
4
+ fix-permissions "${CONDA_DIR}" && \
5
+ fix-permissions "/home/${NB_USER}"
6
+
7
+ COPY requirements.txt .
8
+ RUN pip install -r requirements.txt
9
+
10
+ RUN mkdir ./pages
11
+ COPY /pages ./pages
12
+
13
+ ENV PROJ_LIB='/opt/conda/share/proj'
14
+
15
+ USER root
16
+ RUN chown -R ${NB_UID} ${HOME}
17
+ USER ${NB_USER}
18
+
19
+ EXPOSE 8765
20
+
21
+ CMD ["solara", "run", "./pages", "--host=0.0.0.0"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Open Geospatial Solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,11 +1,58 @@
1
- ---
2
- title: Zoneamento Agroclima
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: pink
6
- sdk: docker
7
- pinned: false
8
- license: mit
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Solara Geemap
3
+ emoji: 🏃
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ app_port: 8765
10
+ ---
11
+
12
+ ## Earth Engine Web Apps
13
+
14
+ ### Introduction
15
+
16
+ **A collection of Earth Engine web apps developed using [Solara](https://github.com/widgetti/solara) and geemap**
17
+
18
+ - Web App: <https://giswqs-solara-geemap.hf.space>
19
+ - GitHub: <https://github.com/opengeos/solara-geemap>
20
+ - Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geemap>
21
+
22
+ ### How to deploy this app on Hugging Face Spaces
23
+
24
+ 1. Go to <https://huggingface.co/spaces/giswqs/solara-geemap/tree/main> and duplicate the space to your own space.
25
+
26
+ ![](https://i.imgur.com/gTg4V2x.png)
27
+
28
+ 2. You need to set `EARTHENGINE_TOKEN` in order to use Earth Engine. The token value should be copied from the following file depending on your operating system:
29
+
30
+ ```text
31
+ Windows: C:\\Users\\USERNAME\\.config\\earthengine\\credentials
32
+ Linux: /home/USERNAME/.config/earthengine/credentials
33
+ MacOS: /Users/USERNAME/.config/earthengine/credentials
34
+ ```
35
+
36
+ Simply open the file and copy **ALL** the content to the `EARTHENGINE_TOKEN` environment variable.
37
+
38
+ ![](https://i.imgur.com/i04gzyH.png)
39
+
40
+ ![](https://i.imgur.com/Ex37Ut7.png)
41
+
42
+ Alternatively, you can run the following code to retrieve your Earth Engine token:
43
+
44
+ ```python
45
+ import geemap
46
+ geemap.get_ee_token()
47
+ ```
48
+
49
+ Copy all the content of the printed token and set it as the `EARTHENGINE_TOKEN` environment variable.
50
+
51
+ 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-solara-geemap.hf.space>.
52
+
53
+ ![](https://i.imgur.com/DNM36sk.png)
54
+
55
+ ![](https://i.imgur.com/KX82lSf.png)
56
+
57
+ 4. Add your own apps (\*.py) to the `pages` folder.
58
+ 5. Commit and push your changes to the repository. Wait for the space to be built successfully.
images/LOGO GAIA.png ADDED
notebooks/01_basic.ipynb ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/01_basic.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import geemap\n",
26
+ "import solara\n",
27
+ "\n",
28
+ "zoom = solara.reactive(4)\n",
29
+ "center = solara.reactive((40, -100))\n",
30
+ "bounds = solara.reactive(None)\n",
31
+ "\n",
32
+ "\n",
33
+ "@solara.component\n",
34
+ "def Page():\n",
35
+ " # Isolation is required to prevent the map from overlapping navigation (when screen width < 960px)\n",
36
+ " with solara.Column(\n",
37
+ " style={\"min-width\": \"500px\", \"height\": \"780px\", \"isolation\": \"isolate\"}\n",
38
+ " ):\n",
39
+ " # solara components support reactive variables\n",
40
+ " solara.SliderInt(label=\"Zoom level\", value=zoom, min=1, max=20)\n",
41
+ " # using 3rd party widget library require wiring up the events manually\n",
42
+ " # using zoom.value and zoom.set\n",
43
+ " geemap.Map.element( # type: ignore\n",
44
+ " zoom=zoom.value,\n",
45
+ " on_zoom=zoom.set,\n",
46
+ " center=center.value,\n",
47
+ " on_center=center.set,\n",
48
+ " on_bounds=bounds.set,\n",
49
+ " scroll_wheel_zoom=True,\n",
50
+ " height=\"600px\",\n",
51
+ " )\n",
52
+ " solara.Text(f\"Zoom: {zoom.value}\")\n",
53
+ " solara.Text(f\"Center: {center.value}\")\n",
54
+ " solara.Text(f\"Bounds: {bounds.value}\")"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "metadata": {},
61
+ "outputs": [],
62
+ "source": [
63
+ "Page()"
64
+ ]
65
+ }
66
+ ],
67
+ "metadata": {
68
+ "kernelspec": {
69
+ "display_name": "geo",
70
+ "language": "python",
71
+ "name": "python3"
72
+ },
73
+ "language_info": {
74
+ "codemirror_mode": {
75
+ "name": "ipython",
76
+ "version": 3
77
+ },
78
+ "file_extension": ".py",
79
+ "mimetype": "text/x-python",
80
+ "name": "python",
81
+ "nbconvert_exporter": "python",
82
+ "pygments_lexer": "ipython3",
83
+ "version": "3.11.8"
84
+ }
85
+ },
86
+ "nbformat": 4,
87
+ "nbformat_minor": 2
88
+ }
notebooks/02_inspector.ipynb ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/02_inspector.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import ee\n",
26
+ "import geemap\n",
27
+ "import solara\n",
28
+ "\n",
29
+ "\n",
30
+ "class Map(geemap.Map):\n",
31
+ " def __init__(self, **kwargs):\n",
32
+ " super().__init__(**kwargs)\n",
33
+ " self.add_ee_data()\n",
34
+ " self.add(\"layer_manager\")\n",
35
+ " self.add(\"inspector\")\n",
36
+ "\n",
37
+ " def add_ee_data(self):\n",
38
+ " # Add Earth Engine dataset\n",
39
+ " dem = ee.Image(\"USGS/SRTMGL1_003\")\n",
40
+ " landsat7 = ee.Image(\"LANDSAT/LE7_TOA_5YEAR/1999_2003\").select(\n",
41
+ " [\"B1\", \"B2\", \"B3\", \"B4\", \"B5\", \"B7\"]\n",
42
+ " )\n",
43
+ " states = ee.FeatureCollection(\"TIGER/2018/States\")\n",
44
+ "\n",
45
+ " # Set visualization parameters.\n",
46
+ " vis_params = {\n",
47
+ " \"min\": 0,\n",
48
+ " \"max\": 4000,\n",
49
+ " \"palette\": [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"],\n",
50
+ " }\n",
51
+ "\n",
52
+ " # Add Earth Engine layers to Map\n",
53
+ " self.addLayer(\n",
54
+ " landsat7,\n",
55
+ " {\"bands\": [\"B4\", \"B3\", \"B2\"], \"min\": 20, \"max\": 200, \"gamma\": 2.0},\n",
56
+ " \"Landsat 7\",\n",
57
+ " True,\n",
58
+ " )\n",
59
+ " self.addLayer(dem, vis_params, \"SRTM DEM\", True, 1)\n",
60
+ " self.addLayer(states, {}, \"US States\")\n",
61
+ "\n",
62
+ "\n",
63
+ "@solara.component\n",
64
+ "def Page():\n",
65
+ " with solara.Column(style={\"min-width\": \"500px\", \"isolation\": \"isolate\"}):\n",
66
+ " Map.element(\n",
67
+ " center=[40, -100],\n",
68
+ " zoom=4,\n",
69
+ " height=\"600px\",\n",
70
+ " )"
71
+ ]
72
+ },
73
+ {
74
+ "cell_type": "code",
75
+ "execution_count": null,
76
+ "metadata": {},
77
+ "outputs": [],
78
+ "source": [
79
+ "Page()"
80
+ ]
81
+ }
82
+ ],
83
+ "metadata": {
84
+ "kernelspec": {
85
+ "display_name": "geo",
86
+ "language": "python",
87
+ "name": "python3"
88
+ },
89
+ "language_info": {
90
+ "codemirror_mode": {
91
+ "name": "ipython",
92
+ "version": 3
93
+ },
94
+ "file_extension": ".py",
95
+ "mimetype": "text/x-python",
96
+ "name": "python",
97
+ "nbconvert_exporter": "python",
98
+ "pygments_lexer": "ipython3",
99
+ "version": "3.11.8"
100
+ }
101
+ },
102
+ "nbformat": 4,
103
+ "nbformat_minor": 2
104
+ }
notebooks/03_plotting.ipynb ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/03_plotting.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import ee\n",
26
+ "import geemap\n",
27
+ "import solara\n",
28
+ "\n",
29
+ "\n",
30
+ "class Map(geemap.Map):\n",
31
+ " def __init__(self, **kwargs):\n",
32
+ " super().__init__(**kwargs)\n",
33
+ " self.add_ee_data()\n",
34
+ " self.add_plot_gui()\n",
35
+ "\n",
36
+ " def add_ee_data(self):\n",
37
+ " landsat7 = ee.Image(\"LANDSAT/LE7_TOA_5YEAR/1999_2003\").select(\n",
38
+ " [\"B1\", \"B2\", \"B3\", \"B4\", \"B5\", \"B7\"]\n",
39
+ " )\n",
40
+ "\n",
41
+ " landsat_vis = {\"bands\": [\"B4\", \"B3\", \"B2\"], \"gamma\": 1.4}\n",
42
+ " self.addLayer(landsat7, landsat_vis, \"Landsat\")\n",
43
+ "\n",
44
+ " hyperion = ee.ImageCollection(\"EO1/HYPERION\").filter(\n",
45
+ " ee.Filter.date(\"2016-01-01\", \"2017-03-01\")\n",
46
+ " )\n",
47
+ "\n",
48
+ " hyperion_vis = {\n",
49
+ " \"min\": 1000.0,\n",
50
+ " \"max\": 14000.0,\n",
51
+ " \"gamma\": 2.5,\n",
52
+ " }\n",
53
+ " self.addLayer(hyperion, hyperion_vis, \"Hyperion\")\n",
54
+ "\n",
55
+ "\n",
56
+ "@solara.component\n",
57
+ "def Page():\n",
58
+ " with solara.Column(style={\"min-width\": \"500px\", \"isolation\": \"isolate\"}):\n",
59
+ " Map.element(\n",
60
+ " center=[40, -100],\n",
61
+ " zoom=4,\n",
62
+ " height=\"600px\",\n",
63
+ " )"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": null,
69
+ "metadata": {},
70
+ "outputs": [],
71
+ "source": [
72
+ "Page()"
73
+ ]
74
+ }
75
+ ],
76
+ "metadata": {
77
+ "kernelspec": {
78
+ "display_name": "geo",
79
+ "language": "python",
80
+ "name": "python3"
81
+ },
82
+ "language_info": {
83
+ "codemirror_mode": {
84
+ "name": "ipython",
85
+ "version": 3
86
+ },
87
+ "file_extension": ".py",
88
+ "mimetype": "text/x-python",
89
+ "name": "python",
90
+ "nbconvert_exporter": "python",
91
+ "pygments_lexer": "ipython3",
92
+ "version": "3.11.8"
93
+ }
94
+ },
95
+ "nbformat": 4,
96
+ "nbformat_minor": 2
97
+ }
notebooks/04_split_map.ipynb ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/04_split_map.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import ee\n",
26
+ "import geemap\n",
27
+ "import solara\n",
28
+ "\n",
29
+ "\n",
30
+ "class Map(geemap.Map):\n",
31
+ " def __init__(self, **kwargs):\n",
32
+ " super().__init__(**kwargs)\n",
33
+ " self.add_ee_data()\n",
34
+ "\n",
35
+ " def add_ee_data(self):\n",
36
+ " # Select the eight NLCD epochs after 2000.\n",
37
+ " years = [\"2001\", \"2004\", \"2006\", \"2008\", \"2011\", \"2013\", \"2016\", \"2019\"]\n",
38
+ "\n",
39
+ " # Get an NLCD image by year.\n",
40
+ " def getNLCD(year):\n",
41
+ " # Import the NLCD collection.\n",
42
+ " dataset = ee.ImageCollection(\"USGS/NLCD_RELEASES/2019_REL/NLCD\")\n",
43
+ "\n",
44
+ " # Filter the collection by year.\n",
45
+ " nlcd = dataset.filter(ee.Filter.eq(\"system:index\", year)).first()\n",
46
+ "\n",
47
+ " # Select the land cover band.\n",
48
+ " landcover = nlcd.select(\"landcover\")\n",
49
+ " return landcover\n",
50
+ "\n",
51
+ " ## Create an NLCD image collection for the selected years.\n",
52
+ " collection = ee.ImageCollection(ee.List(years).map(lambda year: getNLCD(year)))\n",
53
+ "\n",
54
+ " # Create a list of labels to populate the dropdown list.\n",
55
+ " labels = [f\"NLCD {year}\" for year in years]\n",
56
+ "\n",
57
+ " # Add a split-panel map for visualizing NLCD land cover change.\n",
58
+ " self.ts_inspector(\n",
59
+ " left_ts=collection,\n",
60
+ " right_ts=collection,\n",
61
+ " left_names=labels,\n",
62
+ " right_names=labels,\n",
63
+ " )\n",
64
+ "\n",
65
+ " # Add the NLCD legend to the map.\n",
66
+ " self.add_legend(\n",
67
+ " title=\"NLCD Land Cover Type\",\n",
68
+ " builtin_legend=\"NLCD\",\n",
69
+ " height=\"460px\",\n",
70
+ " add_header=False,\n",
71
+ " )\n",
72
+ "\n",
73
+ "\n",
74
+ "@solara.component\n",
75
+ "def Page():\n",
76
+ " with solara.Column(style={\"min-width\": \"500px\", \"isolation\": \"isolate\"}):\n",
77
+ " Map.element(\n",
78
+ " center=[40, -100],\n",
79
+ " zoom=4,\n",
80
+ " height=\"600px\",\n",
81
+ " )"
82
+ ]
83
+ },
84
+ {
85
+ "cell_type": "code",
86
+ "execution_count": null,
87
+ "metadata": {},
88
+ "outputs": [],
89
+ "source": [
90
+ "Page()"
91
+ ]
92
+ }
93
+ ],
94
+ "metadata": {
95
+ "kernelspec": {
96
+ "display_name": "geo",
97
+ "language": "python",
98
+ "name": "python3"
99
+ },
100
+ "language_info": {
101
+ "codemirror_mode": {
102
+ "name": "ipython",
103
+ "version": 3
104
+ },
105
+ "file_extension": ".py",
106
+ "mimetype": "text/x-python",
107
+ "name": "python",
108
+ "nbconvert_exporter": "python",
109
+ "pygments_lexer": "ipython3",
110
+ "version": "3.11.8"
111
+ }
112
+ },
113
+ "nbformat": 4,
114
+ "nbformat_minor": 2
115
+ }
notebooks/05_timelapse.ipynb ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/05_timelapse.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import geemap\n",
26
+ "import solara\n",
27
+ "\n",
28
+ "\n",
29
+ "class Map(geemap.Map):\n",
30
+ " def __init__(self, **kwargs):\n",
31
+ " super().__init__(**kwargs)\n",
32
+ " self.add_basemap(\"Esri.WorldImagery\")\n",
33
+ " self.add_gui(\"timelapse\", basemap=None)\n",
34
+ "\n",
35
+ "\n",
36
+ "@solara.component\n",
37
+ "def Page():\n",
38
+ " with solara.Column(style={\"min-width\": \"500px\", \"isolation\": \"isolate\"}):\n",
39
+ " Map.element(\n",
40
+ " center=[20, -0],\n",
41
+ " zoom=2,\n",
42
+ " height=\"750px\",\n",
43
+ " zoom_ctrl=False,\n",
44
+ " measure_ctrl=False,\n",
45
+ " )"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": null,
51
+ "metadata": {},
52
+ "outputs": [],
53
+ "source": [
54
+ "Page()"
55
+ ]
56
+ }
57
+ ],
58
+ "metadata": {
59
+ "kernelspec": {
60
+ "display_name": "geo",
61
+ "language": "python",
62
+ "name": "python3"
63
+ },
64
+ "language_info": {
65
+ "codemirror_mode": {
66
+ "name": "ipython",
67
+ "version": 3
68
+ },
69
+ "file_extension": ".py",
70
+ "mimetype": "text/x-python",
71
+ "name": "python",
72
+ "nbconvert_exporter": "python",
73
+ "pygments_lexer": "ipython3",
74
+ "version": "3.11.8"
75
+ }
76
+ },
77
+ "nbformat": 4,
78
+ "nbformat_minor": 2
79
+ }
notebooks/06_timeseries.ipynb ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/06_timeseries.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import geemap\n",
26
+ "import ipywidgets as widgets\n",
27
+ "import solara\n",
28
+ "from geemap import get_current_year, jslink_slider_label\n",
29
+ "\n",
30
+ "\n",
31
+ "class Map(geemap.Map):\n",
32
+ " def __init__(self, **kwargs):\n",
33
+ " super().__init__(**kwargs)\n",
34
+ " self.add_basemap(\"Esri.WorldImagery\")\n",
35
+ " self.add_ts_gui(position=\"topright\")\n",
36
+ "\n",
37
+ " def clean_up(self):\n",
38
+ " if hasattr(self, \"slider_ctrl\") and self.slider_ctrl is not None:\n",
39
+ " self.remove(self.slider_ctrl)\n",
40
+ " delattr(self, \"slider_ctrl\")\n",
41
+ "\n",
42
+ " layer = self.find_layer(\"Time series\")\n",
43
+ " if layer is not None:\n",
44
+ " self.remove(layer)\n",
45
+ " layer = self.find_layer(\"Image X\")\n",
46
+ " if layer is not None:\n",
47
+ " self.remove(layer)\n",
48
+ "\n",
49
+ " draw_layer = self.find_layer(\"Drawn Features\")\n",
50
+ " if draw_layer is not None:\n",
51
+ " self.remove(draw_layer)\n",
52
+ "\n",
53
+ " def add_ts_gui(self, position=\"topright\", **kwargs):\n",
54
+ "\n",
55
+ " widget_width = \"350px\"\n",
56
+ " padding = \"0px 0px 0px 5px\" # upper, right, bottom, left\n",
57
+ " style = {\"description_width\": \"initial\"}\n",
58
+ " current_year = get_current_year()\n",
59
+ "\n",
60
+ " collection = widgets.Dropdown(\n",
61
+ " options=[\n",
62
+ " \"Landsat TM-ETM-OLI Surface Reflectance\",\n",
63
+ " ],\n",
64
+ " value=\"Landsat TM-ETM-OLI Surface Reflectance\",\n",
65
+ " description=\"Collection:\",\n",
66
+ " layout=widgets.Layout(width=widget_width, padding=padding),\n",
67
+ " style=style,\n",
68
+ " )\n",
69
+ " bands = widgets.Dropdown(\n",
70
+ " description=\"Bands:\",\n",
71
+ " options=[\n",
72
+ " \"Red/Green/Blue\",\n",
73
+ " \"NIR/Red/Green\",\n",
74
+ " \"SWIR2/SWIR1/NIR\",\n",
75
+ " \"NIR/SWIR1/Red\",\n",
76
+ " \"SWIR2/NIR/Red\",\n",
77
+ " \"SWIR2/SWIR1/Red\",\n",
78
+ " \"SWIR1/NIR/Blue\",\n",
79
+ " \"NIR/SWIR1/Blue\",\n",
80
+ " \"SWIR2/NIR/Green\",\n",
81
+ " \"SWIR1/NIR/Red\",\n",
82
+ " ],\n",
83
+ " value=\"SWIR1/NIR/Red\",\n",
84
+ " style=style,\n",
85
+ " layout=widgets.Layout(width=\"195px\", padding=padding),\n",
86
+ " )\n",
87
+ "\n",
88
+ " frequency = widgets.Dropdown(\n",
89
+ " description=\"Frequency:\",\n",
90
+ " options=[\"year\", \"quarter\", \"month\"],\n",
91
+ " value=\"year\",\n",
92
+ " style=style,\n",
93
+ " layout=widgets.Layout(width=\"150px\", padding=padding),\n",
94
+ " )\n",
95
+ "\n",
96
+ " start_year = widgets.IntSlider(\n",
97
+ " description=\"Start Year:\",\n",
98
+ " value=1984,\n",
99
+ " min=1984,\n",
100
+ " max=current_year,\n",
101
+ " readout=False,\n",
102
+ " style=style,\n",
103
+ " layout=widgets.Layout(width=\"138px\", padding=padding),\n",
104
+ " )\n",
105
+ "\n",
106
+ " start_year_label = widgets.Label(\"1984\")\n",
107
+ " jslink_slider_label(start_year, start_year_label)\n",
108
+ "\n",
109
+ " end_year = widgets.IntSlider(\n",
110
+ " description=\"End Year:\",\n",
111
+ " value=current_year,\n",
112
+ " min=1984,\n",
113
+ " max=current_year,\n",
114
+ " readout=False,\n",
115
+ " style=style,\n",
116
+ " layout=widgets.Layout(width=\"138px\", padding=padding),\n",
117
+ " )\n",
118
+ " end_year_label = widgets.Label(str(current_year))\n",
119
+ " jslink_slider_label(end_year, end_year_label)\n",
120
+ "\n",
121
+ " start_month = widgets.IntSlider(\n",
122
+ " description=\"Start Month:\",\n",
123
+ " value=5,\n",
124
+ " min=1,\n",
125
+ " max=12,\n",
126
+ " readout=False,\n",
127
+ " style=style,\n",
128
+ " layout=widgets.Layout(width=\"145px\", padding=padding),\n",
129
+ " )\n",
130
+ "\n",
131
+ " start_month_label = widgets.Label(\n",
132
+ " \"5\",\n",
133
+ " layout=widgets.Layout(width=\"20px\", padding=padding),\n",
134
+ " )\n",
135
+ " jslink_slider_label(start_month, start_month_label)\n",
136
+ "\n",
137
+ " end_month = widgets.IntSlider(\n",
138
+ " description=\"End Month:\",\n",
139
+ " value=10,\n",
140
+ " min=1,\n",
141
+ " max=12,\n",
142
+ " readout=False,\n",
143
+ " style=style,\n",
144
+ " layout=widgets.Layout(width=\"155px\", padding=padding),\n",
145
+ " )\n",
146
+ "\n",
147
+ " end_month_label = widgets.Label(\"10\")\n",
148
+ " jslink_slider_label(end_month, end_month_label)\n",
149
+ "\n",
150
+ " output = widgets.Output()\n",
151
+ "\n",
152
+ " button_width = \"113px\"\n",
153
+ " apply_btn = widgets.Button(\n",
154
+ " description=\"Time slider\",\n",
155
+ " button_style=\"primary\",\n",
156
+ " tooltip=\"Click to create timeseries\",\n",
157
+ " style=style,\n",
158
+ " layout=widgets.Layout(padding=\"0px\", width=button_width),\n",
159
+ " )\n",
160
+ "\n",
161
+ " split_btn = widgets.Button(\n",
162
+ " description=\"Split map\",\n",
163
+ " button_style=\"primary\",\n",
164
+ " tooltip=\"Click to create timeseries\",\n",
165
+ " style=style,\n",
166
+ " layout=widgets.Layout(padding=\"0px\", width=button_width),\n",
167
+ " )\n",
168
+ "\n",
169
+ " reset_btn = widgets.Button(\n",
170
+ " description=\"Reset\",\n",
171
+ " button_style=\"primary\",\n",
172
+ " style=style,\n",
173
+ " layout=widgets.Layout(padding=\"0px\", width=button_width),\n",
174
+ " )\n",
175
+ "\n",
176
+ " vbox = widgets.VBox(\n",
177
+ " [\n",
178
+ " collection,\n",
179
+ " widgets.HBox([bands, frequency]),\n",
180
+ " widgets.HBox([start_year, start_year_label, end_year, end_year_label]),\n",
181
+ " widgets.HBox(\n",
182
+ " [start_month, start_month_label, end_month, end_month_label]\n",
183
+ " ),\n",
184
+ " widgets.HBox([apply_btn, split_btn, reset_btn]),\n",
185
+ " output,\n",
186
+ " ]\n",
187
+ " )\n",
188
+ " self.add_widget(vbox, position=position, add_header=True)\n",
189
+ "\n",
190
+ " def apply_btn_click(change):\n",
191
+ "\n",
192
+ " if hasattr(self, \"slider_ctrl\") and self.slider_ctrl is not None:\n",
193
+ " self.remove(self.slider_ctrl)\n",
194
+ " delattr(self, \"slider_ctrl\")\n",
195
+ "\n",
196
+ " with output:\n",
197
+ " output.clear_output()\n",
198
+ " if self.user_roi is None:\n",
199
+ " output.append_stdout(\"Please draw a ROI first.\")\n",
200
+ " else:\n",
201
+ " output.append_stdout(\"Creating time series...\")\n",
202
+ " collection = geemap.landsat_timeseries(\n",
203
+ " roi=self.user_roi,\n",
204
+ " start_year=start_year.value,\n",
205
+ " end_year=end_year.value,\n",
206
+ " start_date=str(start_month.value).zfill(2) + \"-01\",\n",
207
+ " end_date=str(end_month.value).zfill(2) + \"-01\",\n",
208
+ " frequency=frequency.value,\n",
209
+ " )\n",
210
+ " vis_params = {\n",
211
+ " \"bands\": bands.value.split(\"/\"),\n",
212
+ " \"min\": 0,\n",
213
+ " \"max\": 0.4,\n",
214
+ " }\n",
215
+ "\n",
216
+ " if frequency.value == \"year\":\n",
217
+ " date_format = \"YYYY\"\n",
218
+ " elif frequency.value == \"quarter\":\n",
219
+ " date_format = \"YYYY-MM\"\n",
220
+ " elif frequency.value == \"month\":\n",
221
+ " date_format = \"YYYY-MM\"\n",
222
+ "\n",
223
+ " self.add_time_slider(\n",
224
+ " collection,\n",
225
+ " region=self.user_roi,\n",
226
+ " vis_params=vis_params,\n",
227
+ " date_format=date_format,\n",
228
+ " )\n",
229
+ " self._draw_control.clear()\n",
230
+ " draw_layer = self.find_layer(\"Drawn Features\")\n",
231
+ " if draw_layer is not None:\n",
232
+ " self.remove(draw_layer)\n",
233
+ " output.clear_output()\n",
234
+ "\n",
235
+ " apply_btn.on_click(apply_btn_click)\n",
236
+ "\n",
237
+ " def split_btn_click(change):\n",
238
+ "\n",
239
+ " if hasattr(self, \"slider_ctrl\") and self.slider_ctrl is not None:\n",
240
+ " self.remove(self.slider_ctrl)\n",
241
+ " delattr(self, \"slider_ctrl\")\n",
242
+ "\n",
243
+ " with output:\n",
244
+ " output.clear_output()\n",
245
+ " if self.user_roi is None:\n",
246
+ " output.append_stdout(\"Please draw a ROI first.\")\n",
247
+ " else:\n",
248
+ " output.append_stdout(\"Creating time series...\")\n",
249
+ " collection = geemap.landsat_timeseries(\n",
250
+ " roi=self.user_roi,\n",
251
+ " start_year=start_year.value,\n",
252
+ " end_year=end_year.value,\n",
253
+ " start_date=str(start_month.value).zfill(2) + \"-01\",\n",
254
+ " end_date=str(end_month.value).zfill(2) + \"-01\",\n",
255
+ " frequency=frequency.value,\n",
256
+ " )\n",
257
+ " vis_params = {\n",
258
+ " \"bands\": bands.value.split(\"/\"),\n",
259
+ " \"min\": 0,\n",
260
+ " \"max\": 0.4,\n",
261
+ " }\n",
262
+ "\n",
263
+ " if frequency.value == \"year\":\n",
264
+ " date_format = \"YYYY\"\n",
265
+ " dates = geemap.image_dates(collection, date_format).getInfo()\n",
266
+ " elif frequency.value == \"quarter\":\n",
267
+ " date_format = \"YYYY-MM\"\n",
268
+ " dates = geemap.image_dates(collection, date_format).getInfo()\n",
269
+ " elif frequency.value == \"month\":\n",
270
+ " date_format = \"YYYY-MM\"\n",
271
+ " dates = geemap.image_dates(collection, date_format).getInfo()\n",
272
+ "\n",
273
+ " self.ts_inspector(\n",
274
+ " collection,\n",
275
+ " left_names=dates,\n",
276
+ " left_vis=vis_params,\n",
277
+ " add_close_button=True,\n",
278
+ " )\n",
279
+ " output.clear_output()\n",
280
+ "\n",
281
+ " try:\n",
282
+ " self._draw_control.clear()\n",
283
+ " draw_layer = self.find_layer(\"Drawn Features\")\n",
284
+ " if draw_layer is not None:\n",
285
+ " self.remove(draw_layer)\n",
286
+ " except Exception as e:\n",
287
+ " print(e)\n",
288
+ "\n",
289
+ " split_btn.on_click(split_btn_click)\n",
290
+ "\n",
291
+ " def reset_btn_click(change):\n",
292
+ " output.clear_output()\n",
293
+ " self.clean_up()\n",
294
+ "\n",
295
+ " reset_btn.on_click(reset_btn_click)\n",
296
+ "\n",
297
+ "\n",
298
+ "@solara.component\n",
299
+ "def Page():\n",
300
+ " with solara.Column(style={\"min-width\": \"500px\"}):\n",
301
+ " Map.element(\n",
302
+ " center=[20, -0],\n",
303
+ " zoom=2,\n",
304
+ " height=\"750px\",\n",
305
+ " zoom_ctrl=False,\n",
306
+ " measure_ctrl=False,\n",
307
+ " )"
308
+ ]
309
+ },
310
+ {
311
+ "cell_type": "code",
312
+ "execution_count": null,
313
+ "metadata": {},
314
+ "outputs": [],
315
+ "source": [
316
+ "Page()"
317
+ ]
318
+ },
319
+ {
320
+ "cell_type": "code",
321
+ "execution_count": null,
322
+ "metadata": {},
323
+ "outputs": [],
324
+ "source": []
325
+ }
326
+ ],
327
+ "metadata": {
328
+ "kernelspec": {
329
+ "display_name": "geo",
330
+ "language": "python",
331
+ "name": "python3"
332
+ },
333
+ "language_info": {
334
+ "codemirror_mode": {
335
+ "name": "ipython",
336
+ "version": 3
337
+ },
338
+ "file_extension": ".py",
339
+ "mimetype": "text/x-python",
340
+ "name": "python",
341
+ "nbconvert_exporter": "python",
342
+ "pygments_lexer": "ipython3",
343
+ "version": "3.11.8"
344
+ }
345
+ },
346
+ "nbformat": 4,
347
+ "nbformat_minor": 2
348
+ }
notebooks/07_jrc.ipynb ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/07_jrc.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import ee\n",
26
+ "import geemap\n",
27
+ "import ipywidgets as widgets\n",
28
+ "from IPython.display import display\n",
29
+ "import solara\n",
30
+ "\n",
31
+ "\n",
32
+ "class Map(geemap.Map):\n",
33
+ " def __init__(self, **kwargs):\n",
34
+ " super().__init__(**kwargs)\n",
35
+ " self.add_basemap(\"Esri.WorldImagery\")\n",
36
+ " self.add_ee_data()\n",
37
+ " self.add_buttons(add_header=True)\n",
38
+ "\n",
39
+ " def add_ee_data(self):\n",
40
+ "\n",
41
+ " dataset = ee.Image(\"JRC/GSW1_4/GlobalSurfaceWater\")\n",
42
+ " image = dataset.select([\"occurrence\"])\n",
43
+ " vis_params = {\n",
44
+ " \"min\": 0.0,\n",
45
+ " \"max\": 100.0,\n",
46
+ " \"palette\": [\"ffffff\", \"ffbbbb\", \"0000ff\"],\n",
47
+ " }\n",
48
+ " self.addLayer(image, vis_params, \"Occurrence\")\n",
49
+ " self.add_colorbar(\n",
50
+ " vis_params, label=\"Water occurrence (%)\", layer_name=\"Occurrence\"\n",
51
+ " )\n",
52
+ "\n",
53
+ " def add_buttons(self, position=\"topright\", **kwargs):\n",
54
+ " padding = \"0px 5px 0px 5px\"\n",
55
+ " widget = widgets.VBox(layout=widgets.Layout(padding=padding))\n",
56
+ " layout = widgets.Layout(width=\"auto\")\n",
57
+ " style = {\"description_width\": \"initial\"}\n",
58
+ " hist_btn = widgets.Button(description=\"Occurrence\", layout=layout)\n",
59
+ " bar_btn = widgets.Button(description=\"Monthly history\", layout=layout)\n",
60
+ " reset_btn = widgets.Button(description=\"Reset\", layout=layout)\n",
61
+ " scale = widgets.IntSlider(\n",
62
+ " min=30, max=1000, value=90, description=\"Scale\", layout=layout, style=style\n",
63
+ " )\n",
64
+ " month_slider = widgets.IntRangeSlider(\n",
65
+ " description=\"Months\",\n",
66
+ " value=[5, 10],\n",
67
+ " min=1,\n",
68
+ " max=12,\n",
69
+ " step=1,\n",
70
+ " layout=layout,\n",
71
+ " style=style,\n",
72
+ " )\n",
73
+ " widget.children = [\n",
74
+ " widgets.HBox([hist_btn, bar_btn, reset_btn]),\n",
75
+ " month_slider,\n",
76
+ " scale,\n",
77
+ " ]\n",
78
+ " self.add_widget(widget, position=position, **kwargs)\n",
79
+ " output = widgets.Output()\n",
80
+ " self.add_widget(output, position=\"bottomleft\", add_header=False)\n",
81
+ "\n",
82
+ " def hist_btn_click(b):\n",
83
+ " region = self.user_roi\n",
84
+ " if region is not None:\n",
85
+ " output.clear_output()\n",
86
+ " output.append_stdout(\"Computing histogram...\")\n",
87
+ " image = ee.Image(\"JRC/GSW1_4/GlobalSurfaceWater\").select([\"occurrence\"])\n",
88
+ " self.default_style = {\"cursor\": \"wait\"}\n",
89
+ " hist = geemap.image_histogram(\n",
90
+ " image,\n",
91
+ " region,\n",
92
+ " scale=scale.value,\n",
93
+ " height=350,\n",
94
+ " width=550,\n",
95
+ " x_label=\"Water Occurrence (%)\",\n",
96
+ " y_label=\"Pixel Count\",\n",
97
+ " layout_args={\n",
98
+ " \"title\": dict(x=0.5),\n",
99
+ " \"margin\": dict(l=0, r=0, t=10, b=0),\n",
100
+ " },\n",
101
+ " return_df=False,\n",
102
+ " )\n",
103
+ "\n",
104
+ " with output:\n",
105
+ " output.clear_output()\n",
106
+ " display(hist)\n",
107
+ " self.default_style = {\"cursor\": \"default\"}\n",
108
+ " else:\n",
109
+ " output.clear_output()\n",
110
+ " with output:\n",
111
+ " output.append_stdout(\"Please draw a region of interest first.\")\n",
112
+ "\n",
113
+ " hist_btn.on_click(hist_btn_click)\n",
114
+ "\n",
115
+ " def bar_btn_click(b):\n",
116
+ " region = self.user_roi\n",
117
+ " if region is not None:\n",
118
+ " self.default_style = {\"cursor\": \"wait\"}\n",
119
+ " output.clear_output()\n",
120
+ " output.append_stdout(\"Computing monthly history...\")\n",
121
+ " bar = geemap.jrc_hist_monthly_history(\n",
122
+ " region=region,\n",
123
+ " scale=scale.value,\n",
124
+ " height=350,\n",
125
+ " width=550,\n",
126
+ " layout_args={\n",
127
+ " \"title\": dict(x=0.5),\n",
128
+ " \"margin\": dict(l=0, r=0, t=10, b=0),\n",
129
+ " },\n",
130
+ " frequency=\"month\",\n",
131
+ " start_month=month_slider.value[0],\n",
132
+ " end_month=month_slider.value[1],\n",
133
+ " denominator=1e4,\n",
134
+ " y_label=\"Area (ha)\",\n",
135
+ " )\n",
136
+ "\n",
137
+ " with output:\n",
138
+ " output.clear_output()\n",
139
+ " display(bar)\n",
140
+ " self.default_style = {\"cursor\": \"default\"}\n",
141
+ " else:\n",
142
+ " output.clear_output()\n",
143
+ " with output:\n",
144
+ " output.append_stdout(\"Please draw a region of interest first.\")\n",
145
+ "\n",
146
+ " bar_btn.on_click(bar_btn_click)\n",
147
+ "\n",
148
+ " def reset_btn_click(b):\n",
149
+ " self._draw_control.clear()\n",
150
+ " output.clear_output()\n",
151
+ "\n",
152
+ " reset_btn.on_click(reset_btn_click)\n",
153
+ "\n",
154
+ "\n",
155
+ "@solara.component\n",
156
+ "def Page():\n",
157
+ " with solara.Column(style={\"min-width\": \"500px\"}):\n",
158
+ " Map.element(\n",
159
+ " center=[20, -0],\n",
160
+ " zoom=2,\n",
161
+ " height=\"750px\",\n",
162
+ " zoom_ctrl=False,\n",
163
+ " measure_ctrl=False,\n",
164
+ " )"
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": null,
170
+ "metadata": {},
171
+ "outputs": [],
172
+ "source": [
173
+ "Page()"
174
+ ]
175
+ },
176
+ {
177
+ "cell_type": "code",
178
+ "execution_count": null,
179
+ "metadata": {},
180
+ "outputs": [],
181
+ "source": []
182
+ }
183
+ ],
184
+ "metadata": {
185
+ "kernelspec": {
186
+ "display_name": "geo",
187
+ "language": "python",
188
+ "name": "python3"
189
+ },
190
+ "language_info": {
191
+ "codemirror_mode": {
192
+ "name": "ipython",
193
+ "version": 3
194
+ },
195
+ "file_extension": ".py",
196
+ "mimetype": "text/x-python",
197
+ "name": "python",
198
+ "nbconvert_exporter": "python",
199
+ "pygments_lexer": "ipython3",
200
+ "version": "3.11.8"
201
+ }
202
+ },
203
+ "nbformat": 4,
204
+ "nbformat_minor": 2
205
+ }
notebooks/08_compare.ipynb ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/solara-geemap/blob/main/notebooks/08_compare.ipynb)"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": null,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "# %pip install -U geemap solara"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "metadata": {},
23
+ "outputs": [],
24
+ "source": [
25
+ "import ee\n",
26
+ "import geemap\n",
27
+ "import ipywidgets as widgets\n",
28
+ "import solara\n",
29
+ "from datetime import date\n",
30
+ "\n",
31
+ "\n",
32
+ "class Map(geemap.Map):\n",
33
+ " def __init__(self, **kwargs):\n",
34
+ " super().__init__(**kwargs)\n",
35
+ " self.add_basemap(\"Esri.WorldImagery\")\n",
36
+ " self.add_gui_widget(add_header=True)\n",
37
+ "\n",
38
+ " def clean_up(self):\n",
39
+ "\n",
40
+ " layers = [\n",
41
+ " \"Pre-event Image\",\n",
42
+ " \"Post-event Image\",\n",
43
+ " \"Pre-event NDWI\",\n",
44
+ " \"Post-event NDWI\",\n",
45
+ " \"Pre-event Water\",\n",
46
+ " \"Post-event Water\",\n",
47
+ " \"Disappeared Water\",\n",
48
+ " \"New Water\",\n",
49
+ " ]\n",
50
+ " for layer_name in layers:\n",
51
+ " layer = self.find_layer(layer_name)\n",
52
+ " if layer is not None:\n",
53
+ " self.remove(layer)\n",
54
+ "\n",
55
+ " def add_gui_widget(self, position=\"topright\", **kwargs):\n",
56
+ "\n",
57
+ " widget = widgets.VBox(layout=widgets.Layout(padding=\"0px 5px 0px 5px\"))\n",
58
+ " pre_widget = widgets.HBox()\n",
59
+ " post_widget = widgets.HBox()\n",
60
+ " layout = widgets.Layout(width=\"auto\")\n",
61
+ " style = {\"description_width\": \"initial\"}\n",
62
+ " padding = \"0px 5px 0px 5px\"\n",
63
+ " pre_start_date = widgets.DatePicker(\n",
64
+ " description=\"Start\",\n",
65
+ " value=date(2014, 1, 1),\n",
66
+ " style=style,\n",
67
+ " layout=widgets.Layout(padding=padding, width=\"160px\"),\n",
68
+ " )\n",
69
+ " pre_end_date = widgets.DatePicker(\n",
70
+ " description=\"End\",\n",
71
+ " value=date(2014, 12, 31),\n",
72
+ " style=style,\n",
73
+ " layout=widgets.Layout(padding=padding, width=\"160px\"),\n",
74
+ " )\n",
75
+ " pre_cloud_cover = widgets.IntSlider(\n",
76
+ " description=\"Cloud\",\n",
77
+ " min=0,\n",
78
+ " max=100,\n",
79
+ " value=25,\n",
80
+ " step=1,\n",
81
+ " readout=False,\n",
82
+ " style=style,\n",
83
+ " layout=widgets.Layout(padding=padding, width=\"130px\"),\n",
84
+ " )\n",
85
+ " pre_cloud_label = widgets.Label(value=str(pre_cloud_cover.value))\n",
86
+ " geemap.jslink_slider_label(pre_cloud_cover, pre_cloud_label)\n",
87
+ " pre_widget.children = [\n",
88
+ " pre_start_date,\n",
89
+ " pre_end_date,\n",
90
+ " pre_cloud_cover,\n",
91
+ " pre_cloud_label,\n",
92
+ " ]\n",
93
+ " post_start_date = widgets.DatePicker(\n",
94
+ " description=\"Start\",\n",
95
+ " value=date(2024, 1, 1),\n",
96
+ " style=style,\n",
97
+ " layout=widgets.Layout(padding=padding, width=\"160px\"),\n",
98
+ " )\n",
99
+ " post_end_date = widgets.DatePicker(\n",
100
+ " description=\"End\",\n",
101
+ " value=date(2024, 12, 31),\n",
102
+ " style=style,\n",
103
+ " layout=widgets.Layout(padding=padding, width=\"160px\"),\n",
104
+ " )\n",
105
+ " post_cloud_cover = widgets.IntSlider(\n",
106
+ " description=\"Cloud\",\n",
107
+ " min=0,\n",
108
+ " max=100,\n",
109
+ " value=30,\n",
110
+ " step=1,\n",
111
+ " readout=False,\n",
112
+ " style=style,\n",
113
+ " layout=widgets.Layout(padding=padding, width=\"130px\"),\n",
114
+ " )\n",
115
+ " post_cloud_label = widgets.Label(value=str(post_cloud_cover.value))\n",
116
+ " geemap.jslink_slider_label(post_cloud_cover, post_cloud_label)\n",
117
+ " post_widget.children = [\n",
118
+ " post_start_date,\n",
119
+ " post_end_date,\n",
120
+ " post_cloud_cover,\n",
121
+ " post_cloud_label,\n",
122
+ " ]\n",
123
+ "\n",
124
+ " apply_btn = widgets.Button(description=\"Apply\", layout=layout)\n",
125
+ " reset_btn = widgets.Button(description=\"Reset\", layout=layout)\n",
126
+ " buttons = widgets.HBox([apply_btn, reset_btn])\n",
127
+ " output = widgets.Output()\n",
128
+ "\n",
129
+ " use_split = widgets.Checkbox(\n",
130
+ " value=False,\n",
131
+ " description=\"Split map\",\n",
132
+ " style=style,\n",
133
+ " layout=widgets.Layout(padding=padding, width=\"100px\"),\n",
134
+ " )\n",
135
+ "\n",
136
+ " use_ndwi = widgets.Checkbox(\n",
137
+ " value=False,\n",
138
+ " description=\"Compute NDWI\",\n",
139
+ " style=style,\n",
140
+ " layout=widgets.Layout(padding=padding, width=\"160px\"),\n",
141
+ " )\n",
142
+ "\n",
143
+ " ndwi_threhold = widgets.FloatSlider(\n",
144
+ " description=\"Threshold\",\n",
145
+ " min=-1,\n",
146
+ " max=1,\n",
147
+ " value=0,\n",
148
+ " step=0.05,\n",
149
+ " readout=True,\n",
150
+ " style=style,\n",
151
+ " layout=widgets.Layout(padding=padding, width=\"230px\"),\n",
152
+ " )\n",
153
+ "\n",
154
+ " options = widgets.HBox(\n",
155
+ " [\n",
156
+ " use_split,\n",
157
+ " use_ndwi,\n",
158
+ " ndwi_threhold,\n",
159
+ " ]\n",
160
+ " )\n",
161
+ "\n",
162
+ " widget.children = [pre_widget, post_widget, options, buttons, output]\n",
163
+ " self.add_widget(widget, position=position, **kwargs)\n",
164
+ "\n",
165
+ " def apply_btn_click(b):\n",
166
+ "\n",
167
+ " marker_layer = self.find_layer(\"Search location\")\n",
168
+ " if marker_layer is not None:\n",
169
+ " self.remove(marker_layer)\n",
170
+ " self.clean_up()\n",
171
+ "\n",
172
+ " if self.user_roi is None:\n",
173
+ " output.clear_output()\n",
174
+ " output.append_stdout(\"Please draw a ROI first.\")\n",
175
+ " elif (\n",
176
+ " pre_start_date.value is None\n",
177
+ " or pre_end_date.value is None\n",
178
+ " or post_start_date.value is None\n",
179
+ " or post_end_date.value is None\n",
180
+ " ):\n",
181
+ " output.clear_output()\n",
182
+ " output.append_stdout(\"Please select start and end dates.\")\n",
183
+ "\n",
184
+ " elif self.user_roi is not None:\n",
185
+ " output.clear_output()\n",
186
+ " output.append_stdout(\"Computing... Please wait.\")\n",
187
+ " roi = ee.FeatureCollection(self.user_roi)\n",
188
+ " vis_params = {\"bands\": [\"B6\", \"B5\", \"B4\"], \"min\": 0, \"max\": 0.4}\n",
189
+ " if pre_start_date.value.strftime(\"%Y-%m-%d\") < \"2013-04-11\":\n",
190
+ " pre_col = geemap.landsat_timeseries(\n",
191
+ " roi,\n",
192
+ " start_year=pre_start_date.value.year,\n",
193
+ " end_year=pre_end_date.value.year,\n",
194
+ " ).select([\"SWIR1\", \"NIR\", \"Red\", \"Green\"], [\"B6\", \"B5\", \"B4\", \"B3\"])\n",
195
+ " else:\n",
196
+ " pre_col = (\n",
197
+ " ee.ImageCollection(\"NASA/HLS/HLSL30/v002\")\n",
198
+ " .filterBounds(roi)\n",
199
+ " .filterDate(\n",
200
+ " pre_start_date.value.strftime(\"%Y-%m-%d\"),\n",
201
+ " pre_end_date.value.strftime(\"%Y-%m-%d\"),\n",
202
+ " )\n",
203
+ " .filter(ee.Filter.lt(\"CLOUD_COVERAGE\", pre_cloud_cover.value))\n",
204
+ " )\n",
205
+ "\n",
206
+ " if post_start_date.value.strftime(\"%Y-%m-%d\") < \"2013-04-11\":\n",
207
+ " post_col = geemap.landsat_timeseries(\n",
208
+ " roi,\n",
209
+ " start_year=post_start_date.value.year,\n",
210
+ " end_year=post_end_date.value.year,\n",
211
+ " ).select([\"SWIR1\", \"NIR\", \"Red\", \"Green\"], [\"B6\", \"B5\", \"B4\", \"B3\"])\n",
212
+ " else:\n",
213
+ " post_col = (\n",
214
+ " ee.ImageCollection(\"NASA/HLS/HLSL30/v002\")\n",
215
+ " .filterBounds(roi)\n",
216
+ " .filterDate(\n",
217
+ " post_start_date.value.strftime(\"%Y-%m-%d\"),\n",
218
+ " post_end_date.value.strftime(\"%Y-%m-%d\"),\n",
219
+ " )\n",
220
+ " .filter(ee.Filter.lt(\"CLOUD_COVERAGE\", post_cloud_cover.value))\n",
221
+ " )\n",
222
+ "\n",
223
+ " pre_img = pre_col.median().clip(roi)\n",
224
+ " post_img = post_col.median().clip(roi)\n",
225
+ "\n",
226
+ " if use_split.value:\n",
227
+ " left_layer = geemap.ee_tile_layer(\n",
228
+ " pre_img, vis_params, \"Pre-event Image\"\n",
229
+ " )\n",
230
+ " right_layer = geemap.ee_tile_layer(\n",
231
+ " post_img, vis_params, \"Post-event Image\"\n",
232
+ " )\n",
233
+ " self.split_map(\n",
234
+ " left_layer,\n",
235
+ " right_layer,\n",
236
+ " add_close_button=True,\n",
237
+ " left_label=\"Pre-event\",\n",
238
+ " right_label=\"Post-event\",\n",
239
+ " )\n",
240
+ " else:\n",
241
+ " pre_img = pre_col.median().clip(roi)\n",
242
+ " post_img = post_col.median().clip(roi)\n",
243
+ " self.add_layer(pre_img, vis_params, \"Pre-event Image\")\n",
244
+ " self.add_layer(post_img, vis_params, \"Post-event Image\")\n",
245
+ "\n",
246
+ " if use_ndwi.value and (not use_split.value):\n",
247
+ " pre_ndwi = pre_img.normalizedDifference([\"B3\", \"B6\"]).rename(\"NDWI\")\n",
248
+ " post_ndwi = post_img.normalizedDifference([\"B3\", \"B6\"]).rename(\n",
249
+ " \"NDWI\"\n",
250
+ " )\n",
251
+ " ndwi_vis = {\"min\": -1, \"max\": 1, \"palette\": \"ndwi\"}\n",
252
+ " self.add_layer(pre_ndwi, ndwi_vis, \"Pre-event NDWI\", False)\n",
253
+ " self.add_layer(post_ndwi, ndwi_vis, \"Post-event NDWI\", False)\n",
254
+ "\n",
255
+ " pre_water = pre_ndwi.gt(ndwi_threhold.value)\n",
256
+ " post_water = post_ndwi.gt(ndwi_threhold.value)\n",
257
+ " self.add_layer(\n",
258
+ " pre_water.selfMask(), {\"palette\": \"blue\"}, \"Pre-event Water\"\n",
259
+ " )\n",
260
+ " self.add_layer(\n",
261
+ " post_water.selfMask(), {\"palette\": \"red\"}, \"Post-event Water\"\n",
262
+ " )\n",
263
+ " new_water = post_water.subtract(pre_water).gt(0)\n",
264
+ " disappear_water = pre_water.subtract(post_water).gt(0)\n",
265
+ " self.add_layer(\n",
266
+ " disappear_water.selfMask(),\n",
267
+ " {\"palette\": \"brown\"},\n",
268
+ " \"Disappeared Water\",\n",
269
+ " )\n",
270
+ " self.add_layer(\n",
271
+ " new_water.selfMask(), {\"palette\": \"cyan\"}, \"New Water\"\n",
272
+ " )\n",
273
+ "\n",
274
+ " with output:\n",
275
+ " output.clear_output()\n",
276
+ "\n",
277
+ " output.clear_output()\n",
278
+ "\n",
279
+ " apply_btn.on_click(apply_btn_click)\n",
280
+ "\n",
281
+ " def reset_btn_click(b):\n",
282
+ " self.clean_up()\n",
283
+ " self._draw_control.clear()\n",
284
+ " draw_layer = self.find_layer(\"Drawn Features\")\n",
285
+ " if draw_layer is not None:\n",
286
+ " self.remove(draw_layer)\n",
287
+ " output.clear_output()\n",
288
+ "\n",
289
+ " reset_btn.on_click(reset_btn_click)\n",
290
+ "\n",
291
+ "\n",
292
+ "@solara.component\n",
293
+ "def Page():\n",
294
+ " with solara.Column(style={\"min-width\": \"500px\"}):\n",
295
+ " Map.element(\n",
296
+ " center=[20, -0],\n",
297
+ " zoom=2,\n",
298
+ " height=\"750px\",\n",
299
+ " zoom_ctrl=False,\n",
300
+ " measure_ctrl=False,\n",
301
+ " )"
302
+ ]
303
+ },
304
+ {
305
+ "cell_type": "code",
306
+ "execution_count": null,
307
+ "metadata": {},
308
+ "outputs": [],
309
+ "source": [
310
+ "Page()"
311
+ ]
312
+ }
313
+ ],
314
+ "metadata": {
315
+ "kernelspec": {
316
+ "display_name": "geo",
317
+ "language": "python",
318
+ "name": "python3"
319
+ },
320
+ "language_info": {
321
+ "codemirror_mode": {
322
+ "name": "ipython",
323
+ "version": 3
324
+ },
325
+ "file_extension": ".py",
326
+ "mimetype": "text/x-python",
327
+ "name": "python",
328
+ "nbconvert_exporter": "python",
329
+ "pygments_lexer": "ipython3",
330
+ "version": "3.11.8"
331
+ }
332
+ },
333
+ "nbformat": 4,
334
+ "nbformat_minor": 2
335
+ }
notebooks/09_teste.ipynb ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 11,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/html": [
11
+ "\n",
12
+ " <style>\n",
13
+ " .geemap-dark {\n",
14
+ " --jp-widgets-color: white;\n",
15
+ " --jp-widgets-label-color: white;\n",
16
+ " --jp-ui-font-color1: white;\n",
17
+ " --jp-layout-color2: #454545;\n",
18
+ " background-color: #383838;\n",
19
+ " }\n",
20
+ "\n",
21
+ " .geemap-dark .jupyter-button {\n",
22
+ " --jp-layout-color3: #383838;\n",
23
+ " }\n",
24
+ "\n",
25
+ " .geemap-colab {\n",
26
+ " background-color: var(--colab-primary-surface-color, white);\n",
27
+ " }\n",
28
+ "\n",
29
+ " .geemap-colab .jupyter-button {\n",
30
+ " --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
31
+ " }\n",
32
+ " </style>\n",
33
+ " "
34
+ ],
35
+ "text/plain": [
36
+ "<IPython.core.display.HTML object>"
37
+ ]
38
+ },
39
+ "metadata": {},
40
+ "output_type": "display_data"
41
+ }
42
+ ],
43
+ "source": [
44
+ "import geemap\n",
45
+ "import ee\n",
46
+ "import plotly.express as px"
47
+ ]
48
+ },
49
+ {
50
+ "cell_type": "code",
51
+ "execution_count": 3,
52
+ "metadata": {},
53
+ "outputs": [
54
+ {
55
+ "data": {
56
+ "text/html": [
57
+ "\n",
58
+ " <style>\n",
59
+ " .geemap-dark {\n",
60
+ " --jp-widgets-color: white;\n",
61
+ " --jp-widgets-label-color: white;\n",
62
+ " --jp-ui-font-color1: white;\n",
63
+ " --jp-layout-color2: #454545;\n",
64
+ " background-color: #383838;\n",
65
+ " }\n",
66
+ "\n",
67
+ " .geemap-dark .jupyter-button {\n",
68
+ " --jp-layout-color3: #383838;\n",
69
+ " }\n",
70
+ "\n",
71
+ " .geemap-colab {\n",
72
+ " background-color: var(--colab-primary-surface-color, white);\n",
73
+ " }\n",
74
+ "\n",
75
+ " .geemap-colab .jupyter-button {\n",
76
+ " --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
77
+ " }\n",
78
+ " </style>\n",
79
+ " "
80
+ ],
81
+ "text/plain": [
82
+ "<IPython.core.display.HTML object>"
83
+ ]
84
+ },
85
+ "metadata": {},
86
+ "output_type": "display_data"
87
+ }
88
+ ],
89
+ "source": [
90
+ "geemap.ee_initialize()"
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "execution_count": 6,
96
+ "metadata": {},
97
+ "outputs": [
98
+ {
99
+ "data": {
100
+ "text/html": [
101
+ "\n",
102
+ " <style>\n",
103
+ " .geemap-dark {\n",
104
+ " --jp-widgets-color: white;\n",
105
+ " --jp-widgets-label-color: white;\n",
106
+ " --jp-ui-font-color1: white;\n",
107
+ " --jp-layout-color2: #454545;\n",
108
+ " background-color: #383838;\n",
109
+ " }\n",
110
+ "\n",
111
+ " .geemap-dark .jupyter-button {\n",
112
+ " --jp-layout-color3: #383838;\n",
113
+ " }\n",
114
+ "\n",
115
+ " .geemap-colab {\n",
116
+ " background-color: var(--colab-primary-surface-color, white);\n",
117
+ " }\n",
118
+ "\n",
119
+ " .geemap-colab .jupyter-button {\n",
120
+ " --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
121
+ " }\n",
122
+ " </style>\n",
123
+ " "
124
+ ],
125
+ "text/plain": [
126
+ "<IPython.core.display.HTML object>"
127
+ ]
128
+ },
129
+ "metadata": {},
130
+ "output_type": "display_data"
131
+ }
132
+ ],
133
+ "source": [
134
+ "esa = ee.ImageCollection('ESA/WorldCover/v200').first()\n",
135
+ "\n",
136
+ "ucs = ee.FeatureCollection(\"projects/ee-curso-gee-rhamon/assets/ucs_estaduais_rj\")\n",
137
+ "\n",
138
+ " \n",
139
+ "esa = esa.clipToCollection(ucs)"
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": 7,
145
+ "metadata": {},
146
+ "outputs": [
147
+ {
148
+ "data": {
149
+ "text/html": [
150
+ "\n",
151
+ " <style>\n",
152
+ " .geemap-dark {\n",
153
+ " --jp-widgets-color: white;\n",
154
+ " --jp-widgets-label-color: white;\n",
155
+ " --jp-ui-font-color1: white;\n",
156
+ " --jp-layout-color2: #454545;\n",
157
+ " background-color: #383838;\n",
158
+ " }\n",
159
+ "\n",
160
+ " .geemap-dark .jupyter-button {\n",
161
+ " --jp-layout-color3: #383838;\n",
162
+ " }\n",
163
+ "\n",
164
+ " .geemap-colab {\n",
165
+ " background-color: var(--colab-primary-surface-color, white);\n",
166
+ " }\n",
167
+ "\n",
168
+ " .geemap-colab .jupyter-button {\n",
169
+ " --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
170
+ " }\n",
171
+ " </style>\n",
172
+ " "
173
+ ],
174
+ "text/plain": [
175
+ "<IPython.core.display.HTML object>"
176
+ ]
177
+ },
178
+ "metadata": {},
179
+ "output_type": "display_data"
180
+ },
181
+ {
182
+ "name": "stdout",
183
+ "output_type": "stream",
184
+ "text": [
185
+ "Computing ... \n",
186
+ "Generating URL ...\n",
187
+ "Downloading data from https://earthengine.googleapis.com/v1/projects/346107197273/tables/60f4e2523a74ad9da945ec21ae745a37-75ffe80c0d13be48ca8789157bb6c245:getFeatures\n",
188
+ "Please wait ...\n",
189
+ "Data downloaded to c:\\Users\\Rhamon\\Desktop\\Solara\\solara-geemap\\notebooks\\esa_stats_ucs_rj.csv\n"
190
+ ]
191
+ }
192
+ ],
193
+ "source": [
194
+ "esa_stats = 'esa_stats_ucs_rj.csv'\n",
195
+ "\n",
196
+ "geemap.zonal_stats_by_group(\n",
197
+ " esa,\n",
198
+ " ucs,\n",
199
+ " esa_stats,\n",
200
+ " statistics_type='PERCENTAGE',\n",
201
+ " denominator=1e6,\n",
202
+ " decimal_places=2,\n",
203
+ ")"
204
+ ]
205
+ },
206
+ {
207
+ "cell_type": "code",
208
+ "execution_count": 9,
209
+ "metadata": {},
210
+ "outputs": [
211
+ {
212
+ "name": "stderr",
213
+ "output_type": "stream",
214
+ "text": [
215
+ "<>:1: SyntaxWarning: invalid escape sequence '\\e'\n",
216
+ "<>:1: SyntaxWarning: invalid escape sequence '\\e'\n"
217
+ ]
218
+ },
219
+ {
220
+ "data": {
221
+ "text/html": [
222
+ "\n",
223
+ " <style>\n",
224
+ " .geemap-dark {\n",
225
+ " --jp-widgets-color: white;\n",
226
+ " --jp-widgets-label-color: white;\n",
227
+ " --jp-ui-font-color1: white;\n",
228
+ " --jp-layout-color2: #454545;\n",
229
+ " background-color: #383838;\n",
230
+ " }\n",
231
+ "\n",
232
+ " .geemap-dark .jupyter-button {\n",
233
+ " --jp-layout-color3: #383838;\n",
234
+ " }\n",
235
+ "\n",
236
+ " .geemap-colab {\n",
237
+ " background-color: var(--colab-primary-surface-color, white);\n",
238
+ " }\n",
239
+ "\n",
240
+ " .geemap-colab .jupyter-button {\n",
241
+ " --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
242
+ " }\n",
243
+ " </style>\n",
244
+ " "
245
+ ],
246
+ "text/plain": [
247
+ "<IPython.core.display.HTML object>"
248
+ ]
249
+ },
250
+ "metadata": {},
251
+ "output_type": "display_data"
252
+ },
253
+ {
254
+ "name": "stderr",
255
+ "output_type": "stream",
256
+ "text": [
257
+ "C:\\Users\\Rhamon\\AppData\\Local\\Temp\\ipykernel_21848\\2857369937.py:1: SyntaxWarning: invalid escape sequence '\\e'\n",
258
+ " df = 'CSVs\\esa_stats_ucs_rj.csv'\n"
259
+ ]
260
+ }
261
+ ],
262
+ "source": [
263
+ "df = 'CSVs\\esa_stats_ucs_rj.csv'"
264
+ ]
265
+ },
266
+ {
267
+ "cell_type": "code",
268
+ "execution_count": 13,
269
+ "metadata": {},
270
+ "outputs": [
271
+ {
272
+ "data": {
273
+ "text/html": [
274
+ "\n",
275
+ " <style>\n",
276
+ " .geemap-dark {\n",
277
+ " --jp-widgets-color: white;\n",
278
+ " --jp-widgets-label-color: white;\n",
279
+ " --jp-ui-font-color1: white;\n",
280
+ " --jp-layout-color2: #454545;\n",
281
+ " background-color: #383838;\n",
282
+ " }\n",
283
+ "\n",
284
+ " .geemap-dark .jupyter-button {\n",
285
+ " --jp-layout-color3: #383838;\n",
286
+ " }\n",
287
+ "\n",
288
+ " .geemap-colab {\n",
289
+ " background-color: var(--colab-primary-surface-color, white);\n",
290
+ " }\n",
291
+ "\n",
292
+ " .geemap-colab .jupyter-button {\n",
293
+ " --jp-layout-color3: var(--colab-primary-surface-color, white);\n",
294
+ " }\n",
295
+ " </style>\n",
296
+ " "
297
+ ],
298
+ "text/plain": [
299
+ "<IPython.core.display.HTML object>"
300
+ ]
301
+ },
302
+ "metadata": {},
303
+ "output_type": "display_data"
304
+ },
305
+ {
306
+ "ename": "ValueError",
307
+ "evalue": "DataFrame constructor not properly called!",
308
+ "output_type": "error",
309
+ "traceback": [
310
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
311
+ "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
312
+ "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_21848\\385931256.py\u001b[0m in \u001b[0;36m?\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mfig\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpie\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'Class_10'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcolor\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"nome\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtitle\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'Cobertura Florestal UCs Estaduais RJ'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mfig\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
313
+ "\u001b[1;32mc:\\Users\\Rhamon\\miniconda3\\envs\\geo\\Lib\\site-packages\\plotly\\express\\_chart_types.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(data_frame, names, values, color, facet_row, facet_col, facet_col_wrap, facet_row_spacing, facet_col_spacing, color_discrete_sequence, color_discrete_map, hover_name, hover_data, custom_data, category_orders, labels, title, template, width, height, opacity, hole)\u001b[0m\n\u001b[0;32m 1478\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mcolor_discrete_sequence\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1479\u001b[0m \u001b[0mlayout_patch\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;34m\"piecolorway\"\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mcolor_discrete_sequence\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1480\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1481\u001b[0m \u001b[0mlayout_patch\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1482\u001b[1;33m return make_figure(\n\u001b[0m\u001b[0;32m 1483\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlocals\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1484\u001b[0m \u001b[0mconstructor\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mgo\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPie\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1485\u001b[0m \u001b[0mtrace_patch\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mshowlegend\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnames\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mhole\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mhole\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
314
+ "\u001b[1;32mc:\\Users\\Rhamon\\miniconda3\\envs\\geo\\Lib\\site-packages\\plotly\\express\\_core.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(args, constructor, trace_patch, layout_patch)\u001b[0m\n\u001b[0;32m 2086\u001b[0m \u001b[0mtrace_patch\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtrace_patch\u001b[0m \u001b[1;32mor\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2087\u001b[0m \u001b[0mlayout_patch\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlayout_patch\u001b[0m \u001b[1;32mor\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2088\u001b[0m \u001b[0mapply_default_cascade\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2089\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2090\u001b[1;33m \u001b[0margs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbuild_dataframe\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconstructor\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2091\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mconstructor\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mgo\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTreemap\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgo\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mSunburst\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mgo\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mIcicle\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"path\"\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2092\u001b[0m \u001b[0margs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mprocess_dataframe_hierarchy\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2093\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mconstructor\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mgo\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPie\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
315
+ "\u001b[1;32mc:\\Users\\Rhamon\\miniconda3\\envs\\geo\\Lib\\site-packages\\plotly\\express\\_core.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(args, constructor)\u001b[0m\n\u001b[0;32m 1344\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"to_pandas_df\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1345\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mto_pandas_df\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1346\u001b[0m \u001b[0mcolumns\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1347\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1348\u001b[1;33m \u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1349\u001b[0m \u001b[0mcolumns\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1350\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mdf_provided\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1351\u001b[0m \u001b[0mcolumns\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"data_frame\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
316
+ "\u001b[1;32mc:\\Users\\Rhamon\\miniconda3\\envs\\geo\\Lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(self, data, index, columns, dtype, copy)\u001b[0m\n\u001b[0;32m 882\u001b[0m \u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 883\u001b[0m \u001b[1;31m# For data is scalar\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 884\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 885\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mcolumns\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 886\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"DataFrame constructor not properly called!\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 887\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 888\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mensure_index\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 889\u001b[0m \u001b[0mcolumns\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mensure_index\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
317
+ "\u001b[1;31mValueError\u001b[0m: DataFrame constructor not properly called!"
318
+ ]
319
+ }
320
+ ],
321
+ "source": []
322
+ },
323
+ {
324
+ "cell_type": "code",
325
+ "execution_count": null,
326
+ "metadata": {},
327
+ "outputs": [],
328
+ "source": []
329
+ }
330
+ ],
331
+ "metadata": {
332
+ "kernelspec": {
333
+ "display_name": "geo",
334
+ "language": "python",
335
+ "name": "python3"
336
+ },
337
+ "language_info": {
338
+ "codemirror_mode": {
339
+ "name": "ipython",
340
+ "version": 3
341
+ },
342
+ "file_extension": ".py",
343
+ "mimetype": "text/x-python",
344
+ "name": "python",
345
+ "nbconvert_exporter": "python",
346
+ "pygments_lexer": "ipython3",
347
+ "version": "3.12.3"
348
+ }
349
+ },
350
+ "nbformat": 4,
351
+ "nbformat_minor": 2
352
+ }
notebooks/esa_stats_ucs_rj2.csv ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Class_60,Class_50,Class_40,Class_95,Class_30,Class_20,Class_10,Class_sum,Class_90,Class_80,num_mapa_1,tipo,categoria,jurisdicao,nome,area_ha,criacao,shape_leng,amortecime,shape_area,plano_mane,num_mapa,rotulo,ogc_fid,escala,system:index
2
+ 0,0,0,0,23.95,0,54.07,78.02,0,0,3.0,PROTECAO INTEGRAL,MONA,ESTADUAL,MONUMENTO NATURAL DA SERRA DA MARIA COMPRIDA,7803.43358398,2023,1.62790463007,N�O,0.00684311649,N�O,40,MONA DA SERRA DA MARIA COMPRIDA,39,1:25.000,00000000000000000026
3
+ 0.06,0.86,0.1,0,38.93,0,57.04,111.28,0,14.29,19.0,PROTECAO INTEGRAL,REVIS,ESTADUAL,REFUGIO DA VIDA SILVESTRE ESTADUAL DO MEDIO PARAIBA,11137.1971838,2016,6.13493591535,N�O,0.00976335248,N�O,21,REVIS MEDIO PARAIBA,2,1:25.000,00000000000000000001
4
+ 0.08,0.03,0,0.45,0.98,0,94.76,99.67000000000002,0.01,3.36,24.0,PROTECAO INTEGRAL,RESEC,ESTADUAL,RESERVA ECOLOGICA ESTADUAL DA JUATINGA,9967.24995917,1992,0.71060414957,N�O,0.0087980555,N�O,4,RESEC DA JUATINGA,19,Sem Info,00000000000000000012
5
+ 0.0,0,0,0,2.93,0,41.05,43.98,0,0,16.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DO MENDANHA,4399.10221912,2013,0.51140355655,N�O,0.00386942761,N�O,20,PE DO MENDANHA,28,1:25.000,0000000000000000001b
6
+ 1.65,0.15,0.04,0,26.1,0,1.85,82.49000000000001,39.14,13.56,9.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA LAGOA DO ACU,8249.12246907,2012,0.83549660297,N�O,0.0072137959,N�O,19,PE DA LAGOA DO ACU,29,Sem info,0000000000000000001c
7
+ 0,0,0,0,10.51,0,44.24,54.75,0,0,2.0,PROTECAO INTEGRAL,MONA,ESTADUAL,MONUMENTO NATURAL DA SERRA DA BELEZA,5476.83546917,2017,1.13386248167,N�O,0.00480016717,N�O,2,MONA SERRA DA BELEZA,36,1:25.000,00000000000000000023
8
+ 0,0.0,0,0,2.61,0,4.14,6.75,0,0,4.0,PROTECAO INTEGRAL,MONA,ESTADUAL,MONUMENTO NATURAL DA SERRA DOS MASCATES,675.057144348,2017,0.18707531907,N�O,5.9145591E-4,N�O,3,MONA SERRA DOS MASCATES,37,1:25.000,00000000000000000024
9
+ 0,0.03,0,0,0.73,0,47.31,48.09,0,0.02,18.0,PROTECAO INTEGRAL,REVIS,ESTADUAL,REFUGIO DA VIDA SILVESTRE ESTADUAL DA SERRA DA ESTRELA,4811.73100649,2017,1.19033062973,SIM,0.00422505577,N�O,23,REVIS SERRA DA ESTRELA,1,1:25.000,00000000000000000000
10
+ 0,0.02,0,0,1.97,0,0.36,2.69,0.21,0.13,20.0,PROTECAO INTEGRAL,REVIS,ESTADUAL,REFUGIO DA VIDA SILVESTRE ESTADUAL LAGOA DA TURFEIRA,269.493133194,2016,0.15745976676,SIM,2.3640802E-4,N�O,22,REVIS LAGOA DA TURFEIRA,18,1:25.000,00000000000000000011
11
+ 0.14,0.0,0,0,0.05,0,32.11,33.11,0.06,0.75,21.0,PROTECAO INTEGRAL,REBIO,ESTADUAL,RESERVA BIOLOGICA ESTADUAL DA PRAIA DO SUL,3311.84134657,2014,0.42874875901,SIM,0.00292054795,N�O,5,REBIO PRAIA DO SUL,20,1:50.000,00000000000000000013
12
+ 0.85,0.18,0,18.4,1.82,0,1.88,33.61,4.37,6.11,23.0,PROTECAO INTEGRAL,REBIO,ESTADUAL,RESERVA BIOLOGICA ESTADUAL DE GUARATIBA,3361.18585618,1974,0.57256120811,SIM,0.00296089188,SIM,6,REBIO DE GUARATIBA,21,1:10.000,00000000000000000014
13
+ 0,0,0,0,5.46,0.01,32.91,38.379999999999995,0,0,22.0,PROTECAO INTEGRAL,REBIO,ESTADUAL,RESERVA BIOLOGICA ESTADUAL DE ARARAS,3837.86536952,1977,0.46092656765,SIM,0.00336699397,SIM,7,REBIO DE ARARAS,22,1:50.000,00000000000000000015
14
+ 0,0.01,0.01,0,21.27,0,629.29,650.5899999999999,0,0.01,17.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DOS TRES PICOS,65080.4867347,2002,9.10823446005,SIM,0.05708718834,SIM,12,PE DOS TRES PICOS,23,1:25.000 ; 1:50.000,00000000000000000016
15
+ 0.08,0.09,0,0,1.55,0,30.19,34.31,0.38,2.02,13.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA SERRA DA TIRIRICA,3433.85726444,1991,1.42936381133,SIM,0.00302301907,SIM,13,PE SERRA DA TIRIRICA,24,1:10.000,00000000000000000017
16
+ 0,0.02,0.01,0,8.02,0,51.45,59.52,0,0.02,12.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA SERRA DA CONCORDIA,5952.58474185,2016,1.45942906837,SIM,0.00521852499,N�O,11,PE SERRA DA CONCORDIA,25,1:25.000,00000000000000000018
17
+ 0,0.0,0.02,0,2.12,0.02,78.25,80.41,0,0,11.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA PEDRA SELADA,8041.49819897,2012,1.66658109283,SIM,0.00704996872,SIM,18,PE DA PEDRA SELADA,26,1:25.000,00000000000000000019
18
+ 0.0,0.1,0,0,10.83,0,113.97,124.91999999999999,0,0.02,10.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA PEDRA BRANCA,12494.2417207,1974,1.8845293254,SIM,0.01100042314,SIM,10,PE DA PEDRA BRANCA,27,Sem Info,0000000000000000001a
19
+ 0,0.02,0,0,0.02,0,0.51,0.55,0,0,15.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DO GRAJAU,54.7290261485,1978,0.05699572081,SIM,4.817604E-5,SIM,14,PE DO GRAJAU,30,Sem Info,0000000000000000001d
20
+ 0,0,0,0,8.76,0,204.47,213.23,0,0,14.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DO DESENGANO,21325.7388368,1970,1.75405439943,SIM,0.01863237605,SIM,16,PE DO DESENGANO,31,Sem info,0000000000000000001e
21
+ 0,0,0,0,12.87,0,364.62,380.73,0,3.24,5.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL CUNHAMBEBE,38076.6666531,2008,4.36267236111,SIM,0.03351297978,SIM,8,PE CUNHAMBEBE,32,Sem info,0000000000000000001f
22
+ 4.26,1.4,0.03,0,22.11,0.04,44.33,98.27000000000001,14.65,11.45,7.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA COSTA DO SOL,9828.61554842,2011,3.29315109101,SIM,0.0086502762,SIM,17,PE DA COSTA DO SOL,33,1:25.000,00000000000000000020
23
+ 0,0.0,0,0,0,0,0.04,0.04,0,0,6.0,PROTECAO INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA CHACRINHA,3.71173380368,1969,0.00787836058,SIM,3.26827E-6,SIM,15,PE DA CHACRINHA,34,Sem Info,00000000000000000021
24
+ 0,0.0,0.51,0,10.26,0,16.53,32.58,4.81,0.47,1.0,PROTECAO INTEGRAL,EEE,ESTADUAL,ESTACAO ECOLOGICA ESTADUAL DE GUAXINDIBA,3259.22390746,2002,0.47132646001,SIM,0.00283886233,SIM,1,EEE DE GUAXINDIBA,35,1:50.000,00000000000000000022
25
+ 0.15,0.05,0,0,0.63,0,118.68,120.89,0.02,1.36,8.0,PROTE��O INTEGRAL,PARQUE,ESTADUAL,PARQUE ESTADUAL DA ILHA GRANDE,12083.7871718,1971,1.47283767448,SIM,0.01066040264,SIM,8,PE DA ILHA GRANDE,40,1:50.000 - IBGE,00000000000000000027
26
+ 0.37,8.45,0.37,0,62.51,0,142.49,221.10999999999999,5.25,1.67,35.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DO ALTO IGUACU,22111.9931221,2013,0.78497409664,N�O SE APLICA,0.01942446261,SIM,36,APA DO ALTO IGUACU,3,1:25.000,00000000000000000002
27
+ 0.04,2.96,2.66,1.57,49.86,0,130.79,194.67,6.49,0.3,25.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DA BACIA DO RIO MACACU,19502.1400409,2002,33.798675024,N�O SE APLICA,0.01711874796,N�O,27,APA DA BACIA DO RIO MACACU,4,Sem Info,00000000000000000003
28
+ 0,0,0.13,0,11.13,0,17.46,28.720000000000002,0,0.0,26.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DA BACIA DOS FRADES,2871.72642178,1990,0.59921403936,N�O SE APLICA,0.0025174733,N�O,31,APA DOS FRADES,5,1:25.000 ; 1:50.000,00000000000000000004
29
+ 0,0.32,0.02,0,25.23,0,324.44,350.01,0,0,29.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DE MACAE DE CIMA,35003.0809078,2001,1.03394504309,N�O SE APLICA,0.03069270346,SIM,30,APA DE MACAE DE CIMA,6,1:50.000,00000000000000000005
30
+ 0.04,0.05,0,0,14.7,0,64.94,79.75,0,0.02,28.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DE GERICINO-MENDANHA,7974.14336908,2005,0.66988583505,N�O SE APLICA,0.00701359206,N�O,25,APA DE GERICINO-MENDANHA,7,Sem Info,00000000000000000006
31
+ 0,0.35,0,0.99,10.44,0,241.09,253.09,0.05,0.17,30.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DE MANGARATIBA,25312.3537777,1987,2.73219986964,N�O SE APLICA,0.02228427968,SIM,24,APA DE MANGARATIBA,8,1:20.000,00000000000000000007
32
+ 1.37,0.36,0,0,2.99,0.01,4.11,9.690000000000001,0.47,0.38,31.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DE MARICA,969.239448931,1984,0.30140385146,N�O SE APLICA,8.5341915E-4,SIM,33,APA DE MARICA,9,Sem info,00000000000000000008
33
+ 0.62,8.76,0.02,0,27.58,0,23.12,91.25,18.32,12.83,32.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DE MASSAMBABA,9124.45193908,2011,0.8822736963,N�O SE APLICA,0.00803179984,SIM,32,APA DE MASSAMBABA,10,1:50.000,00000000000000000009
34
+ 0.69,2.28,0,0,4.17,0,18.42,103.52000000000001,1.7,76.26,36.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DO PAU-BRASIL,10353.1623171,2002,0.42686675166,N�O SE APLICA,0.00910866994,SIM,28,APA PAU BRASIL,11,1:50.000,0000000000000000000a
35
+ 0.26,6.66,0.28,0,29.88,0,21.28,59.53999999999999,0.5,0.68,27.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DA SERRA DE SAPIATIBA,5955.22943195,1990,0.34376268569,N�O SE APLICA,0.00523829411,SIM,29,APA DA SERRA DE SAPIATIBA,12,1:50.000,0000000000000000000b
36
+ 0.14,12.69,1.29,0,264.0,0,456.92,742.91,0.81,7.06,37.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DO RIO GUANDU,74295.2023405,2007,3.89480581005,N�O SE APLICA,0.06525411525,N�O,26,APA DO RIO GUANDU,13,1:50.000,0000000000000000000c
37
+ 0,0.0,0,0,0.01,0,0.25,0.29000000000000004,0,0.03,38.0,USO SUSTENTAVEL,FLOR,ESTADUAL,FLORESTA ESTADUAL JOSE ZAGO,29.1364229911,2016,0.02136871955,N�O SE APLICA,2.549498E-5,N�O,37,FLOE JOSE ZAGO,14,1:25.000,0000000000000000000d
38
+ 0.03,0.12,0,0,0.56,0,0.96,1.7200000000000002,0.05,0,33.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DE SEPETIBA II,171.666213409,2004,0.05801156773,N�O SE APLICA,1.5116278E-4,N�O,34,APA DE SEPETIBA II,15,1:10.000,0000000000000000000e
39
+ 0.13,0,0,0,0.02,0,1.16,18.99,0,17.68,39.0,USO SUSTENTAVEL,RDS,ESTADUAL,RESERVA DE DESENVOLVIMENTO SUSTENTAVEL DO AVENTUREIRO,1899.91188332,2014,0.21453857684,N�O SE APLICA,0.00167576192,N�O,39,RDS DO AVENTUREIRO,16,1:50.000,0000000000000000000f
40
+ 0.22,0.01,0,0,0.1,0,0.1,39.42,0.04,38.95,40.0,USO SUSTENTAVEL,RESEX,ESTADUAL,RESERVA EXTRATIVISTA MARINHA DE ITAIPU,3942.53457822,2013,0.4358579572,N�O SE APLICA,0.00347203423,N�O,38,RESEX MARINHA DE ITAIPU,17,1:25.000,00000000000000000010
41
+ 0.54,6.03,0,3.98,3.28,0,200.16,225.33999999999997,0.32,11.03,34.0,USO SUSTENTAVEL,APA,ESTADUAL,AREA DE PROTECAO AMBIENTAL DE TAMOIOS,22545.1793314,1986,6.34858345439,N�O SE APLICA,0.01987470585,SIM,35,APA DE TAMOIOS,38,Sem info,00000000000000000025
pages/00_home.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import solara
2
+
3
+
4
+ @solara.component
5
+ def Page():
6
+ with solara.Column(align="center"):
7
+ markdown = """
8
+ ## Avaliação do Zoneamento Climático e Uso de Solo
9
+
10
+ ### Importância do Zoneamento Climático
11
+
12
+ O zoneamento climático é uma ferramenta essencial para o planejamento ambiental e o manejo sustentável dos recursos naturais. Ele envolve a avaliação detalhada de variáveis climáticas, como temperatura, precipitação, umidade e radiação solar, bem como características do solo, como textura, fertilidade, drenagem e profundidade. Essa abordagem integrada permite identificar áreas com condições específicas para a vegetação natural e para atividades humanas, como agricultura, reflorestamento e conservação ambiental.
13
+
14
+ A importância dessa avaliação reside no fato de que ela fornece subsídios para mitigar impactos ambientais, promover o uso eficiente do solo e garantir a resiliência dos ecossistemas frente às mudanças climáticas. Além disso, o zoneamento climático é fundamental para orientar a criação de Unidades de Conservação, proteger áreas sensíveis e preservar a biodiversidade.
15
+
16
+ ### Desenvolvimento de um Aplicativo para Visualização Facilitada
17
+
18
+ Para tornar os dados de zoneamento climático mais acessíveis e práticos para pesquisadores, gestores públicos e comunidades locais, foi desenvolvido um aplicativo inovador. Este aplicativo integra variáveis climáticas e do solo em uma interface intuitiva e visual, permitindo a análise e a exploração de informações relevantes de forma ágil.
19
+
20
+ Com o aplicativo, é possível visualizar mapas interativos que destacam áreas com diferentes zonas climáticas e tipos de solo. Além disso, ele permite identificar as condições ideais para determinados tipos de vegetação, monitorar mudanças ao longo do tempo e realizar simulações de cenários futuros com base em dados climáticos projetados.
21
+
22
+ ### Benefícios para a Conservação e o Planejamento Sustentável
23
+
24
+ O aplicativo representa uma solução tecnológica que potencializa a conservação ambiental e o planejamento territorial. Ao unir dados complexos em uma plataforma de fácil acesso, ele apoia iniciativas de restauração florestal, delimitação de áreas prioritárias para conservação e planejamento de uso do solo. Ademais, promove a conscientização da sociedade sobre a importância de preservar os ecossistemas e utilizar os recursos naturais de forma responsável.
25
+
26
+ Essa tecnologia é também um exemplo de como a inovação pode contribuir para o cumprimento das metas climáticas globais e para a construção de um futuro mais sustentável e resiliente para as gerações futuras.
27
+ """
28
+
29
+ solara.Markdown(markdown)
pages/01_Agro-Clima.py ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import leafmap
3
+ import solara
4
+ import ipywidgets as widgets
5
+ import ee
6
+ import geemap
7
+ import geemap.colormaps as cm
8
+
9
+
10
+
11
+
12
+
13
+
14
+ zoom = solara.reactive(2)
15
+ center = solara.reactive((20, 0))
16
+
17
+
18
+ maps = {
19
+ 'Koeppen-Geiger (3-character) classification 2011-2040': 'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/IPSL-CM5A-LR/rcp4p5/KG3_IPSL-CM5A-LR_rcp4p5_2020s.tif',
20
+ "Total number of growing period days": 'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/GFDL-ESM2M/rcp2p6/TS/lgd_GFDL-ESM2M_rcp2p6_',
21
+ "Number of dry days during temperature growing period LGPt=5 (days)" : 'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/IPSL-CM5A-LR/rcp8p5/TS/ndd2_IPSL-CM5A-LR_rcp8p5_',
22
+ 'Longest period of consecutive dry days in temperature growing period LGPt=5(days)':'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/HadGEM2-ES/rcp2p6/TS/ndd_HadGEM2-ES_rcp2p6_',
23
+ 'Annual temperature amplitude (°C)': 'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/NorESM1-M/rcp4p5/TS/td2_NorESM1-M_rcp4p5_',
24
+ 'Mean annual temperature (°C)': 'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/MIROC-ESM-CHEM/rcp4p5/TS/tmp_MIROC-ESM-CHEM_rcp4p5_',
25
+ 'Annual precipitation (mm)': 'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/MIROC-ESM-CHEM/rcp6p0/TS/prc_MIROC-ESM-CHEM_rcp6p0_',
26
+ 'Total number of rain days (days with P > 1 mm)': 'https://s3.eu-west-1.amazonaws.com/data.gaezdev.aws.fao.org/res01/IPSL-CM5A-LR/rcp4p5/TS/ndr_IPSL-CM5A-LR_rcp4p5_'
27
+
28
+ }
29
+ anos = list(range(2025, 2041))
30
+ estados = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level1').filter(ee.Filter.eq('ADM0_NAME', 'Brazil'))
31
+
32
+
33
+ # Get the list of state names
34
+ estados_list = estados.aggregate_array('ADM1_NAME').getInfo()
35
+
36
+
37
+
38
+ #municipios = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil'))
39
+ #municipios_list =
40
+
41
+ # Get the list of municipality names
42
+ #estados_list = [estados_list]
43
+
44
+ maps_list= list(maps)
45
+ maps_values= list(maps.values())
46
+
47
+
48
+
49
+
50
+
51
+ legend_dict = {
52
+ "NA": "#FFFFFF",
53
+ "Tropics, lowland; semi-arid, no soil/terrain limitations": "#FF99CC",
54
+ "Tropics, lowland; semi-arid, with soil/terrain limitations": "#FF6699",
55
+ "Tropics, lowland; sub-humid, no soil/terrain limitations": "#FF9966",
56
+ "Tropics, lowland; sub-humid, with soil/terrain limitations": "#FF6600",
57
+ "Tropics, lowland; humid, no soil/terrain limitations": "#FFCC66",
58
+ "Tropics, lowland; humid, with soil/terrain limitations": "#FF9933",
59
+ "Tropics, highland; semi-arid, no soil/terrain limitations": "#FFCC99",
60
+ "Tropics, highland; semi-arid, with soil/terrain limitations": "#FFCC00",
61
+ "Tropics, highland; sub-humid, no soil/terrain limitations": "#FFFF99",
62
+ "Tropics, highland; sub-humid, with soil/terrain limitations": "#FFFF33",
63
+ "Tropics, highland; humid, no soil/terrain limitations": "#FFFF66",
64
+ "Tropics, highland; humid, with soil/terrain limitations": "#FFFF00",
65
+ "Sub-tropics, warm; semi-arid, no soil/terrain limitations": "#FFCC33",
66
+ "Sub-tropics, warm; semi-arid, with soil/terrain limitations": "#FF9900",
67
+ "Sub-tropics, warm; sub-humid, no soil/terrain limitations": "#FFCC00",
68
+ "Sub-tropics, warm; sub-humid, with soil/terrain limitations": "#FF9900",
69
+ "Sub-tropics, warm; humid, no soil/terrain limitations": "#FFD700",
70
+ "Sub-tropics, warm; humid, with soil/terrain limitations": "#FF8C00",
71
+ "Sub-tropics, mod. cool; semi-arid, no soil/terrain limitations": "#FFA07A",
72
+ "Sub-tropics, mod. cool; semi-arid, with soil/terrain limitations": "#FF4500",
73
+ "Sub-tropics, mod. cool; sub-humid, no soil/terrain limitations": "#FFA500",
74
+ "Sub-tropics, mod. cool; sub-humid, with soil/terrain limitations": "#FFDAB9",
75
+ "Sub-tropics, mod. cool; humid, no soil/terrain limitations": "#FFD700",
76
+ "Sub-tropics, mod. cool; humid, with soil/terrain limitations": "#FFC0CB",
77
+ "Sub-tropics, cool; semi-arid, no soil/terrain limitations": "#98FB98",
78
+ "Sub-tropics, cool; semi-arid, with soil/terrain limitations": "#7CFC00",
79
+ "Sub-tropics, cool; sub-humid, no soil/terrain limitations": "#ADFF2F",
80
+ "Sub-tropics, cool; sub-humid, with soil/terrain limitations": "#32CD32",
81
+ "Sub-tropics, cool; humid, no soil/terrain limitations": "#00FF00",
82
+ "Sub-tropics, cool; humid, with soil/terrain limitations": "#008000",
83
+ "Temperate, moderate; dry, no soil/terrain limitations": "#ADD8E6",
84
+ "Temperate, moderate; dry, with soil/terrain limitations": "#4682B4",
85
+ "Temperate, moderate; moist, no soil/terrain limitations": "#5F9EA0",
86
+ "Temperate, moderate; moist, with soil/terrain limitations": "#6495ED",
87
+ "Temperate, moderate; wet, no soil/terrain limitations": "#1E90FF",
88
+ "Temperate, moderate; wet, with soil/terrain limitations": "#0000FF",
89
+ "Temperate, cool; dry, no soil/terrain limitations": "#87CEEB",
90
+ "Temperate, cool; dry, with soil/terrain limitations": "#4169E1",
91
+ "Temperate, cool; moist, no soil/terrain limitations": "#191970",
92
+ "Temperate, cool; moist, with soil/terrain limitations": "#00008B",
93
+ "Temperate, cool; wet, no soil/terrain limitations": "#4B0082",
94
+ "Temperate, cool; wet, with soil/terrain limitations": "#8A2BE2",
95
+ "Cold, no permafrost; dry, no soil/terrain limitations": "#708090",
96
+ "Cold, no permafrost; dry, with soil/terrain limitations": "#2F4F4F",
97
+ "Cold, no permafrost; moist, no soil/terrain limitations": "#696969",
98
+ "Cold, no permafrost; moist, with soil/terrain limitations": "#808080",
99
+ "Cold, no permafrost; wet, no soil/terrain limitations": "#A9A9A9",
100
+ "Cold, no permafrost; wet, with soil/terrain limitations": "#D3D3D3",
101
+ "Dominantly very steep terrain": "#FFD700",
102
+ "Land with severe soil/terrain limitations": "#A0522D",
103
+ "Ample irrigated soils": "#CD5C5C",
104
+ "Dominantly hydromorphic soils": "#8B0000",
105
+ "Desert/Arid climate": "#FF4500",
106
+ "Boreal/Cold climate": "#2E8B57",
107
+ "Arctic/Very cold climate": "#00CED1",
108
+ "Dominantly built-up land": "#8B4513",
109
+ "Dominantly water": "#0000FF"
110
+ }
111
+
112
+
113
+
114
+
115
+ def add_widgets(m):
116
+
117
+ setattr(m, "zoom_to_layer", True)
118
+ style = {"description_width": "initial"}
119
+ padding = "0px 0px 0px 5px"
120
+
121
+ estado = widgets.Dropdown(
122
+ value= None,
123
+ options=estados_list,
124
+ description="Estado:",
125
+ style=style,
126
+ layout=widgets.Layout(width="270px", padding=padding),
127
+ )
128
+
129
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value))
130
+ municipio_list = municipio_ee.aggregate_array('ADM2_NAME').getInfo()
131
+
132
+ municipio = widgets.Dropdown(
133
+ value=None,
134
+ options=municipio_list,
135
+ description="Municipio:",
136
+ style=style,
137
+ layout=widgets.Layout(width="270px", padding=padding),
138
+ )
139
+
140
+
141
+
142
+
143
+ image = widgets.Dropdown(
144
+ value=None,
145
+ options=[('Koeppen-Geiger (3-character) classification 2011-2040', maps_values[0]),
146
+ ('Total number of growing period days', maps_values[1]),
147
+ ('Number of dry days during temperature growing period LGPt=5 (days)', maps_values[2]),
148
+ ('Longest period of consecutive dry days in temperature growing period LGPt=5(days)', maps_values[3]),
149
+ ('Annual temperature amplitude (°C)', maps_values[4]),
150
+ ('Mean annual temperature (°C)', maps_values[5]),
151
+ ('Annual precipitation (mm)', maps_values[6]),
152
+ ('Total number of rain days (days with P > 1 mm)', maps_values[7]),
153
+ ],
154
+ description="Image:",
155
+ style=style,
156
+ layout=widgets.Layout(width="270px", padding=padding),
157
+ )
158
+
159
+ ano = widgets.Dropdown(
160
+ value=None,
161
+ options=anos,
162
+ description="Ano:",
163
+ style=style,
164
+ layout=widgets.Layout(width="270px", padding=padding),
165
+ )
166
+
167
+ output = widgets.Output()
168
+
169
+
170
+ def change_estado(change):
171
+ if change.new:
172
+ #mosaic = f"{url}/datasets/{dataset.value}/{image.value}.json"
173
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value))
174
+ municipio_list = municipio_ee.aggregate_array('ADM2_NAME').getInfo()
175
+
176
+ municipio.options = municipio_list
177
+ #image_date = get_image_date(image.value, m)
178
+ output.outputs = ()
179
+ #output.append_stdout(f"Image date: {image_date}\n")
180
+
181
+ estado.observe(change_estado, names="value")
182
+
183
+ def change_municipio(change):
184
+ if change.new:
185
+ #mosaic = f"{url}/datasets/{dataset.value}/{image.value}.json"
186
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value)).filter(ee.Filter.eq('ADM2_NAME', municipio.value))
187
+
188
+ m.add_layer(municipio_ee, name =municipio.value )
189
+ m.centerObject(municipio_ee)
190
+ #image_date = get_image_date(image.value, m)
191
+ output.outputs = ()
192
+ #output.append_stdout(f"Image date: {image_date}\n")
193
+
194
+ municipio.observe(change_municipio, names="value")
195
+
196
+ def change_ano(change):
197
+ if change.new:
198
+ if change.new not in m.get_layer_names():
199
+ #mosaic = f"{url}/datasets/{dataset.value}/{image.value}.json"
200
+ colors = cm.get_palette(cmap_name='inferno', hashtag=True)
201
+ m.add_cog_layer(image.value+ str(ano.value) + '.tif', name= str(ano.value),palette = 'inferno', fit_bounds= m.zoom_to_layer)
202
+
203
+
204
+ if image.value == maps_values[4] or image.value == maps_values[5]:
205
+ m.remove_colorbar()
206
+ colors = cm.get_palette(cmap_name='inferno', hashtag=True)
207
+ m.add_colorbar_branca(colors= colors, vmin=0, vmax=40, position='bottomright', orientation='horizontal', label='°C', caption='Graus Celsius')
208
+ elif image.value == maps_values[6]:
209
+ m.remove_colorbar()
210
+ colors = cm.get_palette(cmap_name='inferno', hashtag=True)
211
+ m.add_colorbar_branca(colors= colors, vmin=0, vmax=3000, position='bottomright', orientation='horizontal', label='mm', caption='Precipitação Anual')
212
+ else:
213
+ m.remove_colorbar()
214
+ colors = cm.get_palette(cmap_name='inferno', hashtag=True)
215
+ m.add_colorbar_branca(colors= colors, vmin=0, vmax=365, position='bottomright', orientation='horizontal', label='Dias', caption='Dias no Ano')
216
+
217
+
218
+ output.outputs = ()
219
+ #output.append_stdout(f"Image date: {image_date}\n")
220
+
221
+ ano.observe(change_ano, names="value")
222
+
223
+
224
+ def change_image(change):
225
+ if change.new:
226
+ if change.new not in m.get_layer_names():
227
+ #mosaic = f"{url}/datasets/{dataset.value}/{image.value}.json"
228
+ layer_list = m.get_layer_names()
229
+
230
+ for layer in layer_list:
231
+ m.remove_layer(m.find_layer(layer))
232
+
233
+
234
+ m.add_basemap("HYBRID")
235
+ m.remove_legend()
236
+
237
+ if image.value == maps_values[0]:
238
+
239
+
240
+ m.remove_colorbar()
241
+
242
+ aez = ee.Image('users/rhamonvmlbg/agro-clima/Koeppen-Geiger_3-character_classification')
243
+
244
+ colors = [
245
+ "#FFFFFF",
246
+ "#FF99CC",
247
+ "#FF6699",
248
+ "#FF9966",
249
+ "#FF6600",
250
+ "#FFCC66",
251
+ "#FF9933",
252
+ "#FFCC99",
253
+ "#FFCC00",
254
+ "#FFFF99",
255
+ "#FFFF33",
256
+ "#FFFF66",
257
+ "#FFFF00",
258
+ "#FFCC33",
259
+ "#FF9900",
260
+ "#FFCC00",
261
+ "#FF9900",
262
+ "#FFD700",
263
+ "#FF8C00",
264
+ "#FFA07A",
265
+ "#FF4500",
266
+ "#FFA500",
267
+ "#FFDAB9",
268
+ "#FFD700",
269
+ "#FFC0CB",
270
+ "#98FB98",
271
+ "#7CFC00",
272
+ "#ADFF2F",
273
+ "#32CD32",
274
+ "#00FF00",
275
+ "#008000",
276
+ "#ADD8E6",
277
+ "#4682B4",
278
+ "#5F9EA0",
279
+ "#6495ED",
280
+ "#1E90FF",
281
+ "#0000FF",
282
+ "#87CEEB",
283
+ "#4169E1",
284
+ "#191970",
285
+ "#00008B",
286
+ "#4B0082",
287
+ "#8A2BE2",
288
+ "#708090",
289
+ "#2F4F4F",
290
+ "#696969",
291
+ "#808080",
292
+ "#A9A9A9",
293
+ "#D3D3D3",
294
+ "#FFD700",
295
+ "#A0522D",
296
+ "#CD5C5C",
297
+ "#8B0000",
298
+ "#FF4500",
299
+ "#2E8B57",
300
+ "#00CED1",
301
+ "#8B4513",
302
+ "#0000FF"
303
+ ]
304
+
305
+
306
+
307
+ vis_params ={
308
+ 'min': 0,
309
+ 'max': 58,
310
+ 'palette': colors,
311
+
312
+ }
313
+
314
+
315
+ m.addLayer(aez, vis_params, name ='Koeppen-Geiger Classification')
316
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value)).filter(ee.Filter.eq('ADM2_NAME', municipio.value))
317
+
318
+ m.add_layer(municipio_ee, name =municipio.value )
319
+
320
+ elif image.value == maps_values[4] or image.value == maps_values[5]:
321
+ m.remove_colorbar()
322
+ colors = cm.get_palette(cmap_name='inferno', hashtag=True)
323
+ m.add_cog_layer(image.value+ str(ano.value) + '.tif', name=str(ano.value), palette = 'inferno' )
324
+ m.add_colorbar_branca(colors= colors, vmin=0, vmax=40, position='bottomright', orientation='horizontal', label='°C', caption='Graus Celsius')
325
+ elif image.value == maps_values[6]:
326
+ m.remove_colorbar()
327
+ colors = cm.get_palette(cmap_name='inferno', hashtag=True)
328
+ m.add_cog_layer(image.value+ str(ano.value) + '.tif', name=str(ano.value), palette = 'inferno' )
329
+ m.add_colorbar_branca(colors= colors, vmin=0, vmax=3000, position='bottomright', orientation='horizontal', label='mm', caption='Precipitação Anual')
330
+
331
+
332
+
333
+ else:
334
+
335
+ m.add_cog_layer(image.value+ str(ano.value) + '.tif', name=str(ano.value), palette = 'inferno' )
336
+ m.remove_colorbar()
337
+ colors = cm.get_palette(cmap_name='inferno', hashtag=True)
338
+ m.add_colorbar_branca(colors= colors, vmin=0, vmax=365, position='bottomright', orientation='horizontal', label='Dias', caption='Dias no Ano')
339
+
340
+
341
+
342
+ #image_date = get_image_date(image.value, m)
343
+
344
+ output.outputs = ()
345
+ #output.append_stdout(f"Image date: {image_date}\n")
346
+
347
+ image.observe(change_image, names="value")
348
+
349
+ box = widgets.VBox(
350
+ [ image,ano,estado,municipio, output]
351
+ )
352
+ m.add_widget(box, position="topright", add_header=False)
353
+
354
+
355
+ class Map(geemap.Map):
356
+ def __init__(self, **kwargs):
357
+ super().__init__(**kwargs)
358
+ self.add_ee_data()
359
+ ee.Initialize()
360
+ add_widgets(self)
361
+ self.add_layer_manager(opened= True)
362
+ self.add_legend(legend_title="Legend", legend_dict=legend_dict, open=False)
363
+ #self.add_inspector()
364
+
365
+
366
+ def add_ee_data(self):
367
+
368
+ aez = ee.Image('users/rhamonvmlbg/agro-clima/Koeppen-Geiger_3-character_classification')
369
+
370
+ colors = [
371
+ "#FFFFFF",
372
+ "#FF99CC",
373
+ "#FF6699",
374
+ "#FF9966",
375
+ "#FF6600",
376
+ "#FFCC66",
377
+ "#FF9933",
378
+ "#FFCC99",
379
+ "#FFCC00",
380
+ "#FFFF99",
381
+ "#FFFF33",
382
+ "#FFFF66",
383
+ "#FFFF00",
384
+ "#FFCC33",
385
+ "#FF9900",
386
+ "#FFCC00",
387
+ "#FF9900",
388
+ "#FFD700",
389
+ "#FF8C00",
390
+ "#FFA07A",
391
+ "#FF4500",
392
+ "#FFA500",
393
+ "#FFDAB9",
394
+ "#FFD700",
395
+ "#FFC0CB",
396
+ "#98FB98",
397
+ "#7CFC00",
398
+ "#ADFF2F",
399
+ "#32CD32",
400
+ "#00FF00",
401
+ "#008000",
402
+ "#ADD8E6",
403
+ "#4682B4",
404
+ "#5F9EA0",
405
+ "#6495ED",
406
+ "#1E90FF",
407
+ "#0000FF",
408
+ "#87CEEB",
409
+ "#4169E1",
410
+ "#191970",
411
+ "#00008B",
412
+ "#4B0082",
413
+ "#8A2BE2",
414
+ "#708090",
415
+ "#2F4F4F",
416
+ "#696969",
417
+ "#808080",
418
+ "#A9A9A9",
419
+ "#D3D3D3",
420
+ "#FFD700",
421
+ "#A0522D",
422
+ "#CD5C5C",
423
+ "#8B0000",
424
+ "#FF4500",
425
+ "#2E8B57",
426
+ "#00CED1",
427
+ "#8B4513",
428
+ "#0000FF"
429
+ ]
430
+
431
+
432
+
433
+ vis_params ={
434
+ 'min': 0,
435
+ 'max': 58,
436
+ 'palette': colors,
437
+
438
+ }
439
+
440
+
441
+ self.addLayer(aez, vis_params, name ='Koeppen-Geiger Classification')
442
+
443
+
444
+
445
+
446
+
447
+
448
+ @solara.component
449
+ def Page():
450
+ with solara.Column(style={"min-width": "500px"}):
451
+ Map.element(
452
+ zoom=zoom.value,
453
+ on_zoom=zoom.set,
454
+ center=center.value,
455
+ on_center=center.set,
456
+ height="600px",
457
+ toolbar_ctrl=False,
458
+ data_ctrl=True,
459
+ add_google_map=True,
460
+ )
pages/02_Solos.py ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #import os
2
+ #import leafmap
3
+ import solara
4
+ import ipywidgets as widgets
5
+ import ee
6
+ import geemap
7
+ import geemap.colormaps as cm
8
+
9
+ zoom = solara.reactive(2)
10
+ center = solara.reactive((20, 0))
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ maps = {
19
+ 'Most limiting soil quality rating factor': ee.Image('users/rhamonvmlbg/agro-clima/Most_limiting_soil_quality_rating_factor'),
20
+ "Nutrient retention capacity": ee.Image('users/rhamonvmlbg/agro-clima/Nutrient_retention_capacity'),
21
+ "Rooting conditions" : ee.Image('users/rhamonvmlbg/agro-clima/Rooting_conditions'),
22
+ 'Soil and terrain suitability, rain-fed': ee.Image('users/rhamonvmlbg/agro-clima/Soil_and_terrain_suitability_rain-fed')
23
+ }
24
+ anos = list(range(2025, 2041))
25
+ estados = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level1').filter(ee.Filter.eq('ADM0_NAME', 'Brazil'))
26
+
27
+
28
+ # Get the list of state names
29
+ estados_list = estados.aggregate_array('ADM1_NAME').getInfo()
30
+
31
+
32
+
33
+ #municipios = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil'))
34
+ #municipios_list =
35
+
36
+ # Get the list of municipality names
37
+ #estados_list = [estados_list]
38
+
39
+ maps_list= list(maps)
40
+ maps_values= list(maps.values())
41
+
42
+
43
+
44
+
45
+
46
+ legend_dict1 = {
47
+ "NA": "#FFFFFF", # Branco
48
+ "0.0 - 0.1": "#8B0000", # Vermelho escuro
49
+ "0.1 - 0.2": "#FF4500", # Laranja avermelhado
50
+ "0.2 - 0.3": "#FFA500", # Laranja
51
+ "0.3 - 0.4": "#FFD700", # Amarelo dourado
52
+ "0.4 - 0.5": "#FFFF00", # Amarelo
53
+ "0.5 - 0.6": "#ADFF2F", # Verde amarelado
54
+ "0.6 - 0.7": "#7FFF00", # Verde limão
55
+ "0.7 - 0.8": "#32CD32", # Verde médio
56
+ "0.8 - 0.9": "#008000", # Verde
57
+ "0.9 - 1.0": "#006400", # Verde escuro
58
+ "Permafrost": "#B0C4DE", # Cinza claro azulado
59
+ "Not evaluated": "#A9A9A9", # Cinza escuro
60
+ "Water": "#0000FF", # Azul
61
+ }
62
+ hex_colors = [
63
+ "#FFFFFF", # NA
64
+ "#8B0000", # 0.0 - 0.1
65
+ "#FF4500", # 0.1 - 0.2
66
+ "#FFA500", # 0.2 - 0.3
67
+ "#FFD700", # 0.3 - 0.4
68
+ "#FFFF00", # 0.4 - 0.5
69
+ "#ADFF2F", # 0.5 - 0.6
70
+ "#7FFF00", # 0.6 - 0.7
71
+ "#32CD32", # 0.7 - 0.8
72
+ "#008000", # 0.8 - 0.9
73
+ "#006400", # 0.9 - 1.0
74
+ "#B0C4DE", # Permafrost
75
+ "#A9A9A9", # Not evaluated
76
+ "#0000FF", # Water
77
+ ]
78
+
79
+
80
+
81
+
82
+ def add_widgets(m):
83
+
84
+ setattr(m, "zoom_to_layer", True)
85
+ style = {"description_width": "initial"}
86
+ padding = "0px 0px 0px 5px"
87
+
88
+ estado = widgets.Dropdown(
89
+ value= None,
90
+ options=estados_list,
91
+ description="Estado:",
92
+ style=style,
93
+ layout=widgets.Layout(width="270px", padding=padding),
94
+ )
95
+
96
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value))
97
+ municipio_list = municipio_ee.aggregate_array('ADM2_NAME').getInfo()
98
+
99
+ municipio = widgets.Dropdown(
100
+ value=None,
101
+ options=municipio_list,
102
+ description="Municipio:",
103
+ style=style,
104
+ layout=widgets.Layout(width="270px", padding=padding),
105
+ )
106
+
107
+
108
+
109
+
110
+ image = widgets.Dropdown(
111
+ value=None,
112
+ options=[('Most limiting soil quality rating factor', maps_values[0]),
113
+ ('Nutrient retention capacity', maps_values[1]),
114
+ ('Rooting conditions', maps_values[2]),
115
+ ('Soil and terrain suitability, rain-fed', maps_values[3]),
116
+ ],
117
+ description="Image:",
118
+ style=style,
119
+ layout=widgets.Layout(width="270px", padding=padding),
120
+ )
121
+
122
+
123
+
124
+ output = widgets.Output()
125
+
126
+
127
+ def change_estado(change):
128
+ if change.new:
129
+ #mosaic = f"{url}/datasets/{dataset.value}/{image.value}.json"
130
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value))
131
+ municipio_list = municipio_ee.aggregate_array('ADM2_NAME').getInfo()
132
+
133
+ municipio.options = municipio_list
134
+ #image_date = get_image_date(image.value, m)
135
+ output.outputs = ()
136
+ #output.append_stdout(f"Image date: {image_date}\n")
137
+
138
+ estado.observe(change_estado, names="value")
139
+
140
+ def change_municipio(change):
141
+ if change.new:
142
+ #mosaic = f"{url}/datasets/{dataset.value}/{image.value}.json"
143
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value)).filter(ee.Filter.eq('ADM2_NAME', municipio.value))
144
+
145
+ m.add_layer(municipio_ee, name =municipio.value )
146
+ m.centerObject(municipio_ee)
147
+ #image_date = get_image_date(image.value, m)
148
+ output.outputs = ()
149
+ #output.append_stdout(f"Image date: {image_date}\n")
150
+
151
+ municipio.observe(change_municipio, names="value")
152
+
153
+
154
+
155
+
156
+ def change_image(change):
157
+ if change.new:
158
+ if change.new not in m.get_layer_names():
159
+ #mosaic = f"{url}/datasets/{dataset.value}/{image.value}.json"
160
+ layer_list = m.get_layer_names()
161
+
162
+ for layer in layer_list:
163
+ m.remove_layer(m.find_layer(layer))
164
+
165
+
166
+ m.add_basemap("HYBRID")
167
+ m.remove_legend()
168
+
169
+ if image.value == maps_values[0]:
170
+
171
+
172
+ vis_params = {
173
+ 'min': 0,
174
+ 'max': 13,
175
+ 'palette': hex_colors,
176
+ }
177
+
178
+
179
+ m.addLayer(image.value,vis_params, name=maps_list[0])
180
+ m.add_legend(legend_title="Legend", legend_dict=legend_dict1)
181
+
182
+
183
+ municipio_ee = ee.FeatureCollection('FAO/GAUL_SIMPLIFIED_500m/2015/level2').filter(ee.Filter.eq('ADM0_NAME', 'Brazil')).filter(ee.Filter.eq('ADM1_NAME', estado.value)).filter(ee.Filter.eq('ADM2_NAME', municipio.value))
184
+
185
+ m.add_layer(municipio_ee, name =municipio.value )
186
+
187
+ elif image.value == maps_values[1]:
188
+
189
+ vis_params = {
190
+ 'min': 0,
191
+ 'max': 13,
192
+ 'palette': hex_colors,
193
+ }
194
+
195
+
196
+ m.addLayer(image.value,vis_params, name=maps_list[1])
197
+ m.add_legend(legend_title="Legend", legend_dict=legend_dict1)
198
+
199
+ elif image.value == maps_values[2]:
200
+
201
+ vis_params = {
202
+ 'min': 0,
203
+ 'max': 13,
204
+ 'palette': hex_colors,
205
+ }
206
+
207
+
208
+ m.addLayer(image.value,vis_params, name=maps_list[2])
209
+ m.add_legend(legend_title="Legend", legend_dict=legend_dict1)
210
+
211
+ elif image.value == maps_values[3]:
212
+ colors = [
213
+ "#FFFFFF10", # Branco
214
+ "#006400", # Verde escuro
215
+ "#008000", # Verde
216
+ "#ADFF2F", # Verde claro
217
+ "#FFFF00", # Amarelo
218
+ "#DAA520", # Dourado escuro
219
+ "#FF8C00", # Laranja
220
+ "#A9A9A9", # Cinza escuro
221
+ "#D3D3D3", # Cinza claro
222
+ "#0000FF", # Azul
223
+ "#FF0000" # Vermelho
224
+ ]
225
+ legend_dict = {
226
+ "NA": "#FFFFFF", # Branco
227
+ "SI > 75 : Very high": "#006400", # Verde escuro
228
+ "SI > 63 : High": "#008000", # Verde
229
+ "SI > 50 : Good": "#ADFF2F", # Verde claro
230
+ "SI > 35 : Medium": "#FFFF00", # Amarelo
231
+ "SI > 20 : Moderate": "#DAA520", # Dourado escuro
232
+ "SI > 10 : Marginal": "#FF8C00", # Laranja
233
+ "SI > 0 : Very marginal": "#A9A9A9", # Cinza escuro
234
+ "Not suitable": "#D3D3D3", # Cinza claro
235
+ "No cultivation": "#0000FF", # Azul
236
+ "Water": "#FF0000" # Vermelho
237
+ }
238
+
239
+ vis_params = {
240
+ 'min': 0,
241
+ 'max': 10,
242
+ 'palette': colors,
243
+ }
244
+
245
+ m.addLayer(image.value,vis_params, name=maps_list[3])
246
+ m.add_legend(legend_title="Legend", legend_dict=legend_dict)
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+ #image_date = get_image_date(image.value, m)
255
+
256
+ output.outputs = ()
257
+ #output.append_stdout(f"Image date: {image_date}\n")
258
+
259
+ image.observe(change_image, names="value")
260
+
261
+ box = widgets.VBox(
262
+ [ image,estado,municipio, output]
263
+ )
264
+ m.add_widget(box, position="topright", add_header=False)
265
+
266
+
267
+ class Map(geemap.Map):
268
+ def __init__(self, **kwargs):
269
+ super().__init__(**kwargs)
270
+ #self.add_ee_data()
271
+ ee.Initialize()
272
+ add_widgets(self)
273
+
274
+ self.add_layer_manager(opened= True)
275
+ #self.add_legend(legend_title="Legend", legend_dict=legend_dict)
276
+ #self.add_inspector()
277
+
278
+
279
+ #def add_ee_data(self):
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+ @solara.component
289
+ def Page():
290
+ with solara.Column(style={"min-width": "500px"}):
291
+ Map.element(
292
+ zoom=zoom.value,
293
+ on_zoom=zoom.set,
294
+ center=center.value,
295
+ on_center=center.set,
296
+ height="600px",
297
+ toolbar_ctrl=False,
298
+ data_ctrl=True,
299
+ add_google_map=True,
300
+ )
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ geemap
2
+ geopandas
3
+ pydantic
4
+ solara
5
+ plotly
6
+ leafmap>=0.42.3
7
+ setuptools