github-actions[bot]
Deploy Streamlit Space
843b944
Raw History Blame Contribute Delete
4.77 kB
Metadata-Version: 2.4
Name: spatial-toolkit-py
Version: 0.0.1
Summary: Lightweight spatial tools for ecologists in Python
Author-email: Abhimanyu Raj Singh <abhimanyu@example.com>
License: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: folium
Requires-Dist: geopandas
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: rasterio
Requires-Dist: rioxarray
Requires-Dist: shapely
Requires-Dist: streamlit
Requires-Dist: streamlit-folium
Requires-Dist: xarray
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file
# spatial_toolkit
`spatial_toolkit` is a dual-track spatial toolkit for ecologists. The repository
now carries:
- an R package plus Shiny app
- a Python package plus Streamlit app
- shared project memory and step-by-step learning notes
The intent is practical and educational at the same time: build a useful GIS
toolkit for ecology while preserving enough context that a first-time package
author can understand how the repo was assembled and maintained.
## Scope
The current scaffold includes:
- Raster and vector conversions
- Rasterisation, vectorisation, and reclassification
- Raster QC and metadata inspection
- Common ecological GIS helpers such as crop, mask, and reprojection
- Reusable workflows for repeated data processing
- A Shiny app shell for map review, metadata inspection, and attribute tables
- A Streamlit app shell for the same core use cases
## Why both R and Python
The short answer is: both is reasonable, but they should not be treated equally
at every phase.
- R is the better first implementation here because your requested GIS stack
already maps naturally to `terra`, `sf`, `raster`, and Shiny.
- Python is worth adding because deployment, packaging, and broader data-science
interoperability are often easier with `streamlit`, `rasterio`, `geopandas`,
and `xarray`.
- The safest strategy is to keep one reference implementation first, then build
a parallel implementation with the same concepts and workflows.
That is the approach this repository now follows: R is the reference track and
Python is the parallel native track.
## Product shape
The repository is structured so the same codebase can support:
- An R package
- A local or hosted Shiny app
- A Python package
- A local or hosted Streamlit app
- Reusable workflow functions for scripted batch processing
## Repository layout
- `R/`: reusable R spatial functions and Shiny app wiring
- `python/spatial_toolkit_py/`: reusable Python spatial functions
- `python/app.py`: Streamlit app entrypoint
- `inst/app/www/`: Shiny styling assets
- `tests/`: R tests
- `pytests/`: Python tests
- `memory.txt`: shared project memory and roadmap
- `memopy.txt`: Python-specific maintenance memory
- `R.md`: step-by-step notes for building the R package/app
- `PY.md`: step-by-step notes for building the Python package/app
- `Dockerfile`: container entrypoint for the R app
- `Dockerfile.py`: container entrypoint for the Python app
## R install
```r
# install.packages("pak")
pak::pak(c(
"shiny",
"bslib",
"leaflet",
"DT",
"terra",
"sf",
"raster"
))
```
## Python install
```bash
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
```
## Run the R app
```r
source("app.R")
```
Or after installing as a package:
```r
spatialtoolkit::run_app()
```
Or from the shell:
```bash
bash run_shiny_local.sh
```
Local URL:
```text
http://127.0.0.1:7860
```
## Run the Python app
```bash
streamlit run python/app.py
```
Or with the fixed local port script:
```bash
bash run_streamlit_local.sh
```
Local URL:
```text
http://127.0.0.1:8501
```
## Initial workflows
The first workflow catalogs focus on raster QC:
- CRS presence
- Resolution
- Extent
- Band count
- Layer names
- Missing values
- Numeric summaries
This can be extended into ecological pre-processing pipelines such as harmonise,
crop to study area, standardise CRS, and export derivative products.
## Deployment direction
Both apps can be deployed to Hugging Face Spaces using Docker:
- `Dockerfile` for the R/Shiny track
- `Dockerfile.py` for the Python/Streamlit track
If we want one public hosted app first, Python/Streamlit is often the simpler
deployment target. If we want the strongest spatial processing foundation first,
R remains the better implementation anchor.
## Learning documents
This repository also doubles as a build log:
- [R.md](R.md) explains how the R package/app was scaffolded
- [PY.md](PY.md) explains how the Python package/app was scaffolded
- [memory.txt](memory.txt) tracks decisions, features, and dependencies
- [memopy.txt](memopy.txt) tracks Python-specific implementation notes