Skip to content

Commit

Permalink
Merge branch 'main' into merge_name
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed May 20, 2024
2 parents 18f63e3 + 56e2d9b commit 085b046
Show file tree
Hide file tree
Showing 96 changed files with 728 additions and 444 deletions.
4 changes: 2 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ rdev
hub
tic.R
NOTES
^\.github/workflows/R-CMD-check\.yaml$
^\.github/workflows/R-CMD-check-with-db\.yaml$
^\.ccache$
^\.github$
^tic\.R$
vignettes.awk
^\.gitattributes$
_pkgdown.yml
docs
pkgdown
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -36,13 +38,12 @@ jobs:

- uses: r-lib/actions/setup-r@v2
with:
rtools-version: '42'
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: Install macOS system dependencies
if: runner.os == 'macOS'
if: runner.os == 'macos'
run: brew install gdal proj

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand All @@ -39,7 +41,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::XML
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

Expand All @@ -44,7 +44,7 @@ jobs:

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
4 changes: 2 additions & 2 deletions .github/workflows/tic-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:

- name: "[Stage] Upload R CMD check artifacts"
if: failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ nc.prj
nc.dbf
nc.shx
docs/
tests/testthat/Rplots.pdf
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: sf
Version: 1.0-16
Version: 1.0-17
Title: Simple Features for R
Authors@R:
c(person(given = "Edzer",
Expand Down Expand Up @@ -78,7 +78,7 @@ Suggests:
dplyr (>= 1.0.0),
ggplot2,
knitr,
lwgeom (>= 0.2-1),
lwgeom (>= 0.2-14),
maps,
mapview,
Matrix,
Expand Down Expand Up @@ -113,14 +113,16 @@ LinkingTo:
VignetteBuilder:
knitr
Encoding: UTF-8
RoxygenNote: 7.3.0
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 2
Config/needs/coverage: XML
SystemRequirements: GDAL (>= 2.0.1), GEOS (>= 3.4.0),
PROJ (>= 4.8.0), sqlite3
Collate:
'RcppExports.R'
'init.R'
'import-standalone-s3-register.R'
'crs.R'
'bbox.R'
'read.R'
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ export(gdal_utils)
export(gdal_write)
export(gdal_write_mdim)
export(get_key_pos)
export(pivot_wider.sf)
export(plot_sf)
export(rawToHex)
export(read_sf)
Expand Down
18 changes: 17 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# version 1.0-16
# version 1.0-17

* `st_sf()` no longer strips `tbl` or `tbl_df` class labels; #2378

* `st_layers()` returns an object of class `c("sf_layers", "data.frame")`, with a dedicated `print` method.

* when `dim` is not `XYZM`, `sf_as_sf.data.frame()` interprets a length 4 `coords` argument to specify the corners of a rectangular polygon; #2357

* `st_interpolate_aw()` gains an `na.rm` argument, for removing features with `NA` attributes before interpolating; #830

* `merge.sf()` no longer renames geometry column; #2334

# version 1.0-16

* `st_join()` no longer renames the geometry column; #2327

* `st_sample()` works when unprojected polygon geometry crosses the antemeridian; #2331

* clean up and modernization of S3 registration of methods and tests; #2285, #2288, #2316, #2341, #2342, by @olivroy

* `[.sfc` works when setting argument `op`; #2320

* `st_sample()` for polygons is sensitive to setting `oriented = TRUE` to prevent wrongly correcting ring directions; #2308
Expand Down
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ CPL_transform <- function(sfc, crs, AOI, pipeline, reverse = FALSE, desired_accu
.Call(`_sf_CPL_transform`, sfc, crs, AOI, pipeline, reverse, desired_accuracy, allow_ballpark)
}

CPL_transform_bounds <- function(bb, crs_dst, densify_pts = 21L) {
.Call(`_sf_CPL_transform_bounds`, bb, crs_dst, densify_pts)
}

CPL_wrap_dateline <- function(sfc, opt, quiet = TRUE) {
.Call(`_sf_CPL_wrap_dateline`, sfc, opt, quiet)
}
Expand Down
14 changes: 10 additions & 4 deletions R/aggregate.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ aggregate.sf = function(x, by, FUN, ..., do_union = TRUE, simplify = TRUE,
a = aggregate(x[unlist(i), , drop = FALSE],
list(rep(seq_len(nrow(by)), lengths(i))), FUN, ...)
nrow_diff = nrow(by) - nrow(a)

if (is.matrix(a[[2]])) # https://github.com/r-spatial/sf/issues/2375
a = data.frame(a[1], as.data.frame(a[[2]]))

if(nrow_diff > 0) {
a_na = a[rep(NA, nrow(by)),] # 'top-up' missing rows
a_na[a$Group.1,] = a
Expand Down Expand Up @@ -82,9 +86,7 @@ aggregate.sf = function(x, by, FUN, ..., do_union = TRUE, simplify = TRUE,
else
paste0("Group.", seq_along(by))
agr[n] = "identity"
st_agr(x) = agr

x
st_set_agr(x, agr)
}
}

Expand All @@ -95,8 +97,10 @@ aggregate.sf = function(x, by, FUN, ..., do_union = TRUE, simplify = TRUE,
#' @param x object of class \code{sf}, for which we want to aggregate attributes
#' @param to object of class \code{sf} or \code{sfc}, with the target geometries
#' @param extensive logical; if TRUE, the attribute variables are assumed to be spatially extensive (like population) and the sum is preserved, otherwise, spatially intensive (like population density) and the mean is preserved.
#' @param na.rm logical; if `TRUE` remove features with `NA` attributes from `x` before interpolating
#' @param ... ignored
#' @param keep_NA logical; if \code{TRUE}, return all features in \code{to}, if \code{FALSE} return only those with non-NA values (but with \code{row.names} the index corresponding to the feature in \code{to})
#' @details if `extensive` is `TRUE` and `na.rm` is set to `TRUE`, geometries with `NA` are effectively treated as having zero attribute values.
#' @examples
#' nc = st_read(system.file("shape/nc.shp", package="sf"))
#' g = st_make_grid(nc, n = c(10, 5))
Expand All @@ -113,12 +117,14 @@ st_interpolate_aw = function(x, to, extensive, ...) UseMethod("st_interpolate_aw

#' @export
#' @name interpolate_aw
st_interpolate_aw.sf = function(x, to, extensive, ..., keep_NA = FALSE) {
st_interpolate_aw.sf = function(x, to, extensive, ..., keep_NA = FALSE, na.rm = FALSE) {
if (!inherits(to, "sf") && !inherits(to, "sfc")) {
to <- try(st_as_sf(to))
if (inherits(to, "try-error"))
stop("st_interpolate_aw requires geometries in argument to")
}
if (isTRUE(na.rm))
x = x[! apply(is.na(x), 1, any),]

if (! all_constant(x))
warning("st_interpolate_aw assumes attributes are constant or uniform over areas of x")
Expand Down
9 changes: 5 additions & 4 deletions R/arith.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Ops.sfc <- function(e1, e2) {
if (.Generic == "-")
e2 <- -e2
return(opp_sfc(e1, as.numeric(e2), 0L, NA_crs_))
} else if (.Generic %in% c("*", "/") && is.numeric(e2) && (length(e2) == 1 || is_only_diag(e2))) {
} else if (.Generic %in% c("*", "/") && is.numeric(e2) && (length(e2) == 1 || (is_only_pos_diag(e2)))) {
if (is.matrix(e2)) e2 <- diag(e2)
if (.Generic == "/")
e2 <- 1 / e2
Expand Down Expand Up @@ -168,10 +168,11 @@ Ops.sfc <- function(e1, e2) {
st_crs(e1)
else # geometry got displaced:
NA_crs_
st_sfc(ret, crs = crs, precision = attr(e1, "precision"))
st_sfc(ret, crs = crs, precision = attr(e1, "precision"), recompute_bbox = TRUE) # also check_ring_dir, if polygons? #2377
} else
ret
}
is_only_diag <- function(x) {
is.matrix(x) && all(`diag<-`(x, 0) == 0) # nocov

is_only_pos_diag <- function(x) {
is.matrix(x) && all(`diag<-`(x, 0) == 0) && all(diag(x) >= 0) # nocov
}
8 changes: 4 additions & 4 deletions R/gdal_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ resampling_method = function(option = "near") {
#' @param colorfilename character; name of color file for \code{demprocessing} (mandatory if \code{processing="color-relief"})
#' @return \code{info} returns a character vector with the raster metadata; all other utils return (invisibly) a logical indicating success (i.e., \code{TRUE}); in case of failure, an error is raised.
#' @export
#' @seealso \link{gdal_addo} for adding overlays to a raste file; \link{st_layers} to query geometry type(s) and crs from layers in a (vector) data source
#' @seealso \link{gdal_addo} for adding overlays to a raster file; \link{st_layers} to query geometry type(s) and crs from layers in a (vector) data source
#' @examples
#'
#' if (sf_extSoftVersion()["GDAL"] > "2.1.0") {
#' # info utils can be used to list information about about a raster
#' # dataset. More info: https://gdal.org/programs/ngdalinfo.html
#' # info utils can be used to list information about a raster
#' # dataset. More info: https://gdal.org/programs/gdalinfo.html
#' in_file <- system.file("tif/geomatrix.tif", package = "sf")
#' gdal_utils("info", in_file, options = c("-mm", "-proj4"))
#'
Expand All @@ -54,7 +54,7 @@ resampling_method = function(option = "near") {
#' )
#' # The parameters can be specified as c("name") or c("name", "value"). The
#' # vectortranslate utils can perform also various operations during the
#' # conversion process. For example we can reproject the features during the
#' # conversion process. For example, we can reproject the features during the
#' # translation.
#' gdal_utils(
#' util = "vectortranslate",
Expand Down
2 changes: 1 addition & 1 deletion R/geom-measures.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ st_perimeter = function(x, ...) {
if (!requireNamespace("lwgeom", quietly = TRUE))
stop("package lwgeom required, please install it first")
# note that units are handled appropriately by lwgeom
lwgeom::st_perimeter(x)
lwgeom::st_perimeter_lwgeom(x)
}
}

Expand Down
Loading

0 comments on commit 085b046

Please sign in to comment.