This application processes ShapeFile files by calculating mean and median statistics on images based on the geometry of entities within the ShapeFile. The calculated statistics are added to the .dbf
file of the ShapeFile and saved along with a CSV file.
Images should be in the format index_year_month.tif
(for example, ndvi_2023_10.tif
), where "index" is the name of the index to calculate (such as "ndvi").
- Loads ShapeFile and multiple images.
- Calculates mean and median statistics based on the ShapeFile geometry.
- Creates specific folders for each index and stores
.dbf
and.csv
files with the statistics. - Downloads processed files in a ZIP archive.
- add_stats_to_dbf: Function that adds calculated statistics to a
.dbf
file and saves them along with a.csv
file. - process_shp_data: Main function that processes the ShapeFile and generates folders with statistics for each index.
- validate_login: Function to validate access credentials.
- shapefile_interface: User interface created with Gradio.
- Python 3.x
- Libraries:
gradio
,fastapi
,pandas
,geopandas
,dotenv
,zipfile
,tempfile
-
Install dependencies:
pip install -r requirements.txt
-
Run the FastAPI server:
uvicorn main:app --reload
-
Open the browser at
http://127.0.0.1:8000
to access the application.
- Upload the ShapeFile (in a ZIP file) and images in the format
index_year_month.tif
. - Select the image format (tif or jp2).
- Download the ZIP file with processed data and statistics.