From e497c1be1bdd1e3e8484587588dbb87eeeae8436 Mon Sep 17 00:00:00 2001 From: "plinio@fused.io" Date: Wed, 29 Jan 2025 19:10:19 +0000 Subject: [PATCH] Zonal stats viewer app --- public/Zonal_Stats_Forest_App/README.MD | 6 ++ .../Zonal_Stats_Forest_App.py | 41 +++++++++ public/Zonal_Stats_Forest_App/meta.json | 90 +++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 public/Zonal_Stats_Forest_App/README.MD create mode 100644 public/Zonal_Stats_Forest_App/Zonal_Stats_Forest_App.py create mode 100644 public/Zonal_Stats_Forest_App/meta.json diff --git a/public/Zonal_Stats_Forest_App/README.MD b/public/Zonal_Stats_Forest_App/README.MD new file mode 100644 index 0000000..b36000a --- /dev/null +++ b/public/Zonal_Stats_Forest_App/README.MD @@ -0,0 +1,6 @@ + +

UDF preview image

+ + +# View Forest Observation zonal stats + diff --git a/public/Zonal_Stats_Forest_App/Zonal_Stats_Forest_App.py b/public/Zonal_Stats_Forest_App/Zonal_Stats_Forest_App.py new file mode 100644 index 0000000..556c7d6 --- /dev/null +++ b/public/Zonal_Stats_Forest_App/Zonal_Stats_Forest_App.py @@ -0,0 +1,41 @@ +import micropip +await micropip.install(['pydeck']) + +import streamlit as st +import pydeck as pdk + +st.title("🌲 Zonal Stats of Forest observations by global municipalities") + +st.markdown(""" +This app shows the output of a workflow to quantify forest cover for municipal areas around the world. The workflow aggregates a raster of global forest cover across zones defined by a vector table of municipalities. + +The final result, which you see here, is a table with records for every municipality and columns with summary metrics such as percent forest coverage. This type of analysis can help identify regions with significant forest loss to prioritize conservation efforts or support sustainable land-use planning. + +""") + +url="https://www.fused.io/server/v1/realtime-shared/UDF_Zonal_Stats_Forest_Obs_Viewer/run/tiles/{z}/{x}/{y}?dtype_out_vector=geojson" + + +lat, lng = 28.3949, 84.1240 + +st.pydeck_chart( + pdk.Deck( + map_style="mapbox://styles/mapbox/dark-v9", + initial_view_state=pdk.ViewState(latitude=lat, longitude=lng, zoom=5, pitch=0, bearing=-6), + tooltip={"html": "Value: {stats_mean}","style": {"backgroundColor": "steelblue", "color": "white"},}, + layers=[ + pdk.Layer( + "TileLayer", + data=url, + get_line_color=[255, 25, 2, 1000], + get_elevation="properties.stats_mean", + stroked=True, + get_line_width=2, + pickable=True, + extruded=True, + filled=True, + get_fill_color="[properties.stats_mean*25, properties.stats_mean*256, properties.stats_mean*25]", + ) + ], + ) +) diff --git a/public/Zonal_Stats_Forest_App/meta.json b/public/Zonal_Stats_Forest_App/meta.json new file mode 100644 index 0000000..72007f1 --- /dev/null +++ b/public/Zonal_Stats_Forest_App/meta.json @@ -0,0 +1,90 @@ +{ + "version": "0.0.3", + "job_config": { + "version": "0.0.3", + "name": null, + "steps": [ + { + "type": "udf", + "udf": { + "type": "geopandas_v2", + "name": "Zonal_Stats_Forest_App", + "entrypoint": "udf", + "parameters": {}, + "metadata": { + "fused:name": "Zonal_Stats_Forest_App", + "fused:slug": "Zonal_Stats_Forest_App", + "fused:gitRepo": "fusedlabs/fusedudfs", + "fused:gitRef": "1658a5ac8c85e3240a1c1a01945ba4d090b0a853", + "fused:gitUrl": "https://github.com/fusedlabs/fusedudfs/tree/1658a5ac8c85e3240a1c1a01945ba4d090b0a853/Zonal_Stats_Forest_App/", + "fused:gitShortUrl": "https://github.com/fusedlabs/fusedudfs/tree/1658a5a/Zonal_Stats_Forest_App/", + "fused:gitPath": "Zonal_Stats_Forest_App", + "fused:gitLastModified": "2025-01-28T13:41:46+00:00", + "fused:gitPullRequestBranch": "plinio-patch-1ba1ae-Zonal-stats-forest-app", + "fused:gitPullRequestLink": "https://github.com/fusedlabs/fusedudfs/pull/527", + "fused:vizConfig": { + "tileLayer": { + "@@type": "TileLayer", + "minZoom": 0, + "maxZoom": 19, + "tileSize": 256 + }, + "rasterLayer": { + "@@type": "BitmapLayer", + "pickable": true + }, + "vectorLayer": { + "@@type": "GeoJsonLayer", + "stroked": true, + "filled": false, + "pickable": true, + "lineWidthMinPixels": 1, + "pointRadiusMinPixels": 1, + "getLineColor": { + "@@function": "colorContinuous", + "attr": "value", + "domain": [ + 0, + 10 + ], + "colors": "SunsetDark", + "nullColor": [ + 184, + 184, + 184 + ] + }, + "getFillColor": [ + 208, + 208, + 208, + 40 + ] + } + }, + "fused:udfType": "app", + "fused:id": null, + "fused:description": "# View Forest Observation zonal stats \n\n", + "fused:gitAuthorNames": [ + null + ], + "fused:gitAuthorUsernames": [ + "fused-io[bot]" + ], + "fused:gitAuthorUrls": [ + "https://github.com/apps/fused-io" + ], + "fused:gitAuthorAvatarUrls": [ + "https://avatars.githubusercontent.com/in/834700?v=4" + ], + "fused:explorerTab": "team", + "fused:assetUrl": "https://fused-magic.s3.us-west-2.amazonaws.com/blog-assets/zstats_viewer_mx.png" + }, + "source": "Zonal_Stats_Forest_App.py", + "headers": [] + } + } + ], + "metadata": null + } +} \ No newline at end of file