Skip to content

Commit 250cc44

Browse files
committed
Merge branch 'main' into pointx
2 parents 4713008 + 340c5c6 commit 250cc44

File tree

18 files changed

+135
-56
lines changed

18 files changed

+135
-56
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# version 1.0-13
22

3+
* `gdal_utils()` adds `"ogrinfo"` utility (requires GDAL >= 3.7.0); #2160
4+
5+
* `st_as_sf()` catches errors when setting invalid crs values, raised by Jon Skøien
6+
37
* add `rename_with.sf()` method; #1472
48

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

R/RcppExports.R

Lines changed: 5 additions & 1 deletion
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
}
@@ -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/crs.R

Lines changed: 4 additions & 1 deletion
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

R/gdal_utils.R

Lines changed: 7 additions & 5 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
@@ -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)

R/sp.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,11 @@ as_Spatial = function(from, cast = TRUE, IDs = paste0("ID", seq_along(from))) {
307307
if (ncol(from))
308308
sp::addAttrToGeom(as_Spatial(geom, cast = cast, IDs = row.names(from)),
309309
data.frame(from), match.ID = FALSE)
310-
else
311-
.as_Spatial(from, cast, IDs)
310+
else {
311+
if (missing(IDs))
312+
IDs = paste0("ID", seq_along(geom))
313+
as_Spatial(geom, cast, IDs)
314+
}
312315
} else {
313316
.as_Spatial(from, cast, IDs)
314317
}

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ Package sf:
2727
* interfaces to [PRØJ](http://proj.org/) for coordinate reference system conversion and transformation
2828
* uses [well-known-binary](https://en.wikipedia.org/wiki/Well-known_text#Well-known_binary) serialisations written in C++/Rcpp for fast I/O with GDAL and GEOS
2929
* reads from and writes to spatial databases such as [PostGIS](http://postgis.net/) using [DBI](https://cran.r-project.org/web/packages/DBI/index.html)
30-
* is extended by [lwgeom](https://github.com/r-spatial/lwgeom/) for selected liblwgeom/PostGIS functions
31-
* is extended by [stars](https://github.com/r-spatial/stars/) for raster data, and raster or vector data cubes (spatial time series)
30+
* is extended by
31+
* [lwgeom](https://github.com/r-spatial/lwgeom/) for selected liblwgeom/PostGIS functions
32+
* [stars](https://github.com/r-spatial/stars/) for raster data, and raster or vector data cubes (spatial time series)
33+
* [sfnetworks](https://luukvdmeer.github.io/sfnetworks/) for geospatial network data
3234

3335
<a href="https://gist.github.com/edzer/442d74a5775abcd5068cf3e73b23687b"><img align="left" src="https://user-images.githubusercontent.com/520851/50280460-e35c1880-044c-11e9-9ed7-cc46754e49db.jpg" /></a>
3436

inst/docker/gdal/Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ RUN cd proj* \
102102

103103
# GDAL:
104104

105-
ENV GDAL_VERSION 3.6.0
106-
ENV GDAL_VERSION_NAME 3.6.0
105+
ENV GDAL_VERSION 3.7.0
106+
ENV GDAL_VERSION_NAME 3.7.0
107107

108108
RUN wget -q http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION_NAME}.tar.gz \
109109
&& tar -xf gdal-${GDAL_VERSION_NAME}.tar.gz \
@@ -133,10 +133,13 @@ RUN Rscript -e 'install.packages(c("mapview", "tmap"))'
133133
RUN Rscript -e 'install.packages(c("spatstat", "spatstat.linnet"))'
134134

135135
RUN R CMD build --no-build-vignettes --no-manual sf
136-
RUN R CMD check --no-build-vignettes --no-manual --as-cran sf_*.tar.gz
137-
RUN R CMD check --no-build-vignettes --no-manual --as-cran lwgeom_*.tar.gz
136+
RUN rm -fr sf
137+
RUN git clone --depth 10 https://github.com/r-spatial/sf.git
138+
RUN R CMD INSTALL sf
139+
#RUN R CMD check --no-build-vignettes --no-manual --as-cran sf_*.tar.gz
140+
#RUN R CMD check --no-build-vignettes --no-manual --as-cran lwgeom_*.tar.gz
138141

139142
#RUN Rscript -e 'install.packages("starsdata", repos="http://gis-bigdata.uni-muenster.de/pebesma/")'
140-
RUN R CMD build --no-manual stars
141-
RUN Rscript -e 'install.packages(c("ncdfgeom"))'
142-
RUN _R_CHECK_FORCE_SUGGESTS_=false R CMD check --no-build-vignettes --no-manual --as-cran stars_*.tar.gz
143+
#RUN R CMD build --no-manual stars
144+
#RUN Rscript -e 'install.packages(c("ncdfgeom", "exactextractr"))'
145+
#RUN _R_CHECK_FORCE_SUGGESTS_=false R CMD check --no-build-vignettes --no-manual --as-cran stars_*.tar.gz

man/gdal_utils.Rd

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

0 commit comments

Comments
 (0)