Skip to content

A Python wrapper for the NSW Government's Beachwatch API.

License

Notifications You must be signed in to change notification settings

ben-n93/beachwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

beachwatch 🏖️

Testing versions License

beachwatch is a Python wrapper for the NSW Government's Beachwatch API.

In their own words:

"Beachwatch and our partners monitor water quality at swim sites to ensure that recreational water environments are managed as safely as possible so that as many people as possible can benefit from using the water."

With this package you can retrieve data about a NSW beach's water pollution forecast, water quality rating, coordinates and more.

Installation

pip install beachwatch

Usage

There is only one function - get_beaches() function, which returns Beach objects:

>>> get_beaches() # Returns a list of all Beach objects.
>>> get_beaches("Bondi Beach") # Returns a list with the specified beach.
>>> get_beaches("Bondi Beach", "Whale Beach") # Returns a list with the specifies beaches.

The Beach object:

class Beach:
    """A NSW beach.

    Attributes
    ----------
    identifier : str
         Unknown but likely a unique ID within the Beachwatch database.
    name : str
         The name of the beach.
    pollution_forecast : str
         The latest water quality pollution forecast.
    pollution_forecast_timestamp : datetime.datetime
         What time the forecast was issued by Beachwatch.
    latest_result : str
         A water quality rating based on the number of bacteria (enterococci)
         in the most recent water sample.
    latest_result_rating : int
        The latest water quality result, rated from 1 to 4 to indicate
        suitability for swimming.
    latest_result_observation_timestamp : datetime.datetime
         The most recent sampling date.
    geometry : dict
         A GeoJSON feature with the coordinates of the beach.
    """

Note that the Beach object is not meant to be instantiated directly.

Example

>>> bondi = get_beaches("Bondi Beach")[0]
>>> bondi.pollution_forecast
    'Good'

Important

Beachwatch notes on their website that forecasts "are predictions of water quality only and are not 100% accurate. Beachwatch cannot guarantee the accuracy of any of the results or outputs from this model. Any reliance you place on such information is strictly at your own risk."