A location record needs a known coordinate reference, geometry type, observation time and uncertainty before distance or containment has meaning.
Geospatial data contract: location units, coordinates and accuracy
Choose the decision unit
An operations team may estimate delivery coverage for pickup points. One row can represent a pickup site, delivery event or service zone; joining them without declaring grain multiplies counts. Give each site a stable ID and record whether coordinates describe an entrance, centroid or approximate neighborhood. Dataset grain prevents one busy site from silently dominating a regional report.
Validate coordinates
Longitude and latitude have different valid ranges and order. A pair (77.25, 28.61) means something different when reversed. Record coordinate reference system and axis order for every source, plus whether values are degrees or projected linear units. Never compute kilometer distances from degree differences. A missing coordinate is not the zero-degree point.
Represent accuracy
A geocoded address may be accurate to a building, street or city. Store the accuracy class and collection method. An event with a 900-meter uncertainty radius should not be assigned confidently to a narrow delivery zone near its boundary. Spatial joins need a policy for boundary and uncertain points rather than a single yes/no flag.
Test the contract
Create pickup site P-47 at longitude 77.25, latitude 28.61, another with swapped axes, and a third with no coordinates. Reject the swapped record through range or region checks, and preserve the missing record for quality reporting. Add two historical site moves and verify an older delivery joins to the site location valid at its event time.
Implementation
def valid_lon_lat(longitude, latitude):
return (longitude is not None and latitude is not None
and -180 <= longitude <= 180 and -90 <= latitude <= 90)Performance and operating cost
Coordinate-range validation is O(1) per point and O(N) for N records. Range checks cannot detect every swapped pair because both values may remain legal; region plausibility and source metadata are additional safeguards.
Common Mistakes
- Do not treat degrees as kilometers.
- Do not assign a missing coordinate to longitude and latitude zero.
- Do not assume an address geocode identifies the exact entrance.
Read next
- Spatial joins: polygons, boundaries and duplicate matches
- Distance and nearest service: metric choice before optimization
- Dataset grain and join cardinality: protect the unit of analysis
- Time-series calendar: distinguish missing periods from measured zeros
Compare representations: Vector vs raster in machine learning: geometry, pixels and feature vectors.
