giswqs commited on
Commit
d880abe
Β·
1 Parent(s): e696076

Add pre-commit

Browse files
.pre-commit-config.yaml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.4.2
16
+ hooks:
17
+ - id: black-jupyter
18
+ language_version: python3.11
19
+
20
+ # - repo: https://github.com/codespell-project/codespell
21
+ # rev: v2.3.0
22
+ # hooks:
23
+ # - id: codespell
24
+ # args: [--toml, pyproject-codespell.precommit-toml]
25
+
26
+ - repo: https://github.com/kynan/nbstripout
27
+ rev: 0.7.1
28
+ hooks:
29
+ - id: nbstripout
Home.py CHANGED
@@ -32,9 +32,9 @@ st.title("Streamlit for Geospatial Applications")
32
 
33
  st.markdown(
34
  """
35
- This multi-page web app demonstrates various interactive web apps created using [streamlit](https://streamlit.io) and open-source mapping libraries,
36
  such as [leafmap](https://leafmap.org), [geemap](https://geemap.org), [pydeck](https://deckgl.readthedocs.io), and [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter).
37
- This is an open-source project and you are very welcome to contribute your comments, questions, resources, and apps as [issues](https://github.com/giswqs/streamlit-geospatial/issues) or
38
  [pull requests](https://github.com/giswqs/streamlit-geospatial/pulls) to the [GitHub repository](https://github.com/giswqs/streamlit-geospatial).
39
 
40
  """
 
32
 
33
  st.markdown(
34
  """
35
+ This multi-page web app demonstrates various interactive web apps created using [streamlit](https://streamlit.io) and open-source mapping libraries,
36
  such as [leafmap](https://leafmap.org), [geemap](https://geemap.org), [pydeck](https://deckgl.readthedocs.io), and [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter).
37
+ This is an open-source project and you are very welcome to contribute your comments, questions, resources, and apps as [issues](https://github.com/giswqs/streamlit-geospatial/issues) or
38
  [pull requests](https://github.com/giswqs/streamlit-geospatial/pulls) to the [GitHub repository](https://github.com/giswqs/streamlit-geospatial).
39
 
40
  """
data/html/sfo_buildings.html CHANGED
@@ -17,9 +17,9 @@
17
  // Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
18
  const viewer = new Cesium.Viewer('cesiumContainer', {
19
  terrainProvider: Cesium.createWorldTerrain()
20
- });
21
  // Add Cesium OSM Buildings, a global 3D buildings layer.
22
- const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
23
  // Fly the camera to San Francisco at the given longitude, latitude, and height.
24
  viewer.camera.flyTo({
25
  destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
 
17
  // Initialize the Cesium Viewer in the HTML element with the `cesiumContainer` ID.
18
  const viewer = new Cesium.Viewer('cesiumContainer', {
19
  terrainProvider: Cesium.createWorldTerrain()
20
+ });
21
  // Add Cesium OSM Buildings, a global 3D buildings layer.
22
+ const buildingTileset = viewer.scene.primitives.add(Cesium.createOsmBuildings());
23
  // Fly the camera to San Francisco at the given longitude, latitude, and height.
24
  viewer.camera.flyTo({
25
  destination : Cesium.Cartesian3.fromDegrees(-122.4175, 37.655, 400),
pages/10_🌍_Earth_Engine_Datasets.py CHANGED
@@ -80,8 +80,7 @@ def search_data():
80
 
81
  dataset = None
82
  with col2:
83
- keyword = st.text_input(
84
- "Enter a keyword to search (e.g., elevation)", "")
85
  if keyword:
86
  ee_assets = geemap.search_ee_data(keyword)
87
  asset_titles = [x["title"] for x in ee_assets]
@@ -103,8 +102,7 @@ def search_data():
103
  with st.expander("Show dataset details", True):
104
  index = asset_titles.index(dataset)
105
 
106
- html = geemap.ee_data_html(
107
- st.session_state["ee_assets"][index])
108
  html = html.replace("\n", "")
109
  st.markdown(html, True)
110
 
@@ -125,8 +123,7 @@ def search_data():
125
  vis_params = "{}"
126
  vis = eval(vis_params)
127
  if not isinstance(vis, dict):
128
- st.error(
129
- "Visualization parameters must be a dictionary")
130
  try:
131
  Map.addLayer(eval(ee_asset), vis, layer_name)
132
  except Exception as e:
@@ -144,8 +141,7 @@ def search_data():
144
  def app():
145
  st.title("Earth Engine Data Catalog")
146
 
147
- apps = ["Search Earth Engine Data Catalog",
148
- "National Land Cover Database (NLCD)"]
149
 
150
  selected_app = st.selectbox("Select an app", apps)
151
 
 
80
 
81
  dataset = None
82
  with col2:
83
+ keyword = st.text_input("Enter a keyword to search (e.g., elevation)", "")
 
84
  if keyword:
85
  ee_assets = geemap.search_ee_data(keyword)
86
  asset_titles = [x["title"] for x in ee_assets]
 
102
  with st.expander("Show dataset details", True):
103
  index = asset_titles.index(dataset)
104
 
105
+ html = geemap.ee_data_html(st.session_state["ee_assets"][index])
 
106
  html = html.replace("\n", "")
107
  st.markdown(html, True)
108
 
 
123
  vis_params = "{}"
124
  vis = eval(vis_params)
125
  if not isinstance(vis, dict):
126
+ st.error("Visualization parameters must be a dictionary")
 
127
  try:
128
  Map.addLayer(eval(ee_asset), vis, layer_name)
129
  except Exception as e:
 
141
  def app():
142
  st.title("Earth Engine Data Catalog")
143
 
144
+ apps = ["Search Earth Engine Data Catalog", "National Land Cover Database (NLCD)"]
 
145
 
146
  selected_app = st.selectbox("Select an app", apps)
147
 
pages/1_πŸ“·_Timelapse.py CHANGED
@@ -236,8 +236,8 @@ def app():
236
 
237
  st.markdown(
238
  """
239
- An interactive web app for creating [Landsat](https://developers.google.com/earth-engine/datasets/catalog/landsat)/[GOES](https://jstnbraaten.medium.com/goes-in-earth-engine-53fbc8783c16) timelapse for any location around the globe.
240
- The app was built using [streamlit](https://streamlit.io), [geemap](https://geemap.org), and [Google Earth Engine](https://earthengine.google.com). For more info, check out my streamlit [blog post](https://blog.streamlit.io/creating-satellite-timelapse-with-streamlit-and-earth-engine).
241
  """
242
  )
243
 
@@ -413,13 +413,13 @@ def app():
413
  MODIS_options = ["Daytime (1:30 pm)", "Nighttime (1:30 am)"]
414
  MODIS_option = st.selectbox("Select a MODIS dataset:", MODIS_options)
415
  if MODIS_option == "Daytime (1:30 pm)":
416
- st.session_state[
417
- "ee_asset_id"
418
- ] = "projects/sat-io/open-datasets/gap-filled-lst/gf_day_1km"
419
  else:
420
- st.session_state[
421
- "ee_asset_id"
422
- ] = "projects/sat-io/open-datasets/gap-filled-lst/gf_night_1km"
423
 
424
  palette_options = st.selectbox(
425
  "Color palette",
 
236
 
237
  st.markdown(
238
  """
239
+ An interactive web app for creating [Landsat](https://developers.google.com/earth-engine/datasets/catalog/landsat)/[GOES](https://jstnbraaten.medium.com/goes-in-earth-engine-53fbc8783c16) timelapse for any location around the globe.
240
+ The app was built using [streamlit](https://streamlit.io), [geemap](https://geemap.org), and [Google Earth Engine](https://earthengine.google.com). For more info, check out my streamlit [blog post](https://blog.streamlit.io/creating-satellite-timelapse-with-streamlit-and-earth-engine).
241
  """
242
  )
243
 
 
413
  MODIS_options = ["Daytime (1:30 pm)", "Nighttime (1:30 am)"]
414
  MODIS_option = st.selectbox("Select a MODIS dataset:", MODIS_options)
415
  if MODIS_option == "Daytime (1:30 pm)":
416
+ st.session_state["ee_asset_id"] = (
417
+ "projects/sat-io/open-datasets/gap-filled-lst/gf_day_1km"
418
+ )
419
  else:
420
+ st.session_state["ee_asset_id"] = (
421
+ "projects/sat-io/open-datasets/gap-filled-lst/gf_night_1km"
422
+ )
423
 
424
  palette_options = st.selectbox(
425
  "Color palette",
pages/2_🏠_U.S._Housing.py CHANGED
@@ -225,7 +225,7 @@ def app():
225
  st.title("U.S. Real Estate Data and Market Trends")
226
  st.markdown(
227
  """**Introduction:** This interactive dashboard is designed for visualizing U.S. real estate data and market trends at multiple levels (i.e., national,
228
- state, county, and metro). The data sources include [Real Estate Data](https://www.realtor.com/research/data) from realtor.com and
229
  [Cartographic Boundary Files](https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html) from U.S. Census Bureau.
230
  Several open-source packages are used to process the data and generate the visualizations, e.g., [streamlit](https://streamlit.io),
231
  [geopandas](https://geopandas.org), [leafmap](https://leafmap.org), and [pydeck](https://deckgl.readthedocs.io).
 
225
  st.title("U.S. Real Estate Data and Market Trends")
226
  st.markdown(
227
  """**Introduction:** This interactive dashboard is designed for visualizing U.S. real estate data and market trends at multiple levels (i.e., national,
228
+ state, county, and metro). The data sources include [Real Estate Data](https://www.realtor.com/research/data) from realtor.com and
229
  [Cartographic Boundary Files](https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html) from U.S. Census Bureau.
230
  Several open-source packages are used to process the data and generate the visualizations, e.g., [streamlit](https://streamlit.io),
231
  [geopandas](https://geopandas.org), [leafmap](https://leafmap.org), and [pydeck](https://deckgl.readthedocs.io).
pages/3_πŸͺŸ_Split_Map.py CHANGED
@@ -24,8 +24,8 @@ with st.expander("See source code"):
24
  with st.echo():
25
  m = leafmap.Map()
26
  m.split_map(
27
- left_layer='ESA WorldCover 2020 S2 FCC', right_layer='ESA WorldCover 2020'
28
  )
29
- m.add_legend(title='ESA Land Cover', builtin_legend='ESA_WorldCover')
30
 
31
  m.to_streamlit(height=700)
 
24
  with st.echo():
25
  m = leafmap.Map()
26
  m.split_map(
27
+ left_layer="ESA WorldCover 2020 S2 FCC", right_layer="ESA WorldCover 2020"
28
  )
29
+ m.add_legend(title="ESA Land Cover", builtin_legend="ESA_WorldCover")
30
 
31
  m.to_streamlit(height=700)
pages/5_πŸ“_Marker_Cluster.py CHANGED
@@ -24,16 +24,16 @@ with st.expander("See source code"):
24
  with st.echo():
25
 
26
  m = leafmap.Map(center=[40, -100], zoom=4)
27
- cities = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/us_cities.csv'
28
- regions = 'https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/us_regions.geojson'
29
 
30
- m.add_geojson(regions, layer_name='US Regions')
31
  m.add_points_from_xy(
32
  cities,
33
  x="longitude",
34
  y="latitude",
35
- color_column='region',
36
- icon_names=['gear', 'map', 'leaf', 'globe'],
37
  spin=True,
38
  add_legend=True,
39
  )
 
24
  with st.echo():
25
 
26
  m = leafmap.Map(center=[40, -100], zoom=4)
27
+ cities = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/us_cities.csv"
28
+ regions = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/us_regions.geojson"
29
 
30
+ m.add_geojson(regions, layer_name="US Regions")
31
  m.add_points_from_xy(
32
  cities,
33
  x="longitude",
34
  y="latitude",
35
+ color_column="region",
36
+ icon_names=["gear", "map", "leaf", "globe"],
37
  spin=True,
38
  add_legend=True,
39
  )
pages/6_πŸ—ΊοΈ_Basemaps.py CHANGED
@@ -23,7 +23,7 @@ def app():
23
  st.title("Search Basemaps")
24
  st.markdown(
25
  """
26
- This app is a demonstration of searching and loading basemaps from [xyzservices](https://github.com/geopandas/xyzservices) and [Quick Map Services (QMS)](https://github.com/nextgis/quickmapservices). Selecting from 1000+ basemaps with a few clicks.
27
  """
28
  )
29
 
@@ -48,8 +48,7 @@ def app():
48
  if qms is not None:
49
  options = options + qms
50
 
51
- tiles = empty.multiselect(
52
- "Select XYZ tiles to add to the map:", options)
53
 
54
  with row1_col1:
55
  m = leafmap.Map()
 
23
  st.title("Search Basemaps")
24
  st.markdown(
25
  """
26
+ This app is a demonstration of searching and loading basemaps from [xyzservices](https://github.com/geopandas/xyzservices) and [Quick Map Services (QMS)](https://github.com/nextgis/quickmapservices). Selecting from 1000+ basemaps with a few clicks.
27
  """
28
  )
29
 
 
48
  if qms is not None:
49
  options = options + qms
50
 
51
+ tiles = empty.multiselect("Select XYZ tiles to add to the map:", options)
 
52
 
53
  with row1_col1:
54
  m = leafmap.Map()
pages/7_πŸ“¦_Web_Map_Service.py CHANGED
@@ -30,8 +30,8 @@ def app():
30
  st.title("Web Map Service (WMS)")
31
  st.markdown(
32
  """
33
- This app is a demonstration of loading Web Map Service (WMS) layers. Simply enter the URL of the WMS service
34
- in the text box below and press Enter to retrieve the layers. Go to https://apps.nationalmap.gov/services to find
35
  some WMS URLs if needed.
36
  """
37
  )
 
30
  st.title("Web Map Service (WMS)")
31
  st.markdown(
32
  """
33
+ This app is a demonstration of loading Web Map Service (WMS) layers. Simply enter the URL of the WMS service
34
+ in the text box below and press Enter to retrieve the layers. Go to https://apps.nationalmap.gov/services to find
35
  some WMS URLs if needed.
36
  """
37
  )