Skip to content

Commit 4713008

Browse files
committed
Merge branch 'main' into pointx
2 parents dcda1fd + c719ecb commit 4713008

File tree

9 files changed

+56
-17
lines changed

9 files changed

+56
-17
lines changed

.github/workflows/rcmdcheck.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [main, master]
66
pull_request:
77
branches: [main, master]
8+
schedule:
9+
- cron: "0 4 * * *"
810

911
name: R-CMD-check
1012

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# version 1.0-13
22

3+
* add `rename_with.sf()` method; #1472
4+
35
* use GEOS' overlayNG routines for (GEOS) Intersection, Difference, Union and SymDifference; #2143
46

57
* added `duplicated.sf()`; #2138, #2140, thanks to @bart1

R/geom-predicates.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ st_is_within_distance = function(x, y = x, dist, sparse = TRUE, ...) {
259259
ret = if (isTRUE(st_is_longlat(x))) {
260260
units(dist) = as_units("m") # might convert
261261
r = if (sf_use_s2()) {
262-
if (inherits(dist, "units"))
263-
dist = drop_units(dist)
264-
s2::s2_dwithin_matrix(x, y, dist, ...)
265-
} else {
266-
if (!requireNamespace("lwgeom", quietly = TRUE) ||
267-
utils::packageVersion("lwgeom") <= "0.1-2")
268-
stop("lwgeom > 0.1-2 required: install first?")
269-
lwgeom::st_geod_distance(x, y, tolerance = dist, sparse = TRUE)
270-
}
262+
if (inherits(dist, "units"))
263+
dist = drop_units(dist)
264+
s2::s2_dwithin_matrix(x, y, dist, ...)
265+
} else {
266+
if (!requireNamespace("lwgeom", quietly = TRUE) ||
267+
utils::packageVersion("lwgeom") <= "0.1-2")
268+
stop("lwgeom > 0.1-2 required: install first?")
269+
lwgeom::st_geod_distance(x, y, tolerance = dist, sparse = TRUE)
270+
}
271271
sgbp(r, predicate = "is_within_distance", region.id = seq_along(x),
272272
ncol = length(st_geometry(y)))
273273
} else {

R/plot.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,13 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer
788788
#' @param axes ignore
789789
#' @param logz ignore
790790
#' @param ... ignore
791+
#' @param lab ignore
791792
.image_scale = function(z, col, breaks = NULL, key.pos, add.axis = TRUE,
792-
at = NULL, ..., axes = FALSE, key.length, logz = FALSE) {
793+
at = NULL, ..., axes = FALSE, key.length, logz = FALSE, lab = "") {
793794
if (!is.null(breaks) && length(breaks) != (length(col) + 1))
794795
stop("must have one more break than colour")
796+
stopifnot(is.character(lab) || is.expression(lab))
797+
lab_set = (is.character(lab) && lab != "") || is.expression(lab)
795798
zlim = range(z, na.rm = TRUE)
796799
if (is.null(breaks))
797800
breaks = seq(zlim[1], zlim[2], length.out = length(col) + 1)
@@ -819,14 +822,16 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer
819822
xlim = c(0, 1)
820823
mar = c(ifelse(axes, 2.1, 1), 0, 1.2, 0)
821824
}
822-
mar[key.pos] = 2.1
825+
mar[key.pos] = 2.1 + 1.5 * lab_set
823826
par(mar = mar)
824827

828+
plot(1, 1, t = "n", ylim = ylim, xlim = xlim, axes = FALSE,
829+
xlab = "", ylab = "", xaxs = "i", yaxs = "i")
830+
if (lab != "")
831+
mtext(lab, side = key.pos, line = 2.5, cex = .8)
825832
poly = vector(mode="list", length(col))
826833
for (i in seq(poly))
827834
poly[[i]] = c(breaks[i], breaks[i+1], breaks[i+1], breaks[i])
828-
plot(1, 1, t = "n", ylim = ylim, xlim = xlim, axes = FALSE,
829-
xlab = "", ylab = "", xaxs = "i", yaxs = "i")
830835
offset = 0.2
831836
offs = switch(key.pos,
832837
c(0,0,-offset,-offset),

R/tidyverse.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,18 @@ rename.sf <- function(.data, ...) {
235235
st_set_agr(st_as_sf(ret, sf_column_name = sf_column), agr)
236236
}
237237

238+
rename_with.sf = function(.data, .fn, .cols, ...) {
239+
if (!requireNamespace("rlang", quietly = TRUE))
240+
stop("rlang required: install that first") # nocov
241+
.fn = rlang::as_function(.fn)
242+
agr = st_agr(.data)
243+
ret = NextMethod()
244+
names(agr) = .fn(names(agr))
245+
st_agr(ret) = agr
246+
ret
247+
}
248+
249+
238250
#' @name tidyverse
239251
#' @examples
240252
#' if (require(dplyr, quietly = TRUE)) {
@@ -634,6 +646,7 @@ register_all_s3_methods = function() {
634646
register_s3_method("dplyr", "left_join", "sf")
635647
register_s3_method("dplyr", "mutate", "sf")
636648
register_s3_method("dplyr", "rename", "sf")
649+
register_s3_method("dplyr", "rename_with", "sf")
637650
register_s3_method("dplyr", "right_join", "sf")
638651
register_s3_method("dplyr", "rowwise", "sf")
639652
register_s3_method("dplyr", "sample_frac", "sf")

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<!-- badges: start -->
22
[![rcmdcheck](https://github.com/r-spatial/sf/actions/workflows/rcmdcheck.yml/badge.svg?branch=main)](https://github.com/r-spatial/sf/actions/workflows/rcmdcheck.yml)
3-
[![tic](https://github.com/r-spatial/sf/workflows/tic/badge.svg?branch=main)](https://github.com/r-spatial/sf/actions)
43
[![tic-db](https://github.com/r-spatial/sf/workflows/tic-db/badge.svg?branch=main)](https://github.com/r-spatial/sf/actions)
54
[![Coverage Status](https://img.shields.io/codecov/c/github/r-spatial/sf/main.svg)](https://app.codecov.io/gh/r-spatial/sf)
65
[![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)

man/stars.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mdim.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,23 @@ List CPL_write_mdim(CharacterVector name, CharacterVector driver, IntegerVector
367367
std::vector<std::shared_ptr<GDALDimension>> all_dims;
368368
for (int i = dimensions.size() - 1; i >= 0; i--) { // backwards, for whatever reason
369369
std::string type;
370+
std::string direction = "";
370371
if (dimnames[i] == xy[0]) // "x"
371372
type = "HORIZONTAL_X";
372373
else if (dimnames[i] == xy[1]) // "y"
373374
type = "HORIZONTAL_Y";
374-
else if (dimnames[i] == "time")
375+
else if (dimnames[i] == "depth") {
376+
type = "VERTICAL";
377+
direction = "DOWN";
378+
} else if (dimnames[i] == "height") {
379+
type = "VERTICAL";
380+
direction = "UP";
381+
} else if (dimnames[i] == "time")
375382
type = "TEMPORAL";
376383
else
377384
type = "";
378385
const char *name = dimnames[i];
379-
std::shared_ptr<GDALDimension> d = g->CreateDimension(name, type, "", dimensions[i], nullptr);
386+
std::shared_ptr<GDALDimension> d = g->CreateDimension(name, type, direction, dimensions[i], nullptr);
380387
if (d == nullptr)
381388
stop("creation of dimension failed");
382389
all_dims.push_back(d);

tic.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# installs dependencies, runs R CMD check, runs covr::codecov()
2+
do_package_checks()
3+
4+
if (ci_on_ghactions() && ci_has_env("BUILD_PKGDOWN")) {
5+
# creates pkgdown site and pushes to gh-pages branch
6+
# only for the runner with the "BUILD_PKGDOWN" env var set
7+
do_pkgdown()
8+
}

0 commit comments

Comments
 (0)