├── .gitignore ├── LICENSE ├── README.md ├── app.py ├── pages ├── basemap.py └── nlcd_demo.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 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 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 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 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Qiusheng Wu 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # geemap-apps 2 | 3 | ## Introduction 4 | 5 | This repo demostrates how to build a multi-page [Earth Engine](https://earthengine.google.com) App using [streamlit](https://streamlit.io) and [geemap](https://geemap.org). You can deploy the app on various cloud platforms, such as [share.streamlit.io](https://share.streamlit.io). Make sure you set `EARTHENGINE_TOKEN='your-token'` as an environment variable (secret) on the cloud platform. 6 | 7 | - **Web App:** 8 | - **Github:** 9 | 10 | ### Where to find your Earth Engine token? 11 | 12 | - **Windows:** `C:/Users/USERNAME/.config/earthengine/credentials` 13 | - **Linux:** `/home/USERNAME/.config/earthengine/credentials` 14 | - **macOS:** `/Users/USERNAME/.config/earthengine/credentials` 15 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | import geemap.foliumap as geemap 3 | 4 | st.set_page_config(layout="wide") 5 | 6 | # Customize the sidebar 7 | markdown = """ 8 | Web App URL: 9 | """ 10 | 11 | st.sidebar.title("About") 12 | st.sidebar.info(markdown) 13 | logo = "https://i.imgur.com/UbOXYAU.png" 14 | st.sidebar.image(logo) 15 | 16 | # Customize page title 17 | st.title("Earth Engine Web App") 18 | 19 | st.markdown( 20 | """ 21 | This multipage app template demonstrates various interactive web apps created using [streamlit](https://streamlit.io) and [geemap](https://geemap.org). It is an open-source project and you are very welcome to contribute to the [GitHub repository](https://github.com/giswqs/geemap-apps). 22 | """ 23 | ) 24 | 25 | st.header("Instructions") 26 | 27 | markdown = """ 28 | 1. For the [GitHub repository](https://github.com/giswqs/geemap-apps) or [use it as a template](https://github.com/new?template_name=geemap-apps&template_owner=giswqs) for your own project. 29 | 2. Customize the sidebar by changing the sidebar text and logo in each Python files. 30 | 3. Find your favorite emoji from https://emojipedia.org. 31 | 4. Add a new app to the `pages/` directory with an emoji in the file name, e.g., `1_🚀_Chart.py`. 32 | """ 33 | 34 | st.markdown(markdown) 35 | 36 | m = geemap.Map() 37 | m.add_basemap("OpenTopoMap") 38 | m.to_streamlit(height=500) -------------------------------------------------------------------------------- /pages/basemap.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | import geemap.foliumap as geemap 3 | 4 | st.title("Interactive Map") 5 | 6 | col1, col2 = st.columns([4, 1]) 7 | options = list(geemap.basemaps.keys()) 8 | index = options.index("OpenTopoMap") 9 | 10 | with col2: 11 | 12 | basemap = st.selectbox("Select a basemap:", options, index) 13 | 14 | 15 | with col1: 16 | 17 | m = geemap.Map() 18 | m.add_basemap(basemap) 19 | m.to_streamlit(height=700) 20 | -------------------------------------------------------------------------------- /pages/nlcd_demo.py: -------------------------------------------------------------------------------- 1 | import ee 2 | import streamlit as st 3 | import geemap.foliumap as geemap 4 | 5 | # Get an NLCD image by year. 6 | def getNLCD(year): 7 | # Import the NLCD collection. 8 | dataset = ee.ImageCollection("USGS/NLCD_RELEASES/2019_REL/NLCD") 9 | 10 | # Filter the collection by year. 11 | nlcd = dataset.filter(ee.Filter.eq("system:index", year)).first() 12 | 13 | # Select the land cover band. 14 | landcover = nlcd.select("landcover") 15 | return landcover 16 | 17 | 18 | st.header("National Land Cover Database (NLCD)") 19 | 20 | # Create a layout containing two columns, one for the map and one for the layer dropdown list. 21 | row1_col1, row1_col2 = st.columns([3, 1]) 22 | 23 | # Create an interactive map 24 | Map = geemap.Map(center=[40, -100], zoom=4) 25 | 26 | # Select the seven NLCD epochs after 2000. 27 | years = ["2001", "2004", "2006", "2008", "2011", "2013", "2016", "2019"] 28 | 29 | # Add a dropdown list and checkbox to the second column. 30 | with row1_col2: 31 | selected_year = st.multiselect("Select a year", years) 32 | add_legend = st.checkbox("Show legend") 33 | 34 | # Add selected NLCD image to the map based on the selected year. 35 | if selected_year: 36 | for year in selected_year: 37 | Map.addLayer(getNLCD(year), {}, "NLCD " + year) 38 | 39 | if add_legend: 40 | Map.add_legend( 41 | title="NLCD Land Cover Classification", builtin_legend="NLCD" 42 | ) 43 | with row1_col1: 44 | Map.to_streamlit(height=600) 45 | 46 | else: 47 | with row1_col1: 48 | Map.to_streamlit(height=600) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | geemap 2 | streamlit 3 | 4 | --------------------------------------------------------------------------------