giswqs pre-commit-ci[bot] commited on
Commit
02c996d
1 Parent(s): 3096e30

Add notebook examples (#2)

Browse files

* Add notebook examples

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Improve notebook

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

.pre-commit-config.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.6.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.8.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
notebooks/01_basic.ipynb ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import geemap\n",
10
+ "import solara\n",
11
+ "\n",
12
+ "zoom = solara.reactive(4)\n",
13
+ "center = solara.reactive((40, -100))\n",
14
+ "bounds = solara.reactive(None)\n",
15
+ "\n",
16
+ "\n",
17
+ "@solara.component\n",
18
+ "def Page():\n",
19
+ " # Isolation is required to prevent the map from overlapping navigation (when screen width < 960px)\n",
20
+ " with solara.Column(\n",
21
+ " style={\"min-width\": \"500px\", \"height\": \"780px\", \"isolation\": \"isolate\"}\n",
22
+ " ):\n",
23
+ " # solara components support reactive variables\n",
24
+ " solara.SliderInt(label=\"Zoom level\", value=zoom, min=1, max=20)\n",
25
+ " # using 3rd party widget library require wiring up the events manually\n",
26
+ " # using zoom.value and zoom.set\n",
27
+ " geemap.Map.element( # type: ignore\n",
28
+ " zoom=zoom.value,\n",
29
+ " on_zoom=zoom.set,\n",
30
+ " center=center.value,\n",
31
+ " on_center=center.set,\n",
32
+ " on_bounds=bounds.set,\n",
33
+ " scroll_wheel_zoom=True,\n",
34
+ " height=\"600px\",\n",
35
+ " )\n",
36
+ " solara.Text(f\"Zoom: {zoom.value}\")\n",
37
+ " solara.Text(f\"Center: {center.value}\")\n",
38
+ " solara.Text(f\"Bounds: {bounds.value}\")"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": null,
44
+ "metadata": {},
45
+ "outputs": [],
46
+ "source": [
47
+ "Page()"
48
+ ]
49
+ }
50
+ ],
51
+ "metadata": {
52
+ "kernelspec": {
53
+ "display_name": "geo",
54
+ "language": "python",
55
+ "name": "python3"
56
+ },
57
+ "language_info": {
58
+ "codemirror_mode": {
59
+ "name": "ipython",
60
+ "version": 3
61
+ },
62
+ "file_extension": ".py",
63
+ "mimetype": "text/x-python",
64
+ "name": "python",
65
+ "nbconvert_exporter": "python",
66
+ "pygments_lexer": "ipython3",
67
+ "version": "3.11.8"
68
+ }
69
+ },
70
+ "nbformat": 4,
71
+ "nbformat_minor": 2
72
+ }
notebooks/02_inspector.ipynb ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import ee\n",
10
+ "import geemap\n",
11
+ "\n",
12
+ "import solara\n",
13
+ "\n",
14
+ "\n",
15
+ "class Map(geemap.Map):\n",
16
+ " def __init__(self, **kwargs):\n",
17
+ " super().__init__(**kwargs)\n",
18
+ " self.add_ee_data()\n",
19
+ " self.add(\"layer_manager\")\n",
20
+ " self.add(\"inspector\")\n",
21
+ "\n",
22
+ " def add_ee_data(self):\n",
23
+ " # Add Earth Engine dataset\n",
24
+ " dem = ee.Image(\"USGS/SRTMGL1_003\")\n",
25
+ " landsat7 = ee.Image(\"LANDSAT/LE7_TOA_5YEAR/1999_2003\").select(\n",
26
+ " [\"B1\", \"B2\", \"B3\", \"B4\", \"B5\", \"B7\"]\n",
27
+ " )\n",
28
+ " states = ee.FeatureCollection(\"TIGER/2018/States\")\n",
29
+ "\n",
30
+ " # Set visualization parameters.\n",
31
+ " vis_params = {\n",
32
+ " \"min\": 0,\n",
33
+ " \"max\": 4000,\n",
34
+ " \"palette\": [\"006633\", \"E5FFCC\", \"662A00\", \"D8D8D8\", \"F5F5F5\"],\n",
35
+ " }\n",
36
+ "\n",
37
+ " # Add Earth Engine layers to Map\n",
38
+ " self.addLayer(\n",
39
+ " landsat7,\n",
40
+ " {\"bands\": [\"B4\", \"B3\", \"B2\"], \"min\": 20, \"max\": 200, \"gamma\": 2.0},\n",
41
+ " \"Landsat 7\",\n",
42
+ " True,\n",
43
+ " )\n",
44
+ " self.addLayer(dem, vis_params, \"SRTM DEM\", True, 1)\n",
45
+ " self.addLayer(states, {}, \"US States\")\n",
46
+ "\n",
47
+ "\n",
48
+ "@solara.component\n",
49
+ "def Page():\n",
50
+ " with solara.Column(style={\"min-width\": \"500px\"}):\n",
51
+ " Map.element(\n",
52
+ " center=[40, -100],\n",
53
+ " zoom=4,\n",
54
+ " height=\"600px\",\n",
55
+ " )"
56
+ ]
57
+ },
58
+ {
59
+ "cell_type": "code",
60
+ "execution_count": null,
61
+ "metadata": {},
62
+ "outputs": [],
63
+ "source": [
64
+ "Page()"
65
+ ]
66
+ }
67
+ ],
68
+ "metadata": {
69
+ "kernelspec": {
70
+ "display_name": "geo",
71
+ "language": "python",
72
+ "name": "python3"
73
+ },
74
+ "language_info": {
75
+ "codemirror_mode": {
76
+ "name": "ipython",
77
+ "version": 3
78
+ },
79
+ "file_extension": ".py",
80
+ "mimetype": "text/x-python",
81
+ "name": "python",
82
+ "nbconvert_exporter": "python",
83
+ "pygments_lexer": "ipython3",
84
+ "version": "3.11.8"
85
+ }
86
+ },
87
+ "nbformat": 4,
88
+ "nbformat_minor": 2
89
+ }
notebooks/03_plotting.ipynb ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import ee\n",
10
+ "import geemap\n",
11
+ "\n",
12
+ "import solara\n",
13
+ "\n",
14
+ "\n",
15
+ "class Map(geemap.Map):\n",
16
+ " def __init__(self, **kwargs):\n",
17
+ " super().__init__(**kwargs)\n",
18
+ " self.add_ee_data()\n",
19
+ " self.add_plot_gui()\n",
20
+ "\n",
21
+ " def add_ee_data(self):\n",
22
+ " landsat7 = ee.Image(\"LANDSAT/LE7_TOA_5YEAR/1999_2003\").select(\n",
23
+ " [\"B1\", \"B2\", \"B3\", \"B4\", \"B5\", \"B7\"]\n",
24
+ " )\n",
25
+ "\n",
26
+ " landsat_vis = {\"bands\": [\"B4\", \"B3\", \"B2\"], \"gamma\": 1.4}\n",
27
+ " self.addLayer(landsat7, landsat_vis, \"Landsat\")\n",
28
+ "\n",
29
+ " hyperion = ee.ImageCollection(\"EO1/HYPERION\").filter(\n",
30
+ " ee.Filter.date(\"2016-01-01\", \"2017-03-01\")\n",
31
+ " )\n",
32
+ "\n",
33
+ " hyperion_vis = {\n",
34
+ " \"min\": 1000.0,\n",
35
+ " \"max\": 14000.0,\n",
36
+ " \"gamma\": 2.5,\n",
37
+ " }\n",
38
+ " self.addLayer(hyperion, hyperion_vis, \"Hyperion\")\n",
39
+ "\n",
40
+ "\n",
41
+ "@solara.component\n",
42
+ "def Page():\n",
43
+ " with solara.Column(style={\"min-width\": \"500px\"}):\n",
44
+ " Map.element(\n",
45
+ " center=[40, -100],\n",
46
+ " zoom=4,\n",
47
+ " height=\"600px\",\n",
48
+ " )"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": null,
54
+ "metadata": {},
55
+ "outputs": [],
56
+ "source": [
57
+ "Page()"
58
+ ]
59
+ }
60
+ ],
61
+ "metadata": {
62
+ "kernelspec": {
63
+ "display_name": "geo",
64
+ "language": "python",
65
+ "name": "python3"
66
+ },
67
+ "language_info": {
68
+ "codemirror_mode": {
69
+ "name": "ipython",
70
+ "version": 3
71
+ },
72
+ "file_extension": ".py",
73
+ "mimetype": "text/x-python",
74
+ "name": "python",
75
+ "nbconvert_exporter": "python",
76
+ "pygments_lexer": "ipython3",
77
+ "version": "3.11.8"
78
+ }
79
+ },
80
+ "nbformat": 4,
81
+ "nbformat_minor": 2
82
+ }
notebooks/04_split_map.ipynb ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import ee\n",
10
+ "import geemap\n",
11
+ "\n",
12
+ "import solara\n",
13
+ "\n",
14
+ "\n",
15
+ "class Map(geemap.Map):\n",
16
+ " def __init__(self, **kwargs):\n",
17
+ " super().__init__(**kwargs)\n",
18
+ " self.add_ee_data()\n",
19
+ "\n",
20
+ " def add_ee_data(self):\n",
21
+ " # Select the eight NLCD epochs after 2000.\n",
22
+ " years = [\"2001\", \"2004\", \"2006\", \"2008\", \"2011\", \"2013\", \"2016\", \"2019\"]\n",
23
+ "\n",
24
+ " # Get an NLCD image by year.\n",
25
+ " def getNLCD(year):\n",
26
+ " # Import the NLCD collection.\n",
27
+ " dataset = ee.ImageCollection(\"USGS/NLCD_RELEASES/2019_REL/NLCD\")\n",
28
+ "\n",
29
+ " # Filter the collection by year.\n",
30
+ " nlcd = dataset.filter(ee.Filter.eq(\"system:index\", year)).first()\n",
31
+ "\n",
32
+ " # Select the land cover band.\n",
33
+ " landcover = nlcd.select(\"landcover\")\n",
34
+ " return landcover\n",
35
+ "\n",
36
+ " ## Create an NLCD image collection for the selected years.\n",
37
+ " collection = ee.ImageCollection(ee.List(years).map(lambda year: getNLCD(year)))\n",
38
+ "\n",
39
+ " # Create a list of labels to populate the dropdown list.\n",
40
+ " labels = [f\"NLCD {year}\" for year in years]\n",
41
+ "\n",
42
+ " # Add a split-panel map for visualizing NLCD land cover change.\n",
43
+ " self.ts_inspector(\n",
44
+ " left_ts=collection,\n",
45
+ " right_ts=collection,\n",
46
+ " left_names=labels,\n",
47
+ " right_names=labels,\n",
48
+ " )\n",
49
+ "\n",
50
+ " # Add the NLCD legend to the map.\n",
51
+ " self.add_legend(\n",
52
+ " title=\"NLCD Land Cover Type\",\n",
53
+ " builtin_legend=\"NLCD\",\n",
54
+ " height=\"460px\",\n",
55
+ " add_header=False,\n",
56
+ " )\n",
57
+ "\n",
58
+ "\n",
59
+ "@solara.component\n",
60
+ "def Page():\n",
61
+ " with solara.Column(style={\"min-width\": \"500px\"}):\n",
62
+ " Map.element(\n",
63
+ " center=[40, -100],\n",
64
+ " zoom=4,\n",
65
+ " height=\"600px\",\n",
66
+ " )"
67
+ ]
68
+ },
69
+ {
70
+ "cell_type": "code",
71
+ "execution_count": null,
72
+ "metadata": {},
73
+ "outputs": [],
74
+ "source": [
75
+ "Page()"
76
+ ]
77
+ }
78
+ ],
79
+ "metadata": {
80
+ "kernelspec": {
81
+ "display_name": "geo",
82
+ "language": "python",
83
+ "name": "python3"
84
+ },
85
+ "language_info": {
86
+ "codemirror_mode": {
87
+ "name": "ipython",
88
+ "version": 3
89
+ },
90
+ "file_extension": ".py",
91
+ "mimetype": "text/x-python",
92
+ "name": "python",
93
+ "nbconvert_exporter": "python",
94
+ "pygments_lexer": "ipython3",
95
+ "version": "3.11.8"
96
+ }
97
+ },
98
+ "nbformat": 4,
99
+ "nbformat_minor": 2
100
+ }
pages/00_home.py CHANGED
@@ -6,7 +6,7 @@ def Page():
6
  with solara.Column(align="center"):
7
  markdown = """
8
  ## Earth Engine Web Apps
9
-
10
  ### Introduction
11
 
12
  **A collection of Earth Engine web apps developed using [Solara](https://github.com/widgetti/solara) and geemap**
@@ -15,7 +15,7 @@ def Page():
15
  - GitHub: <https://github.com/opengeos/solara-geemap>
16
  - Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geemap>
17
 
18
-
19
  ### How to deploy this app on Hugging Face Spaces
20
 
21
  1. Go to <https://huggingface.co/spaces/giswqs/solara-geemap/tree/main> and duplicate the space to your own space.
 
6
  with solara.Column(align="center"):
7
  markdown = """
8
  ## Earth Engine Web Apps
9
+
10
  ### Introduction
11
 
12
  **A collection of Earth Engine web apps developed using [Solara](https://github.com/widgetti/solara) and geemap**
 
15
  - GitHub: <https://github.com/opengeos/solara-geemap>
16
  - Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geemap>
17
 
18
+
19
  ### How to deploy this app on Hugging Face Spaces
20
 
21
  1. Go to <https://huggingface.co/spaces/giswqs/solara-geemap/tree/main> and duplicate the space to your own space.
pages/01_basic.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import geemap
2
+ import solara
3
+
4
+ zoom = solara.reactive(4)
5
+ center = solara.reactive((40, -100))
6
+ bounds = solara.reactive(None)
7
+
8
+
9
+ @solara.component
10
+ def Page():
11
+ # Isolation is required to prevent the map from overlapping navigation (when screen width < 960px)
12
+ with solara.Column(
13
+ style={"min-width": "500px", "height": "780px", "isolation": "isolate"}
14
+ ):
15
+ # solara components support reactive variables
16
+ solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
17
+ # using 3rd party widget library require wiring up the events manually
18
+ # using zoom.value and zoom.set
19
+ geemap.Map.element( # type: ignore
20
+ zoom=zoom.value,
21
+ on_zoom=zoom.set,
22
+ center=center.value,
23
+ on_center=center.set,
24
+ on_bounds=bounds.set,
25
+ scroll_wheel_zoom=True,
26
+ height="600px",
27
+ )
28
+ solara.Text(f"Zoom: {zoom.value}")
29
+ solara.Text(f"Center: {center.value}")
30
+ solara.Text(f"Bounds: {bounds.value}")
pages/02_inspector.py CHANGED
@@ -13,27 +13,27 @@ class Map(geemap.Map):
13
 
14
  def add_ee_data(self):
15
  # Add Earth Engine dataset
16
- dem = ee.Image('USGS/SRTMGL1_003')
17
- landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(
18
- ['B1', 'B2', 'B3', 'B4', 'B5', 'B7']
19
  )
20
  states = ee.FeatureCollection("TIGER/2018/States")
21
 
22
  # Set visualization parameters.
23
  vis_params = {
24
- 'min': 0,
25
- 'max': 4000,
26
- 'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
27
  }
28
 
29
  # Add Earth Engine layers to Map
30
  self.addLayer(
31
  landsat7,
32
- {'bands': ['B4', 'B3', 'B2'], 'min': 20, 'max': 200, 'gamma': 2.0},
33
- 'Landsat 7',
34
  True,
35
  )
36
- self.addLayer(dem, vis_params, 'SRTM DEM', True, 1)
37
  self.addLayer(states, {}, "US States")
38
 
39
 
 
13
 
14
  def add_ee_data(self):
15
  # Add Earth Engine dataset
16
+ dem = ee.Image("USGS/SRTMGL1_003")
17
+ landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003").select(
18
+ ["B1", "B2", "B3", "B4", "B5", "B7"]
19
  )
20
  states = ee.FeatureCollection("TIGER/2018/States")
21
 
22
  # Set visualization parameters.
23
  vis_params = {
24
+ "min": 0,
25
+ "max": 4000,
26
+ "palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
27
  }
28
 
29
  # Add Earth Engine layers to Map
30
  self.addLayer(
31
  landsat7,
32
+ {"bands": ["B4", "B3", "B2"], "min": 20, "max": 200, "gamma": 2.0},
33
+ "Landsat 7",
34
  True,
35
  )
36
+ self.addLayer(dem, vis_params, "SRTM DEM", True, 1)
37
  self.addLayer(states, {}, "US States")
38
 
39
 
pages/03_plotting.py CHANGED
@@ -11,23 +11,23 @@ class Map(geemap.Map):
11
  self.add_plot_gui()
12
 
13
  def add_ee_data(self):
14
- landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(
15
- ['B1', 'B2', 'B3', 'B4', 'B5', 'B7']
16
  )
17
 
18
- landsat_vis = {'bands': ['B4', 'B3', 'B2'], 'gamma': 1.4}
19
  self.addLayer(landsat7, landsat_vis, "Landsat")
20
 
21
- hyperion = ee.ImageCollection('EO1/HYPERION').filter(
22
- ee.Filter.date('2016-01-01', '2017-03-01')
23
  )
24
 
25
  hyperion_vis = {
26
- 'min': 1000.0,
27
- 'max': 14000.0,
28
- 'gamma': 2.5,
29
  }
30
- self.addLayer(hyperion, hyperion_vis, 'Hyperion')
31
 
32
 
33
  @solara.component
 
11
  self.add_plot_gui()
12
 
13
  def add_ee_data(self):
14
+ landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003").select(
15
+ ["B1", "B2", "B3", "B4", "B5", "B7"]
16
  )
17
 
18
+ landsat_vis = {"bands": ["B4", "B3", "B2"], "gamma": 1.4}
19
  self.addLayer(landsat7, landsat_vis, "Landsat")
20
 
21
+ hyperion = ee.ImageCollection("EO1/HYPERION").filter(
22
+ ee.Filter.date("2016-01-01", "2017-03-01")
23
  )
24
 
25
  hyperion_vis = {
26
+ "min": 1000.0,
27
+ "max": 14000.0,
28
+ "gamma": 2.5,
29
  }
30
+ self.addLayer(hyperion, hyperion_vis, "Hyperion")
31
 
32
 
33
  @solara.component
pages/04_split_map.py CHANGED
@@ -11,25 +11,25 @@ class Map(geemap.Map):
11
 
12
  def add_ee_data(self):
13
  # Select the eight NLCD epochs after 2000.
14
- years = ['2001', '2004', '2006', '2008', '2011', '2013', '2016', '2019']
15
 
16
  # Get an NLCD image by year.
17
  def getNLCD(year):
18
  # Import the NLCD collection.
19
- dataset = ee.ImageCollection('USGS/NLCD_RELEASES/2019_REL/NLCD')
20
 
21
  # Filter the collection by year.
22
- nlcd = dataset.filter(ee.Filter.eq('system:index', year)).first()
23
 
24
  # Select the land cover band.
25
- landcover = nlcd.select('landcover')
26
  return landcover
27
 
28
  ## Create an NLCD image collection for the selected years.
29
  collection = ee.ImageCollection(ee.List(years).map(lambda year: getNLCD(year)))
30
 
31
  # Create a list of labels to populate the dropdown list.
32
- labels = [f'NLCD {year}' for year in years]
33
 
34
  # Add a split-panel map for visualizing NLCD land cover change.
35
  self.ts_inspector(
@@ -41,7 +41,10 @@ class Map(geemap.Map):
41
 
42
  # Add the NLCD legend to the map.
43
  self.add_legend(
44
- title='NLCD Land Cover Type', builtin_legend='NLCD', height="460px", add_header=False
 
 
 
45
  )
46
 
47
 
 
11
 
12
  def add_ee_data(self):
13
  # Select the eight NLCD epochs after 2000.
14
+ years = ["2001", "2004", "2006", "2008", "2011", "2013", "2016", "2019"]
15
 
16
  # Get an NLCD image by year.
17
  def getNLCD(year):
18
  # Import the NLCD collection.
19
+ dataset = ee.ImageCollection("USGS/NLCD_RELEASES/2019_REL/NLCD")
20
 
21
  # Filter the collection by year.
22
+ nlcd = dataset.filter(ee.Filter.eq("system:index", year)).first()
23
 
24
  # Select the land cover band.
25
+ landcover = nlcd.select("landcover")
26
  return landcover
27
 
28
  ## Create an NLCD image collection for the selected years.
29
  collection = ee.ImageCollection(ee.List(years).map(lambda year: getNLCD(year)))
30
 
31
  # Create a list of labels to populate the dropdown list.
32
+ labels = [f"NLCD {year}" for year in years]
33
 
34
  # Add a split-panel map for visualizing NLCD land cover change.
35
  self.ts_inspector(
 
41
 
42
  # Add the NLCD legend to the map.
43
  self.add_legend(
44
+ title="NLCD Land Cover Type",
45
+ builtin_legend="NLCD",
46
+ height="460px",
47
+ add_header=False,
48
  )
49
 
50
 
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
  geemap
2
- solara
3
  geopandas
4
- pydantic< 2.0
 
 
1
  geemap
 
2
  geopandas
3
+ pydantic< 2.0
4
+ solara