From Point to Perimeter: Mapping Proximity with GeoRadius

from-point-to-perimeter-mapping-proximity-with-georadius

Overview

GeoRadius returns all ZIP Codes (U.S.) or postal codes (Canada) within a specified distance of a central point. Supply a latitude/longitude or a starting code plus radius in miles, kilometers, or nautical miles, and receive a sorted list of nearby codes along with distances.

Key Business Use Cases

1. Location‑Based Search & Discovery

Power “find near me” features in consumer apps—show stores, service centers, or events within a user’s vicinity, sorted by distance.

2. Field Service & Workforce Management

Assign technicians or delivery drivers to jobs based on proximity—optimize dispatch by pulling the nearest available resource.

3. Emergency Response & Planning

Identify critical assets or vulnerable populations within a disaster radius—plan evacuation zones, resource staging, or outreach campaigns.

Developer Spotlight: C# Code Snippet


// GeoRadius C# example
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

namespace CDXGeoDataSample
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var apiKey  = Environment.GetEnvironmentVariable("CDX_GEO_KEY");
            var latitude  = 40.7128;
            var longitude = -74.0060;  // New York City
            var radius    = 10;        // miles
            var format    = "json";
            var url       = $"https://geodata.cdxtech.com/api/georadius?key={apiKey}"
                          + $"&latitude={latitude}&longitude={longitude}"
                          + $"&radius={radius}&unit=miles&format={format}";

            using var client = new HttpClient();
            var response     = await client.GetAsync(url);
            response.EnsureSuccessStatusCode();

            var json    = await response.Content.ReadAsStringAsync();
            var results = JsonDocument.Parse(json).RootElement.GetProperty("results");

            Console.WriteLine($"Found {results.GetArrayLength()} postal codes within {radius} miles:");
            foreach (var item in results.EnumerateArray())
            {
                var code     = item.GetProperty("postalCode").GetString();
                var dist     = item.GetProperty("distance").GetDouble();
                Console.WriteLine($"  {code}: {dist} miles");
            }
        }
    }
}
  

Sample Response

{
  "service": "GeoRadius",
  "results": [
    { "postalCode": "10004", "latitude": 40.7039, "longitude": -74.0139, "distance": 1.2 },
    { "postalCode": "10006", "latitude": 40.7080, "longitude": -74.0132, "distance": 1.5 },
    { "postalCode": "10005", "latitude": 40.7060, "longitude": -74.0086, "distance": 1.7 }
  ],
  "tokenCharge": 2
}
  

Getting Started

  1. Sign up for a free CDXGeoData account and grab your API key.
  2. Invoke GET /api/georadius with key, latitude, longitude, radius, unit, and format.
  3. Parse the results array to handle nearby codes and distances in your application.
Comments are closed