daily_observed_area: daily_observed_area

Description Usage Arguments Details Value References Examples

View source: R/weather-daily.R

Description

daily_observed_area pulls historical weather data from aWhere's API based on a data.frame of lat/lon, polygon or extent

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
daily_observed_area(
  polygon,
  day_start,
  day_end,
  propertiesToInclude = "",
  numcores = 2,
  bypassNumCallCheck = FALSE,
  returnSpatialData = FALSE,
  verbose = TRUE,
  maxTryCount = 3,
  keyToUse = awhereEnv75247$uid,
  secretToUse = awhereEnv75247$secret,
  tokenToUse = awhereEnv75247$token,
  apiAddressToUse = awhereEnv75247$apiAddress
)

Arguments

polygon

either a data.frame with column names lat/lon, SpatialPolygons object, well-known text string, or extent from raster package. If the object contains multiple polygons, the union of them is used. Information from each individal polygon can be retrieved by returning spatial data and using the over function from the sp package

day_start

character string of the first day for which you want to retrieve data, in the form: YYYY-MM-DD

day_end

character string of the last day for which you want to retrieve data, in the form: YYYY-MM-DD

propertiesToInclude

character vector of properties to retrieve from API. Valid values are temperatures, precipitation, solar, relativeHumidity, wind (optional)

bypassNumCallCheck

set to TRUE to avoid prompting the user to confirm that they want to begin making API calls

returnSpatialData

returns the data as a SpatialPixels object. Can be convered to raster with the command raster::stack NOTE: if multiple days worth of data is returned, it is necessary to subset to specific day for working with as spatial data (sp package: optional)

verbose

Set to TRUE tp print messages to console about state of parallization call. Typically only visible if run from console and not GUI

maxTryCount

maximum number of times a call is repeated if the the API returns an error. Random pause between each call

keyToUse

aWhere API key to use. For advanced use only. Most users will not need to use this parameter (optional)

secretToUse

aWhere API secret to use. For advanced use only. Most users will not need to use this parameter (optional)

tokenToUse

aWhere API token to use. For advanced use only. Most users will not need to use this parameter (optional)

apiAddressToUse

Address of aWhere API to use. For advanced use only. Most users will not need to use this parameter (optional)

numcores:

number of cores to use in parallel loop. To check number of available cores: parallel::detectCores() If you receive an error regarding the speed you are making calls, reduce this number

Details

This function returns weather data on Min/Max Temperature, Precipitation, Min/Max Humidity, Solar Radiation, and Maximum Wind Speed, Morning Max Windspeed, and Average Windspeed for the polygon passed to the function. Default units are returned by the API. The polygon should be either a SpatialPolygons object or a well-known text character string or an extent.

The Weather APIs provide access to aWhere's agriculture-specific Weather Terrain system, and allows retrieval and integration of data across all different time ranges, long term normals, daily observed, current weather, and forecasts. These APIs are designed for efficiency, allowing you to customize the responses to return just the attributes you need.

Understanding the recent and long-term daily weather is critical for making in-season decisions. This API opens the weather attributes that matter most to agriculture.

Note about dates: The system does not adjust for any difference in dates between the location of the user and where data is being requested from. It is the responsibility of the user to ensure a valid date range is specified given any differences in timezone. These differences can have implications for whether a given date should be requested from the daily_observed functions or the forecast functions. Furthermore, because this function can take as input locations that may be in different timezones, it is the responsibility of the user to either ensure that the date range specified is valid for all relevant locations or to break the query into pieces.

Value

data.frame of requested data for dates requested

References

https://docs.awhere.com/knowledge-base-docs/daily-observed-weather-by-geolocation/

Examples

1
2
3
4
5
6
## Not run: daily_observed_area(polygon = raster::getData('GADM', country = "Gambia", level = 0, download = T),
                               ,day_start = '2018-04-28'
                               ,day_end = '2018-05-01'
                               ,numcores = 2)
## End(Not run)
                               

aWhereAPI/aWhere-R-Library documentation built on Nov. 5, 2021, 3:35 a.m.