This package was created to ease the process of looking up the Koppen-Geiger Climate Zones for areas. Within this package, one will find helper functions and look up functions.
These functions within the package help in formatting the data in a way that will lead to a climate zone being predicted.
RoundCoordinates
As of right now, the data available to help identify a Koppen-Geiger Climate Zone only supports co-ordinates that end in either .25 or .75. This function will then round the inputed parameter to end in one of these patterns. In the case of a number being equally distant from .25 and .75, it will round up for the counting numbers and round down for those that are not.
Requires a numeric argument and returns the numeric, rounded integer
TranslateZipCode
This function will take a given zip code and provide the longitude and latitude for that location. These co-ordinates are what will be used to look up the climate zone. The longitude and latitude information is according to the 2016 U.S. Census Data.
Requires a numeric argument and returns a data frame with the zip code, longitude, and latitude. Parameters can be one individual zip code or a dataframe with a numeric column titled ‘zip’
RunExample
This function will run the shiny app found within this package. This shiny app will hide the function calls so that the user does not need to worry about creating data frames or labeling columns appropriately. All that is needed is either a zip code or longitude and latitude co-ordinates for a location.
To start the shiny app, simply call “RunExample()”
These functions will search for the climate zone
LookUpCZ
The function will then use these two columns to look up the Koppen Geiger Climate Zone for that location.
The function returns the predicted climate zone for that location.
CZUncertainty
roundCoord.lon: The rounded longitude coordinate
This function will return the uncertainty associated with the predicted climate zone along with other possible climate zones that an area may be in
One use case would be to call RunExample() and enter an areas coordinates or zip code.
An example of how to use all of the functions together to get information about a location can be found below.
library("kgc")
data <- data.frame(site = c("GC","UFS","NEG"), zip = c(44106, 96701, 80019))
data <- data.frame(TranslateZipCode(data))
data
## site zip Latitude Longitude
## 1 GC 44106 41.50534 -81.60543
## 2 UFS 96701 21.40605 -157.88495
## 3 NEG 80019 39.78962 -104.69935
data <- data.frame(data, rndCoord.lat = RoundCoordinates(data$Latitude), rndCoord.lon = RoundCoordinates(data$Longitude))
data
## site zip Latitude Longitude rndCoord.lat rndCoord.lon
## 1 GC 44106 41.50534 -81.60543 41.75 -81.75
## 2 UFS 96701 21.40605 -157.88495 21.25 -157.75
## 3 NEG 80019 39.78962 -104.69935 39.75 -104.75
data <- data.frame(data,ClimateZ=LookupCZ(data))
data
## site zip Latitude Longitude rndCoord.lat rndCoord.lon ClimateZ
## 1 GC 44106 41.50534 -81.60543 41.75 -81.75 Dfa
## 2 UFS 96701 21.40605 -157.88495 21.25 -157.75 As
## 3 NEG 80019 39.78962 -104.69935 39.75 -104.75 BSk
data <- data.frame(data, CZUncertainty(data))
data
## site zip Latitude Longitude rndCoord.lat rndCoord.lon ClimateZ
## 1 GC 44106 41.50534 -81.60543 41.75 -81.75 Dfa
## 2 UFS 96701 21.40605 -157.88495 21.25 -157.75 As
## 3 NEG 80019 39.78962 -104.69935 39.75 -104.75 BSk
## uncertainty possible.cz
## 1 0.5714286 Dfb
## 2 0.1666667 Af
## 3 0.2222222 Dfb
rename(data, c("rndCoord.lat" = "rounded lat", "rndCoord.lon" = "rounded long", "ClimateZ" = "predicted KG-CZ", "possible.cz"="possible KG-CZ"))
## site zip Latitude Longitude rounded lat rounded long predicted KG-CZ
## 1 GC 44106 41.50534 -81.60543 41.75 -81.75 Dfa
## 2 UFS 96701 21.40605 -157.88495 21.25 -157.75 As
## 3 NEG 80019 39.78962 -104.69935 39.75 -104.75 BSk
## uncertainty possible KG-CZ
## 1 0.5714286 Dfb
## 2 0.1666667 Af
## 3 0.2222222 Dfb