ahinkle/noaa

Package that provides current weather conditions provided by NOAA for the United States.


Keywords
package, laravel, weather, noaa, weather-api, weather-data
License
MIT

Documentation

NOAA Current Weather Conditions

PHP Version Latest Version on Packagist Build Status Total Downloads

This PHP Package provides current weather conditions provided by NOAA for the United States. The National Oceanic and Atmospheric Administration (NOAA) is a United States federal agency, so the data they provide is only available for US locations. Current Weather Conditions data is provided by NOAA's XML Feeds of Current Weather Conditions. Here is an example:

CurrentConditions::getWeatherByStation('KEVV');

// Returns array:
[
    "@attributes" => [
        "version" => "1.0"
    ]
    "credit" => "NOAA's National Weather Service"
    "credit_URL" => "http://weather.gov/"
    "image" => [
        "url" => "http://weather.gov/images/xml_logo.gif"
        "title" => "NOAA's National Weather Service"
        "link" => "http://weather.gov"
    ]
    "suggested_pickup" => "15 minutes after the hour"
    "suggested_pickup_period" => "60"
    "location" => "Evansville, Evansville Regional Airport, IN"
    "station_id" => "KEVV"
    "latitude" => "38.04306"
    "longitude" => "-87.52028"
    "observation_time" => "Last Updated on May 17 2019, 2:54 pm CDT"
    "observation_time_rfc822" => "Fri, 17 May 2019 14:54:00 -0500"
    "weather" => "Fair"
    "temperature_string" => "87.0 F (30.6 C)"
    "temp_f" => "87.0"
    "temp_c" => "30.6"
    "relative_humidity" => "40"
    "wind_string" => "Southwest at 16.1 MPH (14 KT)"
    "wind_dir" => "Southwest"
    "wind_degrees" => "220"
    "wind_mph" => "16.1"
    "wind_kt" => "14"
    "pressure_string" => "1011.6 mb"
    "pressure_mb" => "1011.6"
    "pressure_in" => "29.89"
    "dewpoint_string" => "60.1 F (15.6 C)"
    "dewpoint_f" => "60.1"
    "dewpoint_c" => "15.6"
    "heat_index_string" => "87 F (31 C)"
    "heat_index_f" => "87"
    "heat_index_c" => "31"
    "visibility_mi" => "10.00"
    "icon_url_base" => "http://forecast.weather.gov/images/wtf/small/"
    "two_day_history_url" => "http://www.weather.gov/data/obhistory/KEVV.html"
    "icon_url_name" => "skc.png"
    "ob_url" => "http://www.weather.gov/data/METAR/KEVV.1.txt"
    "disclaimer_url" => "http://weather.gov/disclaimer.html"
    "copyright_url" => "http://weather.gov/disclaimer.html"
    "privacy_policy_url" => "http://weather.gov/notice.html"
]

Installation

You can install the package via composer:

composer require ahinkle/noaa

If you are using Laravel, it will autoregister the package itself, but you should still publish the config file yourself:

php artisan vendor:publish --provider="ahinkle\noaa\NoaaServiceProvider" --tag="config"

Configuring Your Weather Location

This package uses NOAA's Weather Stations to retrieve data. See http://www.weather.gov/xml/current_obs/ for more details and a list of Weather Stations.

You can also configure the Station automatically within the NOAA configuration file:

    return [
       /*
        * The Weather Station used to automatically retrieve current conditions.
        *
        * Options:
        *  null   - none set.
        *  'KEVV' - Example Weather Station.
        *
        *  More info & Station List: https://w1.weather.gov/xml/current_obs/
        */
        'station' => 'KEVV',
    ];

Usage

Using Laravel

Add the ahinkle\noaa\CurrentConditions class:

use ahinkle\noaa\CurrentConditions;

CurrentConditions::getWeatherByStation('KEVV');

Using PHP

$weather = new CurrentConditions();
$weather->getWeatherByStation('KEVV');

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

The Weather Services are provided by National Oceanic and Atmospheric Administration (NOAA), Please review the disclaimer at https://www.weather.gov/disclaimer. This package usage is under MIT License (MIT). Please see License File for more information.