Coastline Zip Codes (USA)
Hi All, We came across a situation where we had to find the zip codes across US coastline. The consumer behavior and buying patterns are different across the coastline. We need to make strategies and give promotions accordingly. Finding the zip codes closer to the coastline is difficult and we don’t have a direct approach to search the zips.
I tried to find the coastline zips by calculating the distances from different reference points. I used the geographical centers of the USA, the geographical centers of the coastline US states, and three reference points in the ocean. The distances between lat and long using below formula:
=ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2))) *6371
The data for the united state’s zip codes are downloaded from zipcodes.org. It gives the list of all zip codes across the USA and respective lat and long. I referred Wikipedia to find the geographical center of the USA and the geographical centers of the coastline US states. Also, I used the reference points in the oceans:
- North Pacific Ocean
- North Atlantic Ocean
- Gulf of Mexico
Distance Calculations:
-
US geographical center to each zip: This distance should be maximum for the coastline zip codes, but it gives the circular curve which needs additional calculations.
-
The geographical centers of the coastline US states to each zip: This distance should also be maximum for the coastline zip codes with a condition: the distance between the US geographical center to each state geographical center should be greater than that between the US geographical center to each zip. It is included as a flag on the dashboard. I did the calculation to scale the distances as it differs for each state.
-
The ocean reference points to each zip: This distance should be minimum for the coastline zip codes. It also gives the circular curvatures, but the combinations of the other two calculations give the required zip codes.
Please find the below screenshot for Texas reason:
The dashboard is available in Power BI.
Leave a comment