Parse weather data from NOAA Aviation Weather Centre

I wanted to import local weather data into emoncms for further processing and display so I wrote this little flow to retrieve the data.

Official Airport weather reports are by nature very accurate and are reported every 30 minutes from every airport worldwide to the NOAA Aviation Weather Centre, formatted as a METAR -

To see what data is retrieved, call - from your browser and it will retrieve the most recent METAR data. In this example from Doncaster airport (EGCN), but change the airport ICAO code to the nearest airport, like Stanstead - EGSS.

The flow will parse data from and output as a CSV (which I need for emoncms) however once you have the variables in the function node, you can do whatever you want with the data.


1) METAR standards mean that the XML feed will only include 'wind gust' data it there are wind gusts exceeding 10 knots above the mean windspeed recorded in the preceding 10 minutes, therefore my flow checks if wind gust data is included, and if not, sets the wind gust output to the same value as the windspeed.

2) Humidity is calculated in the flow using the August-Roche-Magnus Approximation formula from the temperature and dewpoint

[{"id":"797da8df.868258","type":"http request","name":"Data source","method":"GET","url":"{{{payload}}}","x":292,"y":208,"z":"7fc7e6a6.803818","wires":[["2f8afb7b.d07504"]]},{"id":"cc8b3378.3374d","type":"inject","name":"Weather report","topic":"","payload":"/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=EGCN","payloadType":"string","repeat":"600","crontab":"","once":false,"x":129,"y":208,"z":"7fc7e6a6.803818","wires":[["797da8df.868258"]]},{"id":"2f8afb7b.d07504","type":"xml","name":"","x":438,"y":208,"z":"7fc7e6a6.803818","wires":[["2c53b24f.d3ac4e"]]},{"id":"8252727b.7dad9","type":"debug","name":"","active":true,"console":"false","complete":"false","x":762,"y":208,"z":"7fc7e6a6.803818","wires":[]},{"id":"2c53b24f.d3ac4e","type":"function","name":"Parse METAR","func":"var METARdata =[0].METAR[0];\nvar wind = METARdata.wind_speed_kt[0];\nvar gusts = wind; //if wind_gust_kt is not present, value defaults to wind_speed_kt\n   if (typeof METARdata.wind_gust_kt != \"undefined\") {\n\t   gusts = METARdata.wind_gust_kt[0];\n       }\nvar altim = METARdata.altim_in_hg[0];\nvar pressure = Math.round(altim * 33.8637526); //convert hg to mb\nvar dew = METARdata.dewpoint_c[0];\nvar temp = METARdata.temp_c[0];\n\n//August-Roche-Magnus approximation to calculate humidity\nvar constA = 17.625;\nvar constB = 243.04;\nvar rh_numer = 100.0*Math.exp((constA*eval(dew))/(eval(dew)+constB));\nvar rh_denom = Math.exp((constA*eval(temp))/(eval(temp)+constB));\nvar rh_hum   = (rh_numer/rh_denom);\nvar humidity = Math.round(rh_hum);\n\nmsg.payload = ((wind) + (\",\") + (gusts) + (\",\") + (humidity) + (\",\") + (pressure) + (\",\") + (temp));\nreturn msg;","outputs":1,"x":593,"y":208,"z":"7fc7e6a6.803818","wires":[["8252727b.7dad9"]]},{"id":"8b841d88.747be","type":"comment","name":"NOAA Weather data","info":"Retrieving Finningly Airport METAR feed","x":124,"y":169,"z":"7fc7e6a6.803818","wires":[]}]

Flow Info

created 2 years, 9 months ago

Node Types

  • comment (x1)
  • debug (x1)
  • function (x1)
  • http request (x1)
  • inject (x1)
  • xml (x1)


  • Weather
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option