How to use the NOAA API to query past weather data for a given set of coordinates

I am trying to get past NOAA data using latitudinal and longitudinal coordinates. I am interested in both historical time series and annual summaries for variables such as temperature, wind speed, proportion of clouds and precipitation.

EX: 2008-02-20 13:00 in (25.033972, 121.564493)

I hope to automate the process that achieves this for 900,000 sites. Any ideas? Ideally, this script will be written in R or Python.

+8
source share
2 answers
  1. Define an endpoint / dataset that contains the information you want (or more)
  2. Convert lat / long to zip code
  3. Find the correct station for the zip code here
  4. For each endpoint, retrieve data for each location.
  5. ???
  6. Profit???
+8
source

NOAA is now on the second version of the NOAA web API. The APIs are useful because you can essentially request a web service using requests and python dict arguments that describe what you want. @Cravden has created a nice class that will help you get started on GitHub . NOAA has good documentation describing what you can get and how (you need to provide them and send them by email in order to get an access token). Other climate data aggregators also do similar things.
Something simple how this can get you started:

 import requests def get_noaa_data(url, data_type, header): r = requests.get(url, data_type, headers=header) print(r) if __name__ == '__main__': token = 'gotowebsitetorequesttoken' creds = dict(token=token) dtype = 'dataset' url = 'https://www.ncdc.noaa.gov/cdo-web/api/v2/' get_noaa_data(url, dtype, creds) 

If you travel through thousands of places, you might consider uploading data to the grid, creating a shapefile of the points file, and then extracting the raster values ​​into the attribute table, as done here .

+6
source

Source: https://habr.com/ru/post/953922/


All Articles