Zip Code Radius Proximity Search Algorithm

There are a lot of algorithms that seek to solve this problem – given a zip code get its latitudinal and longitudinal values from a database that collects accurate information from the most up-to-date census bureau data. The problem is simple enough, get all the zip codes that fall within a radius input and a given zip code input. The great-circle distance formula stated, using simple trigonometry, let O1, LatLon 1, O2, LatLon2 be degree in radian , latitude, Longitude of two point delimited by radius R in miles, hence the distance D is

D=R*(arcos(cos(O1)*(os(O2)*(LatLon2-LatLon1)+ sin(O1) * sin(O2)

That’s assuming Earth is a perfect sphere. However Earth is an oblate spheroid because of it is flattens at its poles due to rotation, which makes the formula flawed. The zip code Radius proximity search algorithm is still in its development stages to improve accuracy and optimization. Most algorithm that seeks to achieved optimization often fails horribly in the worst case scenario where searching within a large radius with thousands of zip codes fall within the radius boundary would chock the database server if the data are not properly indexed. Many databases have spatial type that can handle latitudinal and longitudinal data which was engineered for spatial calculation.