I have a set of Lat/Lon pairs about 8000 pairs. I would like to identify/convert them into the US zip code. Is there a way to do this? I don't have the ZIP code polygon.
Thanks,
Pete
How about this?
http://www.boutell.com/zipcodes/
Then you'd just have to find the basin the given lat/lon falls in.
I don't know but that website that I gave you does. Look at the CSV file, the first column is zip code, then the 4th/5th are lat and lon.
Thus you could load that in and do the whole operation on it at once using BSXFUN. Here's an example:
ll = [40.1 30.2]; %desired lat and lon
[lat lon] = meshgrid(20:.1:45,20:.1:45); %all combos (the web list has this already!)
tbl = [lat(:) lon(:)]; %combined for bsxfun
[junk, idx] = min(sum(bsxfun(@(x,y)abs(x-y),ll,tbl),2)); %minimum absolute difference
idx will be the row containing the answer.
tbl(idx,:)
%{
ans = 40.1 30.2
%}
Zip codes are not points, they are polygons, and frequently very irregular polygons. I'm not sure how you can get accurate answers with this. A simple example where it will fail: an AxB rectangle adjacent to a BxC rectangle, where A>C - points inside the AxB region but near the boundary are closer to the centroid of the BxC region.