Skip to content

Commit effea0a

Browse files
authored
Merge pull request #2189 from MichaelChirico/avoid-1-to
Avoid 1: for possibly-empty input
2 parents de32186 + 9774373 commit effea0a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

R/break_antimeridian.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ st_within_pm180 <- function(x, tol=0.0001) {
100100
xcrs = st_crs(x)
101101
xnames = names(x)
102102
xnames = xnames[grep(attr(x, "sf_column"), xnames, invert=TRUE)]
103-
x$st_within_pm180_ID = as.character(1:nrow(x))
103+
x$st_within_pm180_ID = as.character(seq_len(nrow(x)))
104104
s2_status = sf_use_s2()
105105
sf_use_s2(FALSE) # avoid s2 because we need a planar bounding box
106106
bb0 = st_bbox(x)

R/sample.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ st_sample.sfc = function(x, size, ..., type = "random", exact = TRUE, warn_if_no
110110
ret = if (progress) {
111111
if (!requireNamespace("pbapply", quietly = TRUE))
112112
stop("package pbapply required, please install it first")
113-
pbapply::pblapply(1:length(x), function(i) st_sample(x[i], size[i], type = type, exact = exact, ...))
113+
pbapply::pblapply(seq_along(x), function(i) st_sample(x[i], size[i], type = type, exact = exact, ...))
114114
} else
115-
lapply(1:length(x), function(i) st_sample(x[i], size[i], type = type, exact = exact, ...))
115+
lapply(seq_along(x), function(i) st_sample(x[i], size[i], type = type, exact = exact, ...))
116116
st_set_crs(do.call(c, ret), st_crs(x))
117117
} else {
118118
res = switch(max(st_dimension(x)) + 1,

R/sp.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ st_as_sfc.SpatialPolygons = function(x, ..., precision = 0.0, forceMulti = FALSE
165165
cp0 <- st_contains(raw0[!holes], raw0[holes])
166166
areas <- sapply(slot(pl, "Polygons"), slot, "area")
167167
hole_assigned <- rep(FALSE, sum(holes))
168-
names(cp0) <- 1:length(cp0)
168+
names(cp0) <- seq_along(cp0)
169169
cp1 <- cp0[order(areas[!holes])]
170170
for (i in seq_along(cp1)) {
171171
cp1i <- cp1[[i]]

0 commit comments

Comments
 (0)