Skip to content

A tool for assisting development and assessment of BM projects in POL. CAUTION: BETA version only

License

Notifications You must be signed in to change notification settings

captOverkill/Biomethane-Dev-POL

Repository files navigation

Polish Agricultural Map – Gmina-Level (Docker/HF-ready) v0.9BETA

Overview

Interactive Streamlit web app for visualizing Polish agricultural data at gmina level Upload or use bundled Excel files (livestock + crops) Upload or use bundled gmina boundaries (GeoJSON/JSON/ZIP Shapefile/GeoPackage) Two-way synced circle: Draw a circle on the map → inputs update Change inputs → circle updates and coverage recomputes Coverage: lists gminas where the circle covers >= threshold of area Choropleth: color by chosen metric (cattle, pigs, poultry, sown area, etc.) Search: address/town (geocoder), “locate me,” and search gmina by Name Export: covered gminas CSV Features

Fixed-height map (no “sliver” issue) Robust file handling for Docker/Hugging Face Spaces (uses uploads or bundled defaults) TERC detection for gmina codes (supports TERC, terc, JPT_KOD_JE) Geometry simplification for fast drawing; coverage uses full geometry in a metric CRS Project Structure

Dockerfile (no extension): builds and runs the app agri_map_app.py: Streamlit app (map, circle sync, coverage logic) requirements.txt: Python deps (Streamlit, Folium, streamlit-folium, GeoPandas, Shapely, pyproj, Pandas, NumPy, openpyxl) poland.municipalities.json: Gmina boundaries (fallback when no upload) Substrate_Poland.xlsx: Livestock (bundled fallback for data) Substrate_Poland_crop.xlsx: Crops (bundled fallback for data) .dockerignore (optional): to speed builds and reduce image size Quick Start (Docker – Local)

Prerequisites Install Docker Desktop Ensure the following files are in the project root: Dockerfile agri_map_app.py requirements.txt poland.municipalities.json (optional but recommended) Substrate_Poland.xlsx Substrate_Poland_crop.xlsx Build Windows/Intel: docker build -t agri-map:beta . Apple Silicon (M1/M2) – to build an Intel-compatible image: docker build --platform linux/amd64 -t agri-map:beta . Run docker run --rm -p 8501:8501 --name agri-map agri-map:beta Open http://localhost:8501 Update (after changes) docker build -t agri-map:beta . docker stop agri-map && docker rm agri-map docker run --rm -p 8501:8501 --name agri-map agri-map:beta Distribute to Teammates (No Installs Beyond Docker) Option A: Docker Hub

docker login docker tag agri-map:beta docker.io//agri-map:beta docker push docker.io//agri-map:beta Teammates run: docker pull docker.io//agri-map:beta docker run --rm -p 8501:8501 --name agri-map docker.io//agri-map:beta Option B: Google Drive (offline)

Save the image to a tar: docker save -o agri_map_beta.tar agri-map:beta (optional) gzip to reduce size Share agri_map_beta.tar (or .tar.gz) via Drive Teammates: docker load -i agri_map_beta.tar docker run --rm -p 8501:8501 --name agri-map agri-map:beta Hugging Face Spaces (Free Hosting)

Spaces → Create new Space → Runtime: Docker Connect to GitHub repo (or upload files directly) Include: Dockerfile agri_map_app.py requirements.txt poland.municipalities.json Substrate_Poland.xlsx Substrate_Poland_crop.xlsx Spaces builds and hosts the app → share the Space URL

Notes: If uploads behave oddly, the app falls back to bundled files (Dockerfile COPY ensures they’re present). Set “Simplify geometries” (sidebar) to 60–120 for performance; set to 0 for full fidelity. SharePoint Embedding (optional)

SharePoint can embed external apps via iframe Host on Azure Web App for Containers or other host (HTTPS required) Allow embedding by setting CSP header on the host: Content-Security-Policy: frame-ancestors https://axpo.sharepoint.com https://*.office.com; Then add an “Embed” web part with:<iframe src="https://" width="100%" height="900" frameborder="0"></iframe> Note: SharePoint admins may need to allow the external domain if restricted.

Data Requirements

Excel files: Substrate_Poland.xlsx (livestock; sheet TABLE) Substrate_Poland_crop.xlsx (crops; sheet TABLE) The app can also read uploaded Excel files (same structure). Boundaries: GeoJSON/JSON (with polygon features), zipped Shapefile (.zip), or GeoPackage (.gpkg) Must contain a 7-digit municipality code column; detection supports TERC, terc, JPT_KOD_JE Simplify (meters) only affects drawing; coverage uses full geometry in EPSG:2180 Two-Way Circle Sync

Draw a circle on the map (left toolbar): inputs (Latitude, Longitude, Radius) update instantly. Change inputs: the circle overlay updates on next rerun and coverage recomputes. Use geocoder (top-left) for address/town search; “locate me” to center the map to your position. Troubleshooting

“Failed to load Excel data: No such file or directory”

Ensure the bundled files exist (Substrate_Poland.xlsx, Substrate_Poland_crop.xlsx) in the image: Dockerfile must include: COPY Substrate_Poland.xlsx /app/ COPY Substrate_Poland_crop.xlsx /app/ Or upload Excel files in the sidebar. Boundaries not displaying or no LayerControl toggles

Ensure poland.municipalities.json loads (debug shows “Boundaries loaded: bbox: (…)”). Lower “Simplify geometries (meters)” to 0–60 if polygons are very small or complex. LayerControl appears after overlays are added (app does this automatically). Map height is a thin sliver

This build uses fixed numeric sizes (MAP_WIDTH, MAP_HEIGHT) in both Folium and st_folium to avoid slivers. Do not switch to use_container_width=True for the maps. Gmina code detection fails

Your file must have a 7-digit TERC-like code; detection supports TERC, terc, or JPT_KOD_JE. Rename the column if needed. Apple Silicon multi-arch image

Build Intel-compatible image on M1/M2 for flexibility: docker build --platform linux/amd64 -t agri-map:beta . Configuration

Adjust map size inside agri_map_app.py: MAP_WIDTH = 1280 MAP_HEIGHT = 820 Change default fallback paths as needed (see DEFAULT_LIVE/DEFAULT_CROP in the app). Security/Privacy

The app runs locally (Docker) or on the selected hosting service (Spaces). No telemetry is enabled (STREAMLIT_BROWSER_GATHERUSAGESTATS=false). Uploaded files are processed in-memory; with Spaces, they are handled by the app session. Contact/Support

For deployment (Azure/App Service) or SharePoint embedding, coordinate with IT to set CSP headers (frame-ancestors) on the host. For general questions or bugs, update the repo README and raise issues in GitHub, or share the Docker image via Drive for reproducible testing. GitHub Repository: https://github.com/captOverkill/Biomethane-Dev-POL

Changelog

v0.9 Beta: Two-way circle sync; bundled Excel & boundaries; Docker/HF-ready build; address/gmina search; choropleth + coverage export.

About

A tool for assisting development and assessment of BM projects in POL. CAUTION: BETA version only

Resources

License

Stars

Watchers

Forks

Packages

No packages published