Skip to content

crizmo/TerraBound

Repository files navigation

TerraBound

TerraBound is a dynamic web mapping application developed using React, Vite, and React-Leaflet, styled with Tailwind CSS and Shadcn. It allows users to create, edit, and manage geographical features such as points, lines, and areas, and integrates functionalities for enhanced data interaction and documentation.

Table of Contents

Hackofiesta 6.0 - AISpire UP Hackathon

Problem Statement

Title: AI-based application for Auto-Measurement of Land Area

Description: An AI-based application for auto-measurement of land area utilizes advanced technologies like satellite imagery, GPS, and machine learning algorithms to accurately measure and map land parcels. Traditionally, land measurement has been a manual process, often prone to errors and delays.

The AI application automates this process by analyzing geospatial data and identifying land boundaries with high precision. By using real-time satellite data and GPS coordinates, it can provide instant measurements of land area without the need for physical surveys.

Department: Board of Revenue
Sector: Land Administration and Revenue

Video Demo

Watch the demo

Features

  • Create Geographic Features: Add polygons, bounding boxes to the map.
  • Text Mode: View information about the area in popups by hovering.
  • Edit and Delete: Modify or remove existing map features.
  • Sidebar with Details: View feature details in a sidebar, including unique IDs, areas, text, and coordinates.
  • Coordinates Export: Copy coordinates details for any particular region directly from the sidebar.
  • Search Functionality: Quickly find features listed in the sidebar.
  • Segmentation: Segment satellite images and visualize the results on the map.
  • Measure Land Area: Measure the area of any particular land plot.

How the Process Works

1. Creating a Bounding Box

  • The user selects a bounding box on the map.
  • The coordinates of the bounding box are sent to the server via the /minmax endpoint.

2. Generating a Shapefile

  • The server processes the bounding box coordinates using create_bbox_shapefile from create_shapefile.py.
  • A shapefile is created based on the selected area.

3. Downloading Satellite Imagery

  • The server retrieves high-resolution satellite imagery for the bounding box using download_satellite_imagery from download_imagery.py.

4. Segmenting the Satellite Image

  • The downloaded image is processed using segment_satellite_image from segment_land_hqsam.py.
  • The segmentation results are saved as GeoJSON data.

5. Displaying Segmentation Results

  • The client fetches the segmentation data from the server.
  • The segmented land areas are displayed as polygons on the map.
  • Users can interact with these polygons by selecting, editing, or deleting them.

MapComponent Overview

The MapComponent in the file client/src/components/shared/MapComponent.jsx is a React component that integrates with the Leaflet library to create an interactive map. Here are the key details and functionalities of the component:

Key Functionalities

1. Map Initialization:

  • The map is initialized using MapContainer from react-leaflet.
  • The map is centered at a default position defined by DEFAULT_POSITION from the configuration file.

2. Layers Control:

  • The map includes two base layers: OpenStreetMap and Google Satellite.
  • An overlay layer for segmentation data is also included.

3. Drawing and Editing Features:

  • The component uses react-leaflet-draw to allow users to draw and edit shapes on the map.
  • The EditControl component handles the creation, editing, and deletion of shapes.
  • When a shape is created or edited, a text input modal (TextInput) is displayed to allow users to add or edit text associated with the shape.

4. Segmentation Data:

  • The component fetches segmentation data from a server endpoint (/get-segments) and displays it as a GeoJSON layer on the map.
  • Polygons in the segmentation data can be selected, deselected, and hovered over, with different styles applied based on their state.

5. Selected Polygons Counter:

  • A counter is displayed at the bottom right of the map, showing the number of selected polygons.

6. Measure Land Area:

  • The component allows users to measure the area of any particular land plot by selecting the polygon and clicking the "Measure Area" button.
  • The area is calculated using the geod.geometry_area_perimeter function from the pyproj library.

AI Model Integration

  • The component integrates with a pretrained segmentation model SamGeo.
  • The model is used to segment satellite images and generate masks and annotations.
  • The model file (sam_hq_vit_h.pth) is downloaded from a specified URL if it does not already exist in the cache directory.
  • We then perform some post processing on these masks to filter out small areas and get the final segmented land areas.

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js
  • npm or yarn
  • Python 3.9
  • Conda

Additionally, set the following environment variable before running the application:

export QT_QPA_PLATFORM=offscreen

Installation

Clone the Repository

git clone https://github.com/crizmo/TerraBound.git
cd TerraBound

Setting Up the Client

  1. Navigate to the client directory:

    cd client
  2. Install the dependencies:

    npm install
  3. Start the development server:

    npm run dev
  4. Open your browser and navigate to http://localhost:3000.

Setting Up the Server

  1. Navigate to the server directory:

    cd server
  2. Create a Conda environment:

    conda env create -f ../environment.yml
  3. Activate the Conda environment:

    conda activate samgeo
  4. Install additional Python dependencies:

    pip install -r ../requirements.txt
  5. Start the Flask server:

    python server.py
  6. The server will be running on http://127.0.0.1:5010.

Contributors

About

TerraBound is an interactive web mapping tool built with React, Vite, and Leaflet, enabling users to draw, edit, and analyze geographic features with AI-powered land segmentation and GEOJSON export. πŸš€

Topics

Resources

Stars

Watchers

Forks

Contributors