Please avoid repeated downloads.
United State Geological Survey (USGS) provides a list
of each "feature" in the USA with its latitude and longitude. The
International Civil Aviation Organization (ICAO) provides a list
of each registered aviation station (airport) around the world with its latitude and longitude.
Many American stations feed weather observations to the
National Oceanic and Atmospheric Administration (NOAA),
which makes the observations available in the form of
XML feeds and
United States Census Bureau
offers downloadable files containing ZIP codes.
I am not aware of another free source for place names cross-referenced against weather sites. The weather reports on this page use the runtime file available via the link above. My webcam page uses similar XML files to present conditions and forecasts for upstate NY.
My ZIP files each contain an XML file that cross-references USGS locations and USA zip codes with the closest NOAA-feeding ICAO stations.
In other words, I wrote software (not available for download) to calculate the distance from selected USGS features
to every US ICAO station that feeds weather data to NOAA. From the USGS National file, the software selects every
feature with a class of "Populated Place" or "Civil". Certain feature name phrases are trimmed, such as "City of"
and "(historical)". The ZIP files, together with NOAA's free services, effectively allow a web page
developer to provide weather services for any place in the United States. The two ZIP files contain essentially the same
data, but in different formats. You may need
software to extract the XML files from the ZIP files.
My list of zip codes may not be complete because zip codes are only incidental to Census Bureau data. The USCB uses zip codes often enough to get a useful data set. The latitude and longitude of a zip code is assumed to be the same as its place name, but this is not always accurate. Some post offices serve multiple zip codes, and there are a few instances of duplicate place names within a state. If you really, really need accurate lat/lon values for a zip code, contact the United States Postal Service.
The XML files contained in the ZIP files begin with the EF BB BF byte order mark for UTF-8. I believe that UTF-8 is required and ASCII is insufficient, since Hawaiian names often contain characters outside of ASCII.
Statistics: Out of
XML file details:
- icao-usgs-full-20151121.zip contains icao-usgs-full-20151121.xml
<IcaoUsgs> <State name="AK"> <Usgs name="Ester" zipcode="99725" latitude="64.8472222" longitude="-148.0144444"> <Icao code="PAFA" name="FAIRBANKS" state="AK" latitude="64.8166667" longitude="-147.8666667" direction="E" distance="4.8250160" /> <Icao code="PAFB" name="FORT WAINWRIGHT" state="AK" latitude="64.8333333" longitude="-147.6166667" direction="E" distance="11.7159581" /> <Icao code="PAEI" name="EIELSON AFB" state="AK" latitude="64.6666667" longitude="-147.1000000" direction="E" distance="29.6720195" /> </Usgs> ...The "full" file provides friendly attribute names and 7 digits to the right of the decimal point. The USGS features are grouped by state (incouding DC and PR). The three closest ICAO sites to the USGS feature are included. At the time the file was generated, NOAA returned weather data for the ICAO sites. The direction and distance (miles) for each ICAO station are from the USGS feature to the ICAO station. In the example above, the FAIRBANKS ICAO station is 4.8 miles east of Ester.
- icao-usgs-runtime-20151121.zip contains icao-usgs-runtime-20151121.xml
<IcaoUsgs> <State name="AK"> <U f="Ester" a="64.85" o="-148.01" z="99725"> <I i="PAFA" c="E" d="4.8" /> <I i="PAFB" c="E" d="11.7" /> <I i="PAEI" c="E" d="29.7" /> </U> ...In the "runtime" file, I trimmed out excess text and provide less numeric precision. The USGS elements are grouped by state. A "U" element is a USGS element, with attributes "f" for feature, "a" for latitude, "o" for longitude, "z" for zip code. Three ICAO sites are grouped within a U element. The ICAO elements are named "I", i.e., capital letter "eye". The attributes are "i" for ICAO code, "c" for (compass) direction and "d" for distance (miles). The latitude and the longitude are provided for the USGS features, but not for the ICAO stations.
- icao-usgs-resx-20151121.zip contains icao-usgs-20151121.resx
<data name="Ester, AK"> <value>64.85|-148.01|99725@PAFA|E|4.8@PAFB|E|11.7@PAEI|E|29.7</value> </data> ...The "resx" file is a standard resource file suitable for inclusion in a Microsoft Visual Studio project. The name of the resource is the USGS feature name followed by a comma and a space and the state abbreviation. The value of the resource is a delimited string. When software retrieves the value via a resource manager, the value must be split into its parts.
Split the value first on "@". This results in four parts. The first part contains the latitude, longitude and zip code (if relevant) of the USGS feature separated by "|" (or-bar).
The other three parts are the three closest ICAO stations. Each of these parts contains the ICOA code, direction from the USGS feature and distance to the USGS feature in miles, separated by "|" (or-bar). The latitude and the longitude are provided for the USGS features, but not for the ICAO stations.