1. Guide to Backend and Database Setup for GeoBee Dashboard Development

This article serves as a comprehensive guide for setting up the backend and database for the GeoBee Dashboard, which is focused on geospatial analysis for waste collection in Tangerang City. We’ll cover how to install and configure PostGIS, set up the Python environment, and implement the workflow for uploading shapefiles and raster data.

1. Setting Up and Installing PostGIS

PostGIS is an essential extension for PostgreSQL that adds support for geographic objects, enabling us to store and query spatial data. Here’s how to install and enable PostGIS and the PostGIS Raster extension:

Step 1: Install PostgreSQL and PostGIS

  1. Install PostgreSQL:
    • Depending on your operating system, follow the instructions to install PostgreSQL from the official PostgreSQL website.
  2. Install PostGIS:

Step 2: Enable PostGIS and PostGIS Raster Extension

  1. Connect to PostgreSQL:
    • Access the PostgreSQL prompt:
      bash
      sudo -u postgres psql
  2. Create a new database (if not already created):
    CREATE DATABASE your_db_name;
  3. Enable PostGIS in your database:
    \c your_db_name
    CREATE EXTENSION postgis;
    CREATE EXTENSION postgis_raster;
    • This will enable the spatial features and raster support in your database.

Step 3: Verify Installation

  • Verify that the extensions are installed by running:
    sql
    \dx
    • You should see postgis and postgis_raster listed.

2. Setting Up the Python Environment

To get the backend running, we’ll set up a Python environment that includes all the necessary dependencies for the GeoBee Dashboard.

Step 1: Clone the Project Repository

  1. Clone the GitHub Repository:
    git clone https://github.com/syauqiakm/geobee-dashboard.git
    cd geobee-dashboard/Backend

Step 2: Set Up a Python Virtual Environment

  1. Create a Virtual Environment:
    python3 -m venv venv
  2. Activate the Virtual Environment:
    • On Linux/Mac:
      source venv/bin/activate
    • On Windows:
      .\venv\Scripts\activate

Step 3: Install Dependencies

  1. Install Required Packages:
    • Assuming the project has a requirements.txt file, install the dependencies:
      pip install -r requirements.txt
    • If there’s no requirements.txt, manually install the key packages:
      pip install fastapi uvicorn sqlalchemy psycopg2-binary geoalchemy2 shapely

Step 4: Test the Environment Setup

  1. Run the Application:
    • Start the FastAPI server to ensure everything is configured properly:
      uvicorn main:app --reload
  2. Access the API:
    • Open your browser and navigate to http://127.0.0.1:8000/docs to see the interactive API documentation.

3. Shapefile and Raster Feature Workflow

Understanding the workflow for handling shapefiles and raster data is crucial for smooth operation in the GeoBee Dashboard. The process involves multiple steps from the frontend to the backend and back to the frontend. Below is an illustration to help you visualize the workflow:

Workflow Overview

[Placeholder Image – Insert actual image link]

  1. Upload from Frontend:
    • Users upload shapefiles or raster data through the GeoBee Dashboard interface.
  2. Backend Processing:
    • The backend receives the files, converts them into database-compatible formats, and stores the data in PostGIS.
  3. Data Retrieval:
    • The frontend requests the processed data from the backend, which then queries the PostGIS database.
  4. Display on Frontend:
    • The frontend renders the retrieved data, displaying maps, layers, or other geospatial visualizations.

This simplified workflow helps users understand how geospatial data moves through the system, ensuring that each component works harmoniously.

Conclusion

With PostGIS set up, the Python environment configured, and a clear understanding of the shapefile and raster workflow, your GeoBee Dashboard is well-prepared for effective geospatial analysis. This setup will enable efficient storage, processing, and visualization of spatial data, empowering decision-making for waste management in Tangerang City.