Geofence Marking and Validation Standard Operating Procedures

TL;DR: Complete guide to marking, validating, and bulk uploading geofence coordinates for location-based services with quality assurance checks

Accurate geofence boundaries are critical for location-based delivery services, security systems, and property management applications. This guide covers the complete workflow from marking coordinates to validation and database upload.

Geofence Marking Workflow

┌─────────────────────────────────────────────────────────────────┐
│                    GEOFENCE WORKFLOW                             │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  ┌──────────────┐    ┌──────────────┐    ┌──────────────┐      │
│  │  Satellite   │    │   Master     │    │   Google     │      │
│  │    Map       │    │    Plan      │    │    Maps      │      │
│  └──────┬───────┘    └──────┬───────┘    └──────┬───────┘      │
│         │                   │                   │               │
│         └─────────────┬─────┴───────────────────┘               │
│                       ▼                                         │
│              ┌─────────────────┐                                │
│              │  Mark Boundary  │                                │
│              │  Coordinates    │                                │
│              └────────┬────────┘                                │
│                       ▼                                         │
│              ┌─────────────────┐                                │
│              │   Validation    │                                │
│              │    (maps.co)    │                                │
│              └────────┬────────┘                                │
│                       ▼                                         │
│              ┌─────────────────┐                                │
│              │ Python Format   │                                │
│              │   & Cleanup     │                                │
│              └────────┬────────┘                                │
│                       ▼                                         │
│              ┌─────────────────┐                                │
│              │  API Conversion │                                │
│              │  (xlsx format)  │                                │
│              └────────┬────────┘                                │
│                       ▼                                         │
│              ┌─────────────────┐                                │
│              │  Bulk Upload    │                                │
│              │  to Database    │                                │
│              └─────────────────┘                                │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Step-by-Step Marking Process

1. Prepare Reference Materials

Before marking, gather:

  • Master Plan: Builder’s official site layout (from their website)
  • Satellite View: Use birdtheme.org for satellite imagery
  • Google Maps: Cross-reference building names and landmarks
  • Building Registry: Count of registered structures in your system

2. Marking Coordinates

Initial Setup

  1. Open the mapping tool and locate the property
  2. Switch to Satellite mode for accurate boundary identification
  3. Identify property boundaries using master plan reference

Marking Rules

RuleDescription
Buffer DistanceStart marking slightly inward from boundary (system uses 250m buffer)
Point SpacingMaximum 50m between consecutive points
Building ShadowsMark building footprints, not shadow projections
Decimal PrecisionUse minimum 6 decimal places for lat/long
Under ConstructionExclude areas still under development

Coordinate Order

Mark points in sequential order around the perimeter:

Start here ──▶ 1 ──▶ 2 ──▶ 3
              ▲              │
              │              ▼
              8              4
              ▲              │
              │              ▼
              7 ◀── 6 ◀── 5

3. Gate Coordinates

Mark main entrance gate with high precision:

✓ Correct: 28.458916, 77.089499 (6 decimals)
✗ Wrong:   28.45, 77.08 (2 decimals - too imprecise)

Imprecise gate coordinates cause delivery failures when partners attempt proximity validation.

Data Format Specification

Upload Format

ColumnDescriptionExample
site_idUnique property identifier6010
gate_latitudeMain entrance lat28.458916
gate_longitudeMain entrance long77.089499
Point 1 latFirst boundary point28.458916
Point 1 longFirst boundary point77.089499
Continue for all points

Database Storage Format

[
  {"lat": "28.467977", "long": "77.537888"},
  {"lat": "28.468449", "long": "77.538961"},
  {"lat": "28.468656", "long": "77.539626"},
  {"lat": "28.469637", "long": "77.539819"}
]

Validation Process

Visual Validation Tool

Use maps.co/gis to verify geofence accuracy:

  1. Navigate to LayersNew Layer
  2. Paste comma-separated lat/long coordinates
  3. Click Import
  4. Verify polygon matches property boundary on satellite view

Common Quality Issues

┌─────────────────────────────────────────────────────────────────┐
│                  GEOFENCE QUALITY ISSUES                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  INTERSECTING              OVERLAPPING              OPEN         │
│  ┌──────┐                  ┌──────┐                ┌──────┐     │
│  │    ╲╱│                  │██████│                │      │     │
│  │    ╱╲│                  │██████│──overlap──▶    │      │     │
│  │   ╱  ╲                  └──────┘                │      ╲     │
│  └──╱────╲                 ┌──────┐                │       ╲    │
│    ╱      ╲                │██████│                └────────    │
│                            └──────┘                             │
│                                                                  │
│  Lines cross each    Polygons overlap       Polygon not closed  │
│  other incorrectly   with adjacent ones     (missing segment)   │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Automated Validation Script

import pandas as pd
import re

def validate_geofence(filepath):
    """Validate geofence data from CSV file."""
    df = pd.read_csv(filepath)
    
    results = {
        'valid': [],
        'invalid': [],
        'point_counts': []
    }
    
    # Regex pattern for valid coordinate format
    pattern = re.compile(r'(\d{1,2}\.\d+,\d{1,2}\.\d+,\d{1,2}\.\d+\s*){4,}')
    point_pattern = re.compile(r'(\d{1,2}\.\d+,\d{1,2}\.\d+,\d{1,2}\.\d+)')
    
    for idx, row in df.iterrows():
        geofence = str(row['geofence']).replace('"', '').strip()
        
        is_valid = pattern.search(geofence) is not None
        point_count = len(re.findall(point_pattern, geofence)) if is_valid else 0
        
        results['valid'].append(is_valid)
        results['point_counts'].append(point_count)
        
        if not is_valid:
            results['invalid'].append({
                'row': idx,
                'site_id': row.get('site_id', 'N/A')
            })
    
    df['geo_points'] = results['point_counts']
    df['valid_geofence'] = results['valid']
    
    return df, results['invalid']

# Usage
df, invalid = validate_geofence("/path/to/geofence_data.csv")

# Export validation results
df.to_csv('geofence_validated.csv', index=False)

print(f"Valid entries: {df['valid_geofence'].sum()}")
print(f"Invalid entries: {len(invalid)}")

Bulk Upload Process

Step 1: Format Data

Ensure required columns exist:

  • City, Region, site_status_fmt, is_site_active, Locality

Add placeholder values if missing:

City: Bangalore
Region: Bangalore  
site_status_fmt: live
is_site_active: Active
Locality: [Area Name]

Step 2: Validate with Script

python geo_fence_format.py

Review output file for:

  • valid_geofence = True entries only
  • Remove invalid rows
  • Delete validation columns before upload

Step 3: Data Cleanup Checklist

  • Remove all invalid geofence entries
  • Delete empty rows and columns
  • Verify numeric columns contain only numbers (lat, long, pincode, site_id)
  • Remove special characters from coordinates
  • Check for escape characters (e.g., "lat":"28.471467\"}")

Step 4: Convert to Upload Format

curl --location --request POST 'http://172.xx.xx.xx:8090/partner/v1/geofileconv/' \
  --header 'api-key: YOUR_API_KEY' \
  --form 'file=@"/path/to/formatted_geofence.xlsx"'

Step 5: Format Conversion

Convert the API response file to .xls format:

  • Use macOS Numbers app, or
  • Use online converter (zamzar.com/convert/xlsx-to-xls/)

Step 6: Upload to process

Upload the final .xls file to the bulk upload endpoint:

https://api.example.com/upload/site/geofence

Quality Assurance Guidelines

Pre-Upload Verification

  1. Coordinate Precision: Minimum 6 decimal places
  2. Point Density: At least 4 points, ideally 8-12 for complex shapes
  3. Data Integrity: No special characters or escape sequences
  4. Boundary Accuracy: Compare against satellite imagery

Common Data Issues

IssueExampleFix
Escape characters"lat":"28.471467\"}"Remove backslashes
Mixed coordinatesPrevious sites’s points includedClear map before marking
Low precision28.45, 77.08Add decimal precision
Open polygonMissing final pointEnsure closure

Post-Upload Validation

After bulk upload, verify:

  1. Query uploaded records from database
  2. Visualize on maps.co/gis
  3. Test with partner delivery validation
  4. Monitor for geofence-related delivery failures

Coordinate Tools Reference

ToolURLPurpose
Satellite Markingbirdtheme.org/useful/v3largemap.htmlMark coordinates
Validationmaps.co/gisVisualize polygons
Format Conversionzamzar.comxlsx to xls
Lat/Long ArrangerInternal toolFormat coordinates

This standardized process ensures consistent, accurate geofence data that supports reliable location-based services across all integrated applications.

Acknowledgements
  • Aniket — Process documentation and workflow design