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.
- Hackofiesta 6.0 - AISpire UP Hackathon
- Features
- How the Process Works
- MapComponent Overview
- AI Model Integration
- Prerequisites
- Installation
- Contributors
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
- 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.
- The user selects a bounding box on the map.
- The coordinates of the bounding box are sent to the server via the
/minmaxendpoint.
- The server processes the bounding box coordinates using
create_bbox_shapefilefromcreate_shapefile.py. - A shapefile is created based on the selected area.
- The server retrieves high-resolution satellite imagery for the bounding box using
download_satellite_imageryfromdownload_imagery.py.
- The downloaded image is processed using
segment_satellite_imagefromsegment_land_hqsam.py. - The segmentation results are saved as GeoJSON data.
- 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.
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:
- The map is initialized using
MapContainerfromreact-leaflet. - The map is centered at a default position defined by
DEFAULT_POSITIONfrom the configuration file.
- The map includes two base layers: OpenStreetMap and Google Satellite.
- An overlay layer for segmentation data is also included.
- The component uses
react-leaflet-drawto allow users to draw and edit shapes on the map. - The
EditControlcomponent 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.
- 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.
- A counter is displayed at the bottom right of the map, showing the number of selected polygons.
- 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_perimeterfunction from thepyprojlibrary.
- 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.
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=offscreengit clone https://github.com/crizmo/TerraBound.git
cd TerraBound-
Navigate to the client directory:
cd client -
Install the dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to http://localhost:3000.
-
Navigate to the server directory:
cd server -
Create a Conda environment:
conda env create -f ../environment.yml
-
Activate the Conda environment:
conda activate samgeo
-
Install additional Python dependencies:
pip install -r ../requirements.txt
-
Start the Flask server:
python server.py
-
The server will be running on http://127.0.0.1:5010.
