Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d66b78
commit 0f84970
Showing
7 changed files
with
55 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
Package: weatherr | ||
Type: Package | ||
Title: Tools for Handling and Scrapping Instant Weather Forecast Feeds | ||
Version: 0.1 | ||
Date: 2015-07-15 | ||
Version: 0.1.1 | ||
Date: 2015-08-25 | ||
Author: Stan Yip [aut, cre] | ||
Maintainer: Stan Yip <stanyip101@gmail.com> | ||
Description: Handle instant weather forecasts and geographical information. It combines multiple sources of information to obtain instant weather forecasts. | ||
Depends: ggmap, lubridate, RJSONIO, XML | ||
License: GPL (>= 2) | ||
Packaged: 2015-07-16 02:55:23 UTC; STANLEYCYYIP | ||
Packaged: 2015-08-26 04:28:32 UTC; STANLEYCYYIP | ||
NeedsCompilation: no | ||
Repository: CRAN | ||
Date/Publication: 2015-07-16 14:24:43 | ||
Date/Publication: 2015-08-26 08:50:30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
eaaae8a803e025ee222cd78d752466d3 *DESCRIPTION | ||
3b4870f0f6e59c248e34cc8655bfbfc1 *INDEX | ||
8e51f304e59de7643629189d2509e471 *DESCRIPTION | ||
584eb9909df0fae17be59fec04e8c06f *NAMESPACE | ||
b9bede9f12d8de4ccb9560d1195754c4 *R/locationforecast.R | ||
4c516856a860e022f50229a44359d92a *man/locationforecast.Rd | ||
8ec76daa34f08f980eba8e4f4baa7469 *man/weatherr-package.Rd | ||
0c7365448d96c16380cac482c07e706c *R/ggele.R | ||
180254083c663baef7ee26351fef203d *R/locationforecast.R | ||
c4578404743d1f1f76f841af174fa295 *man/ggele.Rd | ||
ef8c153667e7c906de2502441e7da569 *man/locationforecast.Rd | ||
2310e4a3f02068957d51cc7b69b0e0b0 *man/weatherr-package.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ggele = function(lat=0,lon=0, output=c('elevation','elevation/resolution','all')) { | ||
output <- match.arg(output) | ||
if ((length(lat) != length(lon)) | (any(abs(lat)>90)) | (any(abs(lon)>180))) stop('Longitude and latitude should have equal length and within the valid range') | ||
inpar = paste(paste0(lat,', ', lon),collapse = ' | ') | ||
url = paste0("http://maps.googleapis.com/maps/api/elevation/json?locations=", inpar) | ||
u = paste0(paste0(readLines(url), collapse = "\n"), "\n") | ||
tmp = try(RJSONIO::fromJSON(u)) | ||
if (class(tmp) == 'try-error') stop('Error: fail to obtain data from Google Elevation API') | ||
if (tmp$status != 'OK') stop('Request denied') | ||
switch(output, 'elevation' = {y=sapply(tmp$results,function(x) x$elevation);names(y)=1:length(tmp$results);y}, 'elevation/resolution' = {y=sapply(tmp$results,function(x) c(x$elevation,x$resolution));y=as.data.frame(y);colnames(y)=1:length(tmp$results);rownames(y) = c('elevation','resolution');y}, all = tmp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
\name{ggele} | ||
\alias{ggele} | ||
|
||
\title{Elevation of a set of specific locations} | ||
|
||
\description{Obtaining elevation at a set of given locations. Note that using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms. | ||
} | ||
|
||
\usage{ggele(lat=0,lon=0, output=c('elevation','elevation/resolution','all'))} | ||
\arguments{ | ||
\item{lat, lon}{numeric objects. latitude and longitude of a location in decimal degrees} | ||
|
||
\item{output}{elevation; elevation and its corresponding resolution or the original JSON output (in a list format)} | ||
|
||
} | ||
\value{ | ||
\item{}{If output="elevation", a numeric vector is returned with the elevation in metres.} | ||
\item{}{If output="elevation/resolution", a data frame is return with the elevation and its corresponding resolution in metres.} | ||
\item{}{If output="all", a list is returned with full JSON query output.} | ||
} | ||
|
||
\author{Stan Yip} | ||
|
||
\examples{ | ||
# Get the elevation of a location in Hong Kong | ||
ggele(lat=22.39643,lon=114.1095) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters