├── .gitignore ├── LICENSE ├── Procfile ├── README.md ├── app.py ├── requirements.txt └── setup.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | .vscode/ 9 | 10 | # Distribution / packaging 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | pip-wheel-metadata/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .nox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | *.py,cover 52 | .hypothesis/ 53 | .pytest_cache/ 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | db.sqlite3-journal 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | 75 | # PyBuilder 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | .python-version 87 | 88 | # pipenv 89 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 90 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 91 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 92 | # install all needed dependencies. 93 | #Pipfile.lock 94 | 95 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 96 | __pypackages__/ 97 | 98 | # Celery stuff 99 | celerybeat-schedule 100 | celerybeat.pid 101 | 102 | # SageMath parsed files 103 | *.sage.py 104 | 105 | # Environments 106 | .env 107 | .venv 108 | env/ 109 | venv/ 110 | ENV/ 111 | env.bak/ 112 | venv.bak/ 113 | 114 | # Spyder project settings 115 | .spyderproject 116 | .spyproject 117 | 118 | # Rope project settings 119 | .ropeproject 120 | 121 | # mkdocs documentation 122 | /site 123 | 124 | # mypy 125 | .mypy_cache/ 126 | .dmypy.json 127 | dmypy.json 128 | 129 | # Pyre type checker 130 | .pyre/ 131 | .streamlit/secrets.toml 132 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 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 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: sh setup.sh && streamlit run app.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # leafmap-streamlit 2 | 3 | 4 | See [Secrets Management](https://www.notion.so/Secrets-Management-730c82af2fc048d383d668c4049fb9bf) for adding environment variables to streamlit. 5 | 6 | ![](https://i.imgur.com/9ifDaJo.png) -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | """Run 'streamlit run app.py' in the terminal to start the app. 2 | """ 3 | import streamlit as st 4 | 5 | # st.set_page_config(layout="wide") 6 | 7 | "# leafmap streamlit demo" 8 | st.markdown('Source code: ') 9 | 10 | "## Create a 3D map using Kepler.gl" 11 | with st.echo(): 12 | import streamlit as st 13 | import leafmap.kepler as leafmap 14 | 15 | m = leafmap.Map(center=[37.7621, -122.4143], zoom=12) 16 | in_csv = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/hex_data.csv' 17 | config = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/hex_config.json' 18 | m.add_csv(in_csv, layer_name="hex_data", config=config) 19 | m.to_streamlit() 20 | 21 | 22 | "## Create a heat map" 23 | with st.echo(): 24 | import leafmap.foliumap as leafmap 25 | 26 | filepath = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/us_cities.csv" 27 | m = leafmap.Map(tiles='stamentoner') 28 | m.add_heatmap(filepath, latitude="latitude", longitude='longitude', value="pop_max", name="Heat map", radius=20) 29 | m.to_streamlit(width=700, height=500, add_layer_control=True) 30 | 31 | 32 | "## Load a GeoJSON file" 33 | with st.echo(): 34 | 35 | m = leafmap.Map(center=[0, 0], zoom=2) 36 | in_geojson = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/cable-geo.geojson' 37 | m.add_geojson(in_geojson, layer_name="Cable lines") 38 | m.to_streamlit() 39 | 40 | 41 | "## Add a colorbar" 42 | with st.echo(): 43 | 44 | m = leafmap.Map() 45 | m.add_basemap('USGS 3DEP Elevation') 46 | colors = ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'] 47 | vmin = 0 48 | vmax = 4000 49 | m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax) 50 | m.to_streamlit() 51 | 52 | 53 | "## Change basemaps" 54 | with st.echo(): 55 | m = leafmap.Map() 56 | m.add_basemap("Esri.NatGeoWorldMap") 57 | m.to_streamlit() 58 | 59 | 60 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | streamlit 2 | streamlit-folium 3 | streamlit-keplergl 4 | git+git://github.com/giswqs/whitebox 5 | git+git://github.com/giswqs/leafmap -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | 2 | mkdir -p ~/.streamlit/ 3 | echo "[general] 4 | email = \"giswqs@gmail.com\" 5 | " > ~/.streamlit/credentials.toml 6 | echo "[server] 7 | headless = true 8 | port = $PORT 9 | enableCORS = false 10 | " > ~/.streamlit/config.toml --------------------------------------------------------------------------------