Skip to content

A handy function to create a simple anemometer plot for anywhere in the world

License

Notifications You must be signed in to change notification settings

cjabradshaw/Anemometer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Anemometer function in R

Anemometer

A handy function to create a simple anemometer plot for anywhere in the world in R.

Installation & Set-up

  1. Install ansiweather in the command line (Terminal) via any one of following: OpenBSD, NetBSD, FreeBSD, Debian, Ubuntu, or Homebrew. I use Homebrew on my Mac via: $ brew install ansiweather

ansiweather fetches weather data from OpenWeatherMap's free API

Access ansiweather's manual for more information

  1. Install the following libraries in R:

You can do this easily with the following command:

install.packages(c("jsonlite", "processx", "lutz", "lubridate", "caroline", "rlang", "rgbif"))

  1. Pre-load the city file, which is the location JSON (Javascript Object Notation) database ansiweather uses to identify place names. You could add this to the function itself, but it slows processing down considerably, so it's best to load before running the function.

cityfile <- jsonlite::fromJSON(gzcon(url("https://bulk.openweathermap.org/sample/city.list.json.gz")))

The 2-digit ISO country code can be found here, and you can access various versions and scales of the source JSON database here.

  1. Should you wish the elevation (metres above sea level; 'm asl') of the location to be displayed on the plot, you will need to register for a free user name on the GeoNames geographical database. Once you approve your account, ensure that you enable free webservices on your 'manage account' page.

  2. Run both the functions plotCompass and AnemometerFunction in R (the former is invoked by the latter; both scripts are included together in AnemometerFunction.R), then you're ready to plot a real-time anemometer (including windspeed, wind direction temperature, humidity, air pressure, latitude, longitude, date, time, and elevation (optional) as in the example plot above).

Note: if you registered at GeoNames, you need to include your user name using the option GEONAMES_USERNAME="my_user_name"; if you do not provide a user name, the elevation will return 'no elev data' in the plot.

Some examples:

  • AnemometerFunc(Place="Adelaide,AU", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Darlington,AU", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Hobart,AU", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Perth,AU", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Port Moresby,PG", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Dunedin,NZ", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Wellington,NZ", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Sapporo,JP", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Helsinki,FI", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Paris,FR", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Kyiv,UA", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Reykjavik,IS", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Vancouver,CA", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Whitehorse,CA", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Sachs Harbour,CA", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Rimouski,CA", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Ushuaia,AR", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Punta Arenas,CL", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Agadez,NE", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Dar es Salaam,TZ", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Phalaborwa,ZA", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Kolkata,IN", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")
  • AnemometerFunc(Place="Bengaluru,IN", PlaceFile=cityfile, GEONAMES_USERNAME="my_user_name")

Thylacoleo

Note that the arrow's line width varies as a function of windspeed (thicker with higher speeds), that the colour of the temperature text (T) on the plot varies from blue to red (cold to hot), that the humidity (H) display varies from yellow to dark blue (dry to wet), and that the pressure (P) ranges from dark red, red, pink, to orange (very low, low, moderate, high).


Prof Corey J. A. Bradshaw
Global Ecology, Flinders University, Adelaide, Australia
March 2022
e-mail