<p>You can get this from the <a href="https://www.ncdc.noaa.gov/isd" rel="nofollow noreferrer">Integrated Surface Dataset (ISD)</a>.</p>

<p>First get a list of all weather stations from <code>ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-history.txt</code>:</p>



<pre><code>stations = pandas.read_fwf("ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-history.txt", 
                           skiprows=20, parse_dates=["BEGIN", "END"],
                           skip_blank_lines=True,
                           dtype={"WBAN": "O"})
</code></pre>

<p>Then select the ones in the USA:</p>



<pre><code>stations_us = stations[stations["CTRY"]=="US"]
</code></pre>

<p>That give us 7326 stations.  Although the state of each station is described, the county is not.  To get the county you will need to combine the lat/lon for each station with a county database.  That is a bit beyond the scope of Earth Science SE, but maybe you can get help at <a href="https://gis.stackexchange.com">GIS</a> SE.  The station ID is a combination of two fields:</p>



<pre><code>ids = stations_us["USAF"] + stations_us["WBAN"]
</code></pre>

<p>We can then download the measurements for a particular year from AWS S3:</p>



<pre><code>meas = pandas.read_csv(f"s3://noaa-global-hourly-pds/2020/{ids.iloc[200]:s}.csv", parse_dates=["DATE"])
</code></pre>

<p>And extract temperatures:</p>



<pre><code>temps = meas.TMP.str.extract(r"([+-]\d{4}),([012345679ACIMPRU])")[0].astype("f4")/10
</code></pre>

<p>Let's get the valid ones (there's a 9999 fill value) and plot:</p>



<pre><code>valid = temps&lt;999
meas[valid].set_index(meas.DATE[valid])["temps"].plot()
</code></pre>

<p><a href="https://i.sstatic.net/LEn8G.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LEn8G.png" alt="measurements"></a></p>

<p>Enjoy!</p>

<p>For a description of the fields, see the ISD Format Document at <a href="https://www.ncei.noaa.gov/data/global-hourly/doc/isd-format-document.pdf" rel="nofollow noreferrer">https://www.ncei.noaa.gov/data/global-hourly/doc/isd-format-document.pdf</a> .</p>

CC BY-SA 4.0
2020-02-07T02:58:18.490Z
Thank you so much! This is kind of what I am looking for. However, I ran your code and it only gives readings for Anvik Airport, Alaska. I'm guessing, I should loop over all station codes to get a representative profile for each and then match them to each county. Is there github documentation for AWS S3 + NOAA?
masaladosa
CC BY-SA 4.0
2020-02-07T08:36:30.500Z
@masaladosa It gives Anvik because of the line `ids.iloc[200]` — station 200 happens to be Anvik. You'll want to inspect the `stations` DataFrame to select stations of interest to you (about half the stations are historical, but the stations DataFrame contains date lists). I've linked the ISD page and format documentation, you'll find the [AWS ISD page here](https://registry.opendata.aws/noaa-isd/). There's a lot on AWS S3 around but if you use pandas to read it directly you don't need it. In case you're not familiar with pandas you can use their excellent tutorial (I'm quite new myself).
gerrit
CC BY-SA 4.0
2020-02-10T22:28:52.717Z
Thanks a lot! I think I found what I was looking for deep into their documentation. I'll clean the data and upload for others to use shortly.
masaladosa
CC BY-SA 4.0
2020-02-06T09:25:33.423Z
2020-02-06T20:17:32.083Z
2020-02-06T20:17:32.083Z
gerrit
<p>Need temperature for 24 hours for each county of United States. Average values is ok, seasonal granularity welcome. I've been looking at nClimDiv datasets </p>

CC BY-SA 4.0
2020-02-07T15:59:06.053Z
Worth noting that counties in the United States range from ~ 13 square miles to 20,100 square miles. The largest, such as San Bernardino County, have a mix of climates, so there's no probably no single representative value.
jeffronicus
CC BY-SA 4.0
2020-02-07T18:46:11.287Z
@jeffronicus: There's also quite an elevation range within counties.  I can be in fairly warm sunshine here in the valley, while watching a snowstorm in the nearby mountains - or at other times, be skiing in the sun on those mountains while the valley is covered in fog, or even pogonip: https://en.wikipedia.org/wiki/Ice_fog
jamesqf
<climate><climate-models>
Where can I get hourly ambient temperature for each county in United States?
masaladosa
# Where can I get hourly ambient temperature for each county in United States?

(Asked by: username_0 on 2020-02-06)

Need temperature for 24 hours for each county of United States. Average values is ok, seasonal granularity welcome. I've been looking at nClimDiv datasets

**Tags:** climate, climate-models

> **Comments:**
> **username_1**: Worth noting that counties in the United States range from ~ 13 square miles to 20,100 square miles. The largest, such as San Bernardino County, have a mix of climates, so there's no probably no single representative value.  
> **username_2**: @username_1: There's also quite an elevation range within counties.  I can be in fairly warm sunshine here in the valley, while watching a snowstorm in the nearby mountains - or at other times, be skiing in the sun on those mountains while the valley is covered in fog, or even pogonip: https://en.wikipedia.org/wiki/Ice_fog  

---

## 1 answers

### Answer by username_3 on 2020-02-06. Score: 7

You can get this from the [Integrated Surface Dataset (ISD)](https://www.ncdc.noaa.gov/isd).

First get a list of all weather stations from `ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-history.txt`:

```
stations = pandas.read_fwf("ftp://ftp.ncdc.noaa.gov/pub/data/noaa/isd-history.txt", 
                           skiprows=20, parse_dates=["BEGIN", "END"],
                           skip_blank_lines=True,
                           dtype={"WBAN": "O"})

```

Then select the ones in the USA:

```
stations_us = stations[stations["CTRY"]=="US"]

```

That give us 7326 stations. Although the state of each station is described, the county is not. To get the county you will need to combine the lat/lon for each station with a county database. That is a bit beyond the scope of Earth Science SE, but maybe you can get help at [GIS](https://gis.stackexchange.com) SE. The station ID is a combination of two fields:

```
ids = stations_us["USAF"] + stations_us["WBAN"]

```

We can then download the measurements for a particular year from AWS S3:

```
meas = pandas.read_csv(f"s3://noaa-global-hourly-pds/2020/{ids.iloc[200]:s}.csv", parse_dates=["DATE"])

```

And extract temperatures:

```
temps = meas.TMP.str.extract(r"([+-]\d{4}),([012345679ACIMPRU])")[0].astype("f4")/10

```

Let's get the valid ones (there's a 9999 fill value) and plot:

```
valid = temps<999
meas[valid].set_index(meas.DATE[valid])["temps"].plot()

```

[![measurements](https://i.sstatic.net/LEn8G.png)](https://i.sstatic.net/LEn8G.png)

Enjoy!

For a description of the fields, see the ISD Format Document at <https://www.ncei.noaa.gov/data/global-hourly/doc/isd-format-document.pdf> .

> **Comments:**
> **username_0**: Thank you so much! This is kind of what I am looking for. However, I ran your code and it only gives readings for Anvik Airport, Alaska. I'm guessing, I should loop over all station codes to get a representative profile for each and then match them to each county. Is there github documentation for AWS S3 + NOAA?  
> **username_3**: @username_0 It gives Anvik because of the line `ids.iloc[200]` — station 200 happens to be Anvik. You'll want to inspect the `stations` DataFrame to select stations of interest to you (about half the stations are historical, but the stations DataFrame contains date lists). I've linked the ISD page and format documentation, you'll find the [AWS ISD page here](https://registry.opendata.aws/noaa-isd/). There's a lot on AWS S3 around but if you use pandas to read it directly you don't need it. In case you're not familiar with pandas you can use their excellent tutorial (I'm quite new myself).  
> **username_0**: Thanks a lot! I think I found what I was looking for deep into their documentation. I'll clean the data and upload for others to use shortly.  

---

