[2/2] KNN Classifier (Lands Dataset)
This workflow utilizes the KNN algorithm to achieve automatic classification of land types in satellite imagery. It converts images into vectors through the embedded API of Voyage AI, queries the Qdrant database to retrieve similar images, and employs a majority voting strategy to determine the classification. A mechanism for dynamically adjusting the number of neighbors has been designed to address tie situations in voting, ensuring the accuracy of the classification results, which achieve an overall accuracy rate of 93.24%. This approach is applicable in fields such as remote sensing analysis, urban planning, and agricultural monitoring, enhancing the automation and intelligence level of image classification.
![[2/2] KNN Classifier (Lands Dataset) Workflow diagram](/_next/image?url=https%3A%2F%2Fimg.n8ntemplates.dev%2Fcdn-cgi%2Fimage%2Fwidth%3D1024%2Cheight%3D640%2Cquality%3D85%2Cformat%3Dauto%2Cfit%3Dcover%2Conerror%3Dredirect%2Ftemplates%2F22-knn-classifier-lands-dataset-256422.png&w=3840&q=75)
Workflow Name
[2/2] KNN Classifier (Lands Dataset)
Key Features and Highlights
This workflow implements satellite imagery land type classification based on the K-Nearest Neighbors (KNN) algorithm. It leverages Voyage AI’s multimodal embeddings API to convert input satellite image URLs into vector representations. Subsequently, it queries the Qdrant vector database to retrieve the most similar neighbor images and determines the final classification through majority voting based on the labeled categories of these neighbors. To address tie votes, the workflow incorporates a dynamic loop mechanism that incrementally increases the number of neighbors until a decisive majority is reached, ensuring classification accuracy and stability. The overall classification accuracy achieves 93.24% without requiring additional fine-tuning or metric learning.
Core Problem Addressed
This workflow tackles the challenge of automatic land type classification from satellite images. By utilizing efficient vector retrieval and majority voting strategies, it enables fast and accurate identification of complex land cover types such as farmland, forest, beach, and airport runways, while avoiding the dependency on large labeled datasets and complex model training typical of traditional classification methods.
Application Scenarios
- Satellite remote sensing image analysis and classification
- Land use and land cover monitoring
- Urban planning and environmental protection
- Agricultural region monitoring
- Geographic Information System (GIS) data enhancement
Main Process Steps
- Trigger Execution: Receive input requests containing image URLs via the workflow trigger.
- Image Embedding: Call Voyage AI’s multimodal embeddings API to convert input images into vector embeddings.
- Set Query Parameters: Initialize parameters for querying the Qdrant vector database, including cloud URL, collection name, and neighbor count (limitKNN).
- Query Qdrant: Use the embedding vector to query Qdrant and retrieve the most similar neighbor images along with their labels.
- Majority Voting: Count the categories of neighbor images and select the top two categories with the highest frequencies.
- Tie Detection and Looping: If a tie occurs between the top two categories and the neighbor count has not exceeded 100, increase the neighbor count and re-query until the tie is resolved.
- Return Classification Result: Output the final land type classification result.
Involved Systems or Services
- Voyage AI Multimodal Embeddings API: Provides image vectorization capabilities.
- Qdrant Cloud Vector Database: Stores and retrieves pre-labeled satellite image vector collections.
- n8n Automation Platform: Orchestrates and executes the entire workflow.
Target Users and Value
- Remote sensing analysts and GIS specialists, facilitating automated land type recognition.
- Environmental monitoring agencies and urban planning departments, enabling rapid land use information acquisition.
- Agri-tech companies, supporting farmland management and yield prediction through image classification.
- Data scientists and developers, serving as a reference template for vector retrieval and multimodal AI applications.
This workflow template features a clear structure and supports flexible replacement of datasets and vector database configurations. It is easy to migrate and customize for different image datasets, significantly enhancing the automation and intelligence level of image-based classification tasks.