getPWS: get an object of class "PWS"

Description Arguments Details Value See Also Examples

View source: R/getPWS.R

Description

Gets the nearby PWS (personal weather station) from http://www.wunderground.com based on a original search location and a distance range.

Arguments

lat

a numeric that specifies the latitude of the original search location; must be between -180 and 180

lon

a numeric that specifies the longitude of the original search location; must be between -180 and 180

zipcode

a numeric that specifies the zipcode of the original search location; only valid for locations within USA

city

a single character string that specifies the city of the original search location

state

a single character string that specifies the state of the original search location; should be supplied if the location is within USA

country

a single character string that specifies the country of the original search location; should be supplied if the location is outside USA

distance

a positive numeric which specifies the distance range of the nearby PWS from the original search location

Details

Three methods of specifying a original search location are defined. The function first searches the location by lat and lon if they are supplied. If lat and lon are not supplied, the function next searches the location by the zipcode if it is supplied. If again zipcode is not supplied, then the function searches the location by the city. If state is supplied, then the city will be searched within the USA. Otherwise if country is supplied, then the city will be searched outside the USA. The function then gets the nearby PWS of the original search location within a distance range which is specified by distance.

Value

An S4 object of class PWS-class containing the information about the original search location and the nearby PWS. The object contains the following slots:

city

a single character string that shows the city of the original search location

state

a single character string that shows the state of the original search location; is character(0) if the origin is outside the U.S.A

country

a single character string that shows the country of the original search location; is character(0) if the the origin is within the U.S.A

lat

a numeric that shows the latitude of the original search location; must be between -180 and 180

lon

a numeric that shows the longitude of the original search location; must be between -180 and 180

data

a data frame that contains the information of the nearby PWS; in particular, the columns of the data frame should be:

neighborhood

a single character string that shows the neighborhood of the PWS

city

a single character string that shows the city of the PWS

state

a single character string that shows the state of the PWS

country

a single character string that shows the country of the PWS

id

a numeric that shows the id of the PWS

lat

a numeric that shows the latitude of the PWS

lon

a numeric that shows the longitude of the PWS

distance_km

a positive integer that shows the distance from the PWS to the original search location in kilometers

distance_mi

a positive integer that shows the distance from the PWS to the original search location in miles

see PWS-class for more details

See Also

PWS-class

Examples

1
2
3
a = getPWS(zipcode = 94305)
b = getPWS(city = "San Francisco", state = "CA")
c = getPWS(lat = 37, lon = -120)

x265zhan/PWS documentation built on May 4, 2019, 1:05 p.m.