Skip to content

Commit f2af871

Browse files
committed
update-package
1 parent 8884657 commit f2af871

23 files changed

+738
-731
lines changed

‎LICENSE‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
1-
MIT License
2-
3-
Copyright (c) 2020 Kauê de Sousa
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
YEAR: 2020
2+
COPYRIGHT HOLDER: Kauê de Sousa

‎LICENSE.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Kauê de Sousa
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎NEWS.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
chirps 1.1 (2025-11-24)
2+
=========================
3+
4+
* Housekeeping version to refresh libraries and formats as part of CRAN guidelines updates.
5+
16
chirps 0.1.4.001 (2022-01-15)
27
=========================
38

‎R/GET.R‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@
2020
#' @examples
2121
#' example("tapajos", package = "chirps")
2222
#'
23-
#' dates <- c("05/01/2017", "01/31/2018")
23+
#' dates = c("05/01/2017", "01/31/2018")
2424
#'
25-
#' operation <- 5
25+
#' operation = 5
2626
#'
27-
#' datatype <- 29
27+
#' datatype = 29
2828
#'
2929
#' chirps:::.GET(gjson, dates, operation, datatype)
3030
#'
3131
#'@noRd
32-
.GET <- function(gjson,
32+
.GET = function(gjson,
3333
dates,
3434
operation = NULL,
3535
datatype = NULL) {
3636
message("\nFetching data from ClimateSERV \n")
3737

38-
begindate <- dates[1]
39-
enddate <- dates[2]
38+
begindate = dates[1]
39+
enddate = dates[2]
4040

4141
# submit data request and get ids
42-
ids <- lapply(gjson, function(x) {
43-
i <- .send_request(
42+
ids = lapply(gjson, function(x) {
43+
i = .send_request(
4444
datatype = datatype,
4545
begintime = begindate,
4646
endtime = enddate,
@@ -55,42 +55,42 @@
5555

5656
# check request progress and wait
5757
# until the request is done by the server
58-
request_progress <- seq_along(ids) == FALSE
58+
request_progress = seq_along(ids) == FALSE
5959

60-
nids <- max(seq_along(ids))
60+
nids = max(seq_along(ids))
6161

6262
message("\nGetting your request...\n")
6363

6464
while (isFALSE(all(request_progress))) {
65-
request_progress <- lapply(ids, function(x) {
66-
p <- .get_request_progress(x)
65+
request_progress = lapply(ids, function(x) {
66+
p = .get_request_progress(x)
6767

6868
})
6969

70-
request_progress <- unlist(request_progress)
70+
request_progress = unlist(request_progress)
7171

7272
}
7373

7474
# get data from request
75-
result <- lapply(ids, function(x) {
76-
d <- .get_data_from_request(id = x)
75+
result = lapply(ids, function(x) {
76+
d = .get_data_from_request(id = x)
7777

7878
return(d)
7979

8080
})
8181

8282
# define ids
83-
ids <- NULL
83+
ids = NULL
8484
for (i in seq_along(result)) {
85-
nr <- dim(result[[i]])[[1]]
85+
nr = dim(result[[i]])[[1]]
8686

87-
ids <- c(ids, rep(i, nr))
87+
ids = c(ids, rep(i, nr))
8888

8989
}
9090

91-
result <- do.call("rbind", result)
91+
result = do.call("rbind", result)
9292

93-
nr <- dim(result)[[1]]
93+
nr = dim(result)[[1]]
9494

9595
if (nr == 0) {
9696
stop("Failed to get valid values,
@@ -99,27 +99,27 @@
9999
}
100100

101101
# add ids
102-
result$id <- ids
102+
result$id = ids
103103

104104
# transform dates to the original format as input
105-
dat <- strsplit(result$date, "/")
106-
dat <- do.call("rbind", dat)
107-
dat <- paste(dat[, 3], dat[, 1], dat[, 2], sep = "-")
108-
result$date <- as.Date(dat, format = "%Y-%m-%d")
105+
dat = strsplit(result$date, "/")
106+
dat = do.call("rbind", dat)
107+
dat = paste(dat[, 3], dat[, 1], dat[, 2], sep = "-")
108+
result$date = as.Date(dat, format = "%Y-%m-%d")
109109

110-
names(result) <- c("date", "value", "id")
110+
names(result) = c("date", "value", "id")
111111

112-
rownames(result) <- seq_len(nr)
112+
rownames(result) = seq_len(nr)
113113

114-
result <- result[, c("id", "date", "value")]
114+
result = result[, c("id", "date", "value")]
115115

116-
result <- result[order(result$date),]
116+
result = result[order(result$date),]
117117

118-
result <- result[order(result$id),]
118+
result = result[order(result$id),]
119119

120-
result[result == -9999] <- NA
120+
result[result == -9999] = NA
121121

122-
class(result) <- union("chirps_df", class(result))
122+
class(result) = union("chirps_df", class(result))
123123

124124
return(result)
125125

‎R/as.geojson.R‎

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#' library("sf")
1919
#'
2020
#' set.seed(123)
21-
#' lonlat <- data.frame(lon = runif(1, 10, 12),
21+
#' lonlat = data.frame(lon = runif(1, 10, 12),
2222
#' lat = runif(1, 45, 47))
2323
#'
24-
#' gjson <- as.geojson(lonlat)
24+
#' gjson = as.geojson(lonlat)
2525
#'
2626
#' #################
2727
#'
@@ -30,16 +30,16 @@
3030
#' library("sf")
3131
#'
3232
#' set.seed(123)
33-
#' lonlat <- data.frame(lon = runif(5, 10, 12),
33+
#' lonlat = data.frame(lon = runif(5, 10, 12),
3434
#' lat = runif(5, 45, 47))
3535
#'
36-
#' lonlat <- st_as_sf(lonlat, coords = c("lon","lat"))
36+
#' lonlat = st_as_sf(lonlat, coords = c("lon","lat"))
3737
#'
38-
#' gjson <- as.geojson(lonlat)
38+
#' gjson = as.geojson(lonlat)
3939
#'
4040
#' @importFrom sf st_point st_sfc st_buffer st_write st_as_sf
4141
#' @export
42-
as.geojson <- function(lonlat,
42+
as.geojson = function(lonlat,
4343
dist = 0.00001,
4444
nQuadSegs = 2L,
4545
...) {
@@ -48,61 +48,61 @@ as.geojson <- function(lonlat,
4848

4949
#' @rdname as.geojson
5050
#' @export
51-
as.geojson.default <- function(lonlat,
51+
as.geojson.default = function(lonlat,
5252
dist = 0.00001,
5353
nQuadSegs = 2L,
5454
...) {
55-
n <- dim(lonlat)[[1]]
55+
n = dim(lonlat)[[1]]
5656

5757
# lonlat into matrix
58-
lonlat <- as.matrix(lonlat)
58+
lonlat = as.matrix(lonlat)
5959

6060
# split lonlat by rows
61-
lonlat <- split(lonlat, seq_len(n))
61+
lonlat = split(lonlat, seq_len(n))
6262

6363
# transform into sf points
64-
lonlat <- lapply(lonlat, function(l) {
64+
lonlat = lapply(lonlat, function(l) {
6565
sf::st_point(l)
6666
})
6767

6868
# and then into a geometry list column
69-
lonlat <- sf::st_sfc(lonlat,
69+
lonlat = sf::st_sfc(lonlat,
7070
crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
7171

7272
# set the buffer around the points
73-
lonlatb <- sf::st_buffer(lonlat,
73+
lonlatb = sf::st_buffer(lonlat,
7474
dist = dist,
7575
nQuadSegs = nQuadSegs)
7676

7777
# transform into a sf object
78-
lonlatb <- sf::st_as_sf(x = lonlatb)
78+
lonlatb = sf::st_as_sf(x = lonlatb)
7979

8080

8181
# write the geojson string
82-
tf <- tempfile(fileext = ".geojson")
82+
tf = tempfile(fileext = ".geojson")
8383
sf::st_write(lonlatb, tf, quiet = TRUE)
8484

8585
# capture these strings
86-
gj <- readLines(tf)
86+
gj = readLines(tf)
8787

8888
# keep only the geometry vectors
89-
index <- which(grepl("geometry", unlist(gj)))
89+
index = which(grepl("geometry", unlist(gj)))
9090

91-
gj <- gj[index]
91+
gj = gj[index]
9292

9393
# remove spaces and extra commas
94-
gj <- lapply(gj, function(x) {
95-
x <- strsplit(x, "},")[[1]][2]
96-
x <- gsub(" ", "", x)
97-
x <- gsub("}},", "}}", x)
98-
x <- gsub('"geometry\":', "", x)
99-
x <- gsub(']}}', "]}", x)
94+
gj = lapply(gj, function(x) {
95+
x = strsplit(x, "},")[[1]][2]
96+
x = gsub(" ", "", x)
97+
x = gsub("}},", "}}", x)
98+
x = gsub('"geometry\":', "", x)
99+
x = gsub(']}}', "]}", x)
100100
x
101101
})
102102

103-
result <- unlist(gj)
103+
result = unlist(gj)
104104

105-
class(result) <- c("geojson", "json", class(result))
105+
class(result) = c("geojson", "json", class(result))
106106

107107
return(result)
108108

@@ -111,15 +111,15 @@ as.geojson.default <- function(lonlat,
111111
#' @rdname as.geojson
112112
#' @method as.geojson sf
113113
#' @export
114-
as.geojson.sf <- function(lonlat,
114+
as.geojson.sf = function(lonlat,
115115
dist = 0.00001,
116116
nQuadSegs = 2L,
117117
...) {
118118
# check geometry type
119-
type <- c("POINT", "POLYGON")
119+
type = c("POINT", "POLYGON")
120120

121121
# check for supported types
122-
supp_type <-
122+
supp_type =
123123
c(all(grepl(type[[1]], sf::st_geometry_type(lonlat))),
124124
all(grepl(type[[2]], sf::st_geometry_type(lonlat))))
125125

@@ -130,53 +130,53 @@ as.geojson.sf <- function(lonlat,
130130
)
131131
}
132132

133-
type <- type[which(supp_type)]
133+
type = type[which(supp_type)]
134134

135135
if (type == "POINT") {
136-
n <- dim(lonlat)[[1]]
136+
n = dim(lonlat)[[1]]
137137

138138
# set the buffer around the points
139-
lonlatb <- sf::st_buffer(lonlat,
139+
lonlatb = sf::st_buffer(lonlat,
140140
dist = dist,
141141
nQuadSegs = nQuadSegs,
142142
...)
143143

144144
# transform into a sf object
145-
lonlatb <- sf::st_as_sf(lonlatb,
145+
lonlatb = sf::st_as_sf(lonlatb,
146146
crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
147147
}
148148

149149
if (type == "POLYGON") {
150-
lonlatb <- lonlat
150+
lonlatb = lonlat
151151

152152
}
153153

154154

155155
# write the geojson string
156-
tf <- tempfile(fileext = ".geojson")
156+
tf = tempfile(fileext = ".geojson")
157157
sf::st_write(lonlatb, tf, quiet = TRUE)
158158

159159
# capture these strings
160-
gj <- readLines(tf)
160+
gj = readLines(tf)
161161

162162
# keep only the geometry vectors
163-
index <- which(grepl("geometry", unlist(gj)))
163+
index = which(grepl("geometry", unlist(gj)))
164164

165-
gj <- gj[index]
165+
gj = gj[index]
166166

167167
# remove spaces and extra commas
168-
gj <- lapply(gj, function(x) {
169-
x <- strsplit(x, "},")[[1]][2]
170-
x <- gsub(" ", "", x)
171-
x <- gsub("}},", "}}", x)
172-
x <- gsub('"geometry\":', "", x)
173-
x <- gsub(']}}', "]}", x)
168+
gj = lapply(gj, function(x) {
169+
x = strsplit(x, "},")[[1]][2]
170+
x = gsub(" ", "", x)
171+
x = gsub("}},", "}}", x)
172+
x = gsub('"geometry\":', "", x)
173+
x = gsub(']}}', "]}", x)
174174
x
175175
})
176176

177-
result <- unlist(gj)
177+
result = unlist(gj)
178178

179-
class(result) <- c("geojson", "json", class(result))
179+
class(result) = c("geojson", "json", class(result))
180180

181181
return(result)
182182

0 commit comments

Comments
 (0)