Skip to content

Commit 86059e2

Browse files
committed
Merge branch 'main' into pointx
2 parents 4713008 + b66e30d commit 86059e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+250
-129
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ NOTES
2222
^tic\.R$
2323
vignettes.awk
2424
^\.gitattributes$
25+
_pkgdown.yml

.github/workflows/tic-db.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ jobs:
6969
# set date/week for use in cache creation
7070
# https://github.community/t5/GitHub-Actions/How-to-set-and-access-a-Workflow-variable/m-p/42970
7171
# - cache R packages daily
72-
- name: "[Cache] Prepare daily timestamp for cache"
73-
if: runner.os != 'Windows'
74-
id: date
75-
run: echo "::set-output name=date::$(date '+%d-%m')"
76-
77-
- name: "[Cache] Cache R packages"
78-
if: runner.os != 'Windows'
79-
uses: pat-s/always-upload-cache@v2
80-
with:
81-
path: ${{ env.R_LIBS_USER }}
82-
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}
83-
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}
72+
# - name: "[Cache] Prepare daily timestamp for cache"
73+
# if: runner.os != 'Windows'
74+
# id: date
75+
# run: echo "::set-output name=date::$(date '+%d-%m')"
76+
77+
# - name: "[Cache] Cache R packages"
78+
# if: runner.os != 'Windows'
79+
# uses: pat-s/always-upload-cache@v2
80+
# with:
81+
# path: ${{ env.R_LIBS_USER }}
82+
# key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}
83+
# restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}
8484

8585
- name: "[Stage] [Linux] Install required system libs"
8686
if: runner.os == 'Linux'

NEWS.md

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

3+
* fix many lintr suggestions, thanks go Michael Chirico (#2181 - #2191)
4+
5+
* `gdal_utils()` adds `"ogrinfo"` utility (requires GDAL >= 3.7.0); #2160
6+
7+
* `st_as_sf()` catches errors when setting invalid crs values, raised by Jon Skøien
8+
39
* add `rename_with.sf()` method; #1472
410

511
* use GEOS' overlayNG routines for (GEOS) Intersection, Difference, Union and SymDifference; #2143

R/RcppExports.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ CPL_gdalinfo <- function(obj, options, oo, co) {
117117
.Call(`_sf_CPL_gdalinfo`, obj, options, oo, co)
118118
}
119119

120+
CPL_ogrinfo <- function(obj, options, oo, co) {
121+
.Call(`_sf_CPL_ogrinfo`, obj, options, oo, co)
122+
}
123+
120124
CPL_gdaladdo <- function(obj, method, overviews, bands, oo, co, clean = FALSE, read_only = FALSE) {
121125
.Call(`_sf_CPL_gdaladdo`, obj, method, overviews, bands, oo, co, clean, read_only)
122126
}
@@ -329,8 +333,8 @@ CPL_proj_info <- function(type) {
329333
.Call(`_sf_CPL_proj_info`, type)
330334
}
331335

332-
CPL_xy2sfc <- function(cc, dim, to_points, which) {
333-
.Call(`_sf_CPL_xy2sfc`, cc, dim, to_points, which)
336+
CPL_xy2sfc <- function(cc, dim, to_points, which, cc_has_NAs) {
337+
.Call(`_sf_CPL_xy2sfc`, cc, dim, to_points, which, cc_has_NAs)
334338
}
335339

336340
sfc_is_null <- function(sfc) {
@@ -399,5 +403,5 @@ CPL_get_m_range <- function(sf, depth) {
399403

400404
# Register entry points for exported C++ functions
401405
methods::setLoadAction(function(ns) {
402-
.Call(`_sf_RcppExport_registerCCallable`)
406+
.Call('_sf_RcppExport_registerCCallable', PACKAGE = 'sf')
403407
})

R/agr.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ summarize_agr = function(x) {
9292

9393
all_constant = function(x) {
9494
x = attr(x, "agr")
95-
!(any(is.na(x)) || any(!(x %in% c("identity", "constant"))))
95+
!anyNA(x) && all(x %in% c("identity", "constant"))
9696
}

R/bbox.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
is.na.bbox = function(x) identical(x, NA_bbox_)
66

77
bb_wrap = function(bb) {
8-
stopifnot(is.numeric(bb) && length(bb) == 4)
8+
stopifnot(is.numeric(bb), length(bb) == 4)
99
structure(as.double(bb), names = c("xmin", "ymin", "xmax", "ymax"), class = "bbox")
1010
}
1111

R/break_antimeridian.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#' }
3232
st_break_antimeridian = function(x, lon_0=0, tol=0.0001, ...) {
3333
ll = st_is_longlat(x)
34-
if (!ll | is.na(ll))
34+
if (!isTRUE(ll))
3535
stop("'st_break_antimeridian' requires non-projected geographic coordinates",
3636
call. = FALSE)
3737

@@ -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/crs.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ st_crs.sf = function(x, ...) st_crs(st_geometry(x), ...)
6161
#' @name st_crs
6262
#' @export
6363
st_crs.numeric = function(x, ...) {
64-
make_crs(paste0("EPSG:", x))
64+
if (is.na(x))
65+
NA_crs_
66+
else
67+
make_crs(paste0("EPSG:", x))
6568
}
6669

6770

@@ -332,7 +335,7 @@ crs_parameters = function(x) {
332335
epsg = function(x) {
333336
if (is.na(x))
334337
NA_integer_
335-
else if (grepl("^EPSG:", x[["input"]]))
338+
else if (startsWith(x[["input"]], "EPSG:"))
336339
as.integer(gsub("^EPSG:(\\d+)\\b.*$", "\\1", x[["input"]]))
337340
else
338341
crs_parameters(x)[["epsg"]]

R/db.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ schema_table <- function(conn, table, public = "public") {
192192
else if (length(table) > 2)
193193
stop("table cannot be longer than 2 (schema, table)", call. = FALSE)
194194

195-
if (any(is.na(table)))
195+
if (anyNA(table))
196196
stop("table and schema cannot be NA", call. = FALSE)
197197

198198
return(table)
@@ -242,7 +242,7 @@ db_find_srid = function(conn, crs_local = st_crs(srid), srid = epsg(crs_local),
242242
}
243243
crs_found <- st_crs(db_crs[["srtext"]])
244244
crs_found[["input"]] <- build_epsg(srid)
245-
if(validate && crs_found != crs_local & !is.na(crs_local)) {
245+
if(validate && crs_found != crs_local && !is.na(crs_local)) {
246246
# TODO: pretty print db_spatial_ref
247247
warning("Local crs different from database crs. You can inspect the ",
248248
"database crs using `dbReadtable(conn, \"spatial_ref_sys\")` ",

R/gdal_utils.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resampling_method = function(option = "near") {
2323

2424
#' Native interface to gdal utils
2525
#' @name gdal_utils
26-
#' @param util character; one of \code{info}, \code{warp}, \code{rasterize}, \code{translate}, \code{vectortranslate} (for ogr2ogr), \code{buildvrt}, \code{demprocessing}, \code{nearblack}, \code{grid}, \code{mdiminfo} and \code{mdimtranslate} (the last two requiring GDAL 3.1)
26+
#' @param util character; one of \code{info}, \code{warp}, \code{rasterize}, \code{translate}, \code{vectortranslate} (for ogr2ogr), \code{buildvrt}, \code{demprocessing}, \code{nearblack}, \code{grid}, \code{mdiminfo} and \code{mdimtranslate} (the last two requiring GDAL 3.1), \code{ogrinfo} (requiring GDAL 3.7)
2727
#' @param source character; name of input layer(s); for \code{warp}, \code{buidvrt} or \code{mdimtranslate} this can be more than one
2828
#' @param destination character; name of output layer
2929
#' @param options character; options for the utility
@@ -38,7 +38,7 @@ resampling_method = function(option = "near") {
3838
#'
3939
#' if (sf_extSoftVersion()["GDAL"] > "2.1.0") {
4040
#' # info utils can be used to list information about about a raster
41-
#' # dataset. More info: https://gdal.org/programs/gdalinfo.html
41+
#' # dataset. More info: https://gdal.org/programs/ngdalinfo.html
4242
#' in_file <- system.file("tif/geomatrix.tif", package = "sf")
4343
#' gdal_utils("info", in_file, options = c("-mm", "-proj4"))
4444
#'
@@ -73,7 +73,8 @@ resampling_method = function(option = "near") {
7373
#' st_read(in_file)
7474
#' }
7575
gdal_utils = function(util = "info", source, destination, options = character(0),
76-
quiet = !(util %in% c("info", "mdiminfo")) || ("-multi" %in% options),
76+
quiet = !(util %in% c("info", "gdalinfo", "ogrinfo", "vectorinfo",
77+
"mdiminfo")) || ("-multi" %in% options),
7778
processing = character(0), colorfilename = character(0),
7879
config_options = character(0)) {
7980

@@ -101,7 +102,8 @@ gdal_utils = function(util = "info", source, destination, options = character(0)
101102
quiet = as.logical(quiet)
102103

103104
ret = switch(util,
104-
info = CPL_gdalinfo(if (missing(source)) character(0) else source, options, oo, config_options),
105+
gdalinfo =, info = CPL_gdalinfo(if (missing(source)) character(0) else source, options, oo, config_options),
106+
vectorinfo =, ogrinfo = CPL_ogrinfo(if (missing(source)) character(0) else source, options, oo, config_options),
105107
warp = CPL_gdalwarp(source, destination, options, oo, doo, config_options, quiet, "-overwrite" %in% options),
106108
warper = CPL_gdal_warper(source, destination, as.integer(resampling_method(options)),
107109
oo, doo, config_options, quiet), # nocov
@@ -112,7 +114,7 @@ gdal_utils = function(util = "info", source, destination, options = character(0)
112114
}, # nocov end
113115
translate = CPL_gdaltranslate(source, destination, options, oo, config_options, quiet),
114116
vectortranslate = CPL_gdalvectortranslate(source, destination, options, oo, doo, config_options, quiet),
115-
buildvrt = CPL_gdalbuildvrt(source, destination, options, oo, config_options, quiet),
117+
buildvrt = CPL_gdalbuildvrt(if (missing(source)) character(0) else source, destination, options, oo, config_options, quiet),
116118
demprocessing = CPL_gdaldemprocessing(source, destination, options, processing, colorfilename, oo, config_options, quiet),
117119
nearblack = CPL_gdalnearblack(source, destination, options, oo, config_options, doo, quiet),
118120
grid = CPL_gdalgrid(source, destination, options, oo, config_options, quiet),
@@ -121,7 +123,7 @@ gdal_utils = function(util = "info", source, destination, options = character(0)
121123
stop(paste("unknown util value for gdal_utils:", util))
122124
)
123125

124-
if (util %in% c("info", "mdiminfo")) {
126+
if (util %in% c("info", "gdalinfo", "ogrinfo", "vectorinfo", "mdiminfo")) {
125127
if (! quiet)
126128
cat(ret)
127129
invisible(ret)

0 commit comments

Comments
 (0)