FastAPI Geospatial Image Processing API
Overview
This FastAPI application provides an API for processing satellite images. It includes functionalities to retrieve image attributes and generate thumbnails.
Getting Started
Prerequisites
Installation
-
Clone the repository:
git clone https://github.com/rcbop/python-geospatial.git cd python-geospatial
-
Install dependencies:
pip install -r requirements.txt
Running the Application
Run the FastAPI application using uvicorn:
python api/main.py
The API will be available at http://127.0.0.1:8000.
Environment variable API_PORT
can be used to specify the port number. For example, to run the API on port 8080.
API_PORT=8080 python api/main.py
Running with Docker Compose
-
Build the docker image:
docker-compose build
-
Run the docker container:
docker-compose up
-
The API will be available at http://localhost:8000.
Running on MiniKube
Use the scripts on the scripts
directory to install minikube and deploy the application on a local Kubernetes cluster.
-
Install minikube and start the cluster:
./scripts/minikube-install.sh
-
Deploy the application:
./scripts/minikube-deploy.sh
-
Access the NodePort service:
./scripts/minikube-access.sh
API Endpoints
1. Get Image Attributes
Endpoint: POST /image/attributes
This endpoint retrieves attributes of an uploaded image, such as size, number of bands, CRS, and georeferenced bounding box.
Request:
curl -X POST \
-F "image=@/path/to/your/image.tif" \
http://127.0.0.1:8000/image/attributes
Response:
{
"image_size": {
"width": 1024,
"height": 768
},
"number_of_bands": 3,
"coordinate_reference_system": "EPSG:4326",
"georeferenced_bounding_box": {
"left": -180.0,
"bottom": -90.0,
"right": 180.0,
"top": 90.0
}
}
2. Generate Thumbnail
Endpoint: POST /image/thumbnail
This endpoint generates a thumbnail image from the uploaded satellite image.
Request:
curl -X POST \
-F "image=@/path/to/your/image.tif" \
-F "resolution=100" \
http://127.0.0.1:8000/image/thumbnail \
--output thumbnail.png
Response:
The generated thumbnail image will be saved as thumbnail.png
in your current working directory.
Dependencies
Swagger
FastAPI provies a swagger docs endpoint at /docs. For example, if you are running the application locally, the swagger docs will be available at http://localhost:8000/docs.
Input image
This application expects a TIFF image as input.
License
This project is licensed under the MIT License.