Skip to content

Commit

Permalink
🙊
Browse files Browse the repository at this point in the history
  • Loading branch information
cboettig committed Dec 3, 2024
1 parent bca1779 commit e0eb606
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def bar_chart(gdf_name, rank, taxa, zoom, distinct_taxa = ""):
layer = HexagonLayer(url, v_scale)


m = leafmap.Map(style= terrain_style, center=[-120, 37.6], zoom=2, pitch=35, bearing=10)
m = leafmap.Map(style=terrain_styling(), center=[-120, 37.6], zoom=2, pitch=35, bearing=10)
if gdf is not None:
m.add_gdf(gdf[[gdf.geometry.name]], "fill", paint = {"fill-opacity": 0.2}) # adds area of interest & zooms in
m.add_pmtiles(mappinginequality, style=redlines, visible=True, opacity = 0.9, fit_bounds=False)
Expand Down
73 changes: 39 additions & 34 deletions utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def set_secrets(con):
if secret is None:
secret = st.secrets["MINIO_SECRET"]

ket = os.getenv("MINIO_KEY")
key = os.getenv("MINIO_KEY")
if key is None:
key = st.secrets["MINIO_KEY"]

Expand Down Expand Up @@ -136,40 +136,45 @@ def DeckGlobe(layer):
)
return deck

key = st.secrets['MAPTILER_KEY']
terrain_style = {
"version": 8,
"sources": {
"osm": {
"type": "raster",
"tiles": ["https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}.png"],
"tileSize": 256,
"attribution": "© National Geographic",
"maxzoom": 19,
},
"terrainSource": {
"type": "raster-dem",
"url": f"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key={key}",
"tileSize": 256,
},
"hillshadeSource": {
"type": "raster-dem",
"url": f"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key={key}",
"tileSize": 256,
},
},
"layers": [
{"id": "osm", "type": "raster", "source": "osm"},
{
"id": "hills",
"type": "hillshade",
"source": "hillshadeSource",
"layout": {"visibility": "visible"},
"paint": {"hillshade-shadow-color": "#473B24"},

def terrain_styling():
maptiler_key = os.getenv("MAPTILER_KEY")
if maptiler_key is None:
maptiler_key = st.secrets["MAPTILER_KEY"]
terrain_style = {
"version": 8,
"sources": {
"osm": {
"type": "raster",
"tiles": ["https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}.png"],
"tileSize": 256,
"attribution": "© National Geographic",
"maxzoom": 19,
},
"terrainSource": {
"type": "raster-dem",
"url": f"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key={maptiler_key}",
"tileSize": 256,
},
"hillshadeSource": {
"type": "raster-dem",
"url": f"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json?key={maptiler_key}",
"tileSize": 256,
},
},
],
"terrain": {"source": "terrainSource", "exaggeration": .1},
}
"layers": [
{"id": "osm", "type": "raster", "source": "osm"},
{
"id": "hills",
"type": "hillshade",
"source": "hillshadeSource",
"layout": {"visibility": "visible"},
"paint": {"hillshade-shadow-color": "#473B24"},
},
],
"terrain": {"source": "terrainSource", "exaggeration": .1},
}
return terrain_style
####


Expand Down

0 comments on commit e0eb606

Please sign in to comment.