Skip to content

Commit d7f19fd

Browse files
authored
Merge pull request #2285 from olivroy/roxygen
Improve documentation
2 parents cde0757 + 8b53253 commit d7f19fd

28 files changed

+203
-123
lines changed

.github/workflows/tic-db.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_dispatch:
66
push:
77
branches:
8-
- master
8+
- main
99
pull_request:
1010
# for now, CRON jobs only run on the default branch of the repo (i.e. usually on master)
1111
schedule:

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Collate:
161161
'gdal_utils.R'
162162
'nearest.R'
163163
'normalize.R'
164+
'sf-package.R'
164165
'defunct.R'
165166
'z_range.R'
166167
'm_range.R'

PROPOSAL.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Simple Features for R
22

3-
Applicant: [Edzer Pebesma](https://github.com/edzer/), [Institute for Geoinformatics](http://ifgi.uni-muenster.de/en), University of Muenster, Germany; [edzer.pebesma@uni-muenster.de](mailto:edzer.pebesma@uni-muenster.de)
3+
Applicant: [Edzer Pebesma](https://github.com/edzer/), [Institute for Geoinformatics](https://www.uni-muenster.de/Geoinformatics/en/), University of Muenster, Germany; [edzer.pebesma@uni-muenster.de](mailto:edzer.pebesma@uni-muenster.de)
44

55
Supporting authors: Edzer Pebesma, Roger Bivand, Michael Sumner, Robert Hijmans, Virgilio Gómez-Rubio
66

7-
[Simple features](https://en.wikipedia.org/wiki/Simple_Features) is an open ([OGC](http://www.opengeospatial.org/standards/sfa) and [ISO](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=40114)) interface standard for access and manipulation of spatial vector data (points, lines, polygons). It includes a standard [SQL schema](http://www.opengeospatial.org/standards/sfs) that supports storage, retrieval, query and update of feature collections via a SQL interface. All commonly used databases provide this interface. [GeoJSON](http://geojson.org/) is a standard for encoding simple features in JSON, and is used in JavaScript and MongoDB. Well-known-text ([WKT](https://en.wikipedia.org/wiki/Well-known_text)) is a text representation of simple features used often in linked data; well-known-binary ([WKB] (https://en.wikipedia.org/wiki/Well-known_text)) a standard binary representation used in databases. _Simple Feature Access_ defines coordinate reference systems, and makes it easy to move data from longitude-latitude to projections back and forth in a standardized way.
7+
[Simple features](https://en.wikipedia.org/wiki/Simple_Features) is an open ([OGC](https://www.ogc.org/standard/sfa/) and [ISO](https://www.iso.org/standard/40114.html)) interface standard for access and manipulation of spatial vector data (points, lines, polygons). It includes a standard [SQL schema](http://www.opengeospatial.org/standards/sfs) that supports storage, retrieval, query and update of feature collections via a SQL interface. All commonly used databases provide this interface. [GeoJSON](https://geojson.org/) is a standard for encoding simple features in JSON, and is used in JavaScript and MongoDB. Well-known-text ([WKT](https://en.wikipedia.org/wiki/Well-known_text)) is a text representation of simple features used often in linked data; well-known-binary ([WKB] (https://en.wikipedia.org/wiki/Well-known_text)) a standard binary representation used in databases. _Simple Feature Access_ defines coordinate reference systems, and makes it easy to move data from longitude-latitude to projections back and forth in a standardized way.
88

99

10-
[GDAL](http://gdal.org/) is an open source C++ library for reading and writing both raster and vector data with more than 225 drivers (supported file formats, data base connectors, web service interfaces). GDAL is used by practically all open source geospatial projects and by many industry products (including ESRI's ArcGIS, ERDAS, and FME). It provides coordinate transformations (built on top of PROJ.4) and geometric operations (e.g. polygon intersections, unions, buffers and distance). Standards for coordinate transformations change over time; such changes are typically adopted directly in GDAL/PROJ.4 but do not easily find their way into R-only packages such as `mapproj`.
10+
[GDAL](https://gdal.org/) is an open source C++ library for reading and writing both raster and vector data with more than 225 drivers (supported file formats, data base connectors, web service interfaces). GDAL is used by practically all open source geospatial projects and by many industry products (including ESRI's ArcGIS, ERDAS, and FME). It provides coordinate transformations (built on top of PROJ.4) and geometric operations (e.g. polygon intersections, unions, buffers and distance). Standards for coordinate transformations change over time; such changes are typically adopted directly in GDAL/PROJ.4 but do not easily find their way into R-only packages such as `mapproj`.
1111

12-
Since [2005](https://stat.ethz.ch/pipermail/r-sig-geo/2005-April/000378.html), CRAN has package [sp](https://cran.r-project.org/web/packages/sp/) which provides classes and methods for spatial (point, line, polygon and raster) data. The approach `sp` takes is similar to how `xts` and `zoo` handle the time index of time series data: objects store spatial geometries separately from associated attribute data, matching by order. Package [spacetime](https://cran.r-project.org/web/packages/spacetime/index.html), on CRAN since 2010, extends both `sp` and `xts` to handle data that varies over both space and time.
12+
Since [2005](https://stat.ethz.ch/pipermail/r-sig-geo/2005-April/000378.html), CRAN has package [sp](https://cran.r-project.org/package=sp) which provides classes and methods for spatial (point, line, polygon and raster) data. The approach `sp` takes is similar to how `xts` and `zoo` handle the time index of time series data: objects store spatial geometries separately from associated attribute data, matching by order. Package [spacetime](https://cran.r-project.org/package=spacetime), on CRAN since 2010, extends both `sp` and `xts` to handle data that varies over both space and time.
1313

14-
Today, 221 CRAN packages depend on, import or link to `sp`, 259 when including _Suggests_; when including recursive dependencies these numbers are 376 and 5040. The implementation of `sp` does not follow simple features, but rather the practice used at the time of release, following how ESRI shapefiles are implemented. The cluster of packages around `sp` is shown in Andrie de Vries' [blog on CRAN's network structure](http://blog.revolutionanalytics.com/2015/07/the-network-structure-of-cran.html) in green.
14+
Today, 221 CRAN packages depend on, import or link to `sp`, 259 when including _Suggests_; when including recursive dependencies these numbers are 376 and 5040. The implementation of `sp` does not follow simple features, but rather the practice used at the time of release, following how ESRI shapefiles are implemented. The cluster of packages around `sp` is shown in Andrie de Vries' [blog on CRAN's network structure](https://blog.revolutionanalytics.com/2015/07/the-network-structure-of-cran.html) in green.
1515

16-
Off-CRAN package [rgdal2](https://github.com/thk686/rgdal2) is an interface to GDAL 2.0, which uses raw pointers to interface features, but does not import any data in R, using GDAL to handle everything. CRAN Package [wkb](https://cran.r-project.org/web/packages/wkb/index.html), contributed by Tibco Software, converts between WKB representations of several simple feature classes and corresponding classes in `sp`, and seems to be needed for Tibco software purposes.
16+
Off-CRAN package [rgdal2](https://github.com/thk686/rgdal2) is an interface to GDAL 2.0, which uses raw pointers to interface features, but does not import any data in R, using GDAL to handle everything. CRAN Package [wkb](https://cran.r-project.org/package=wkb), contributed by Tibco Software, converts between WKB representations of several simple feature classes and corresponding classes in `sp`, and seems to be needed for Tibco software purposes.
1717

1818
<!---
1919
[second edition](http://www.springer.com/statistics/life+sciences%2C+medicine+%26+health/book/978-1-4614-7617-7))
@@ -24,14 +24,14 @@ Off-CRAN package [rgdal2](https://github.com/thk686/rgdal2) is an interface to G
2424
The problems we will solve are:
2525

2626
1. R can currently not represent simple features directly. It can read most simple feature classes in `sp` classes, but uses its own representation for this, and can only write data back without loss of information if it is furnished with ancilliary metadata encoded in a comment attribute to each Polygons object. It does for instance internally not distinguish between `POLYGON` and `MULTIPOLYGON` nor deal with several simple feature classes, including `TIN` and `GEOMETRYCOLLECTION`, nor handle `CURVE` geometries.
27-
2. The current implementation of lines and vector data in package `sp` is partly ambiguous (both slot `ringDir` or slot `hole` indicate whether a Polygon is a hole but are superceded by the comment attribute), complicated (to which exterior polygon does a hole belong - handled by the comment attribute), and by some considered difficult to work with (S4). The current implementation is hard to maintain because it contains incremental changes from a baseline that predated the industry-standard OGC/ISO ([Simple Feature Interface Specification](http://www.opengeospatial.org/standards/sfa)).
27+
2. The current implementation of lines and vector data in package `sp` is partly ambiguous (both slot `ringDir` or slot `hole` indicate whether a Polygon is a hole but are superceded by the comment attribute), complicated (to which exterior polygon does a hole belong - handled by the comment attribute), and by some considered difficult to work with (S4). The current implementation is hard to maintain because it contains incremental changes from a baseline that predated the industry-standard OGC/ISO ([Simple Feature Interface Specification](https://www.ogc.org/standard/sfa/)).
2828
3. The lack of support for simple features makes current interfaces to open source libraries (GDAL/OGR and PROJ.4: rgdal, GEOS: rgeos) difficult to understand and maintain, even though they work to specification.
29-
4. The current implementation has no [scale model](http://geos.osgeo.org/doxygen/classgeos_1_1geom_1_1PrecisionModel.html#details) for coordinates.
29+
4. The current implementation has no [scale model](https://libgeos.org/doxygen/classgeos_1_1geom_1_1PrecisionModel.html#details) for coordinates.
3030
5. It is desirable that other R packages are offered the opportunity to migrate to more up-to-date libraries for coordinate transformations (providing proper support for datum transformation), and to avoid having to make simplifying assumptions (e.g., all spatial data come as longitude/latitude using datum `WGS84`; all web maps use [_web Mercator_](https://en.wikipedia.org/wiki/Web_Mercator)).
3131

3232
Which users will benefit from solving these problems? It will mainly affect those who use data bases or modern javascript-based web APIs which largely converged on adopting simple features (such as [CartoDB](https://cartodb.com/)), as well as those who need a simpler and more light-weight handling of spatial data in R. It will also reduce the effort for users and developers to understand the way spatial information is represented in R, making it easier to build upon and reuse the R code for this, and lead to a good, sustainable shared R code base.
3333

34-
In the longer run it will affect users of all packages currently reusing `sp` classes, when we manage to migrate `sp` to exclusively use the simple feature classes for representing vector data. Since the recent [2.0](http://www.gdal.org/index.html) release of GDAL integrates raster and vector data, having an R package that mirrors its classes makes it possible to implement operations in-database (similar to what `DBI`, `RPostgreSQL` and `dplyr` do), making it possible for R to manipulate spatial data that do not fit in memory.
34+
In the longer run it will affect users of all packages currently reusing `sp` classes, when we manage to migrate `sp` to exclusively use the simple feature classes for representing vector data. Since the recent [2.0](https://gdal.org/index.html) release of GDAL integrates raster and vector data, having an R package that mirrors its classes makes it possible to implement operations in-database (similar to what `DBI`, `RPostgreSQL` and `dplyr` do), making it possible for R to manipulate spatial data that do not fit in memory.
3535

3636
Big Data analysis with R often proceeds by connecting R to a database that holds the data. All commonly used commercial and open source databases store spatial point, line and polygon data in the form of simple features. Representing simple features in R will simplify big data analysis for spatial data.
3737

@@ -73,8 +73,8 @@ The visit of Roger is anticipated halfway the project; further communications wi
7373

7474
## Dissemination
7575

76-
Development will take place on github, information will be shared and reactions and contributions invited through [r-sig-geo](https://stat.ethz.ch/mailman/listinfo/r-sig-geo), as well as [StackOverflow](http://stackoverflow.com/) and [GIS StackExchange](http://gis.stackexchange.com/). The project will use an Apache 2.0 license for maximum dissemination (similar to GDAL, which uses X/MIT). The work will be published in 4 blogs (quarterly), announced on r-sig-geo (3300 subscribers), and intermediary results will be presented at [UseR! 2016](http://user2016.org/). The final result will be published in a paper either submitted to [The R Journal](https://journal.r-project.org/) or to the [Journal of Statistical Software](http://www.jstatsoft.org/); this paper will be available before publication as a package vignette.
76+
Development will take place on github, information will be shared and reactions and contributions invited through [r-sig-geo](https://stat.ethz.ch/mailman/listinfo/r-sig-geo), as well as [StackOverflow](https://stackoverflow.com/) and [GIS StackExchange](https://gis.stackexchange.com/). The project will use an Apache 2.0 license for maximum dissemination (similar to GDAL, which uses X/MIT). The work will be published in 4 blogs (quarterly), announced on r-sig-geo (3300 subscribers), and intermediary results will be presented at [UseR! 2016](https://www.r-project.org/conferences/useR-2016/). The final result will be published in a paper either submitted to [The R Journal](https://journal.r-project.org/) or to the [Journal of Statistical Software](https://www.jstatsoft.org/index); this paper will be available before publication as a package vignette.
7777

7878
## UseR! slides
7979

80-
UseR! 2016 slides are found [here](http://pebesma.staff.ifgi.de/pebesma_sfr.pdf).
80+
UseR! 2016 slides are found [here](https://pebesma.staff.ifgi.de/pebesma_sfr.pdf).

R/datasets.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
#' though this is basically the same as \code{nc.sids} dataset in spData
77
#' package, \code{nc} only contains a subset of variables. The differences are
88
#' also discussed on the vignette.
9-
#'
9+
#' @format A `sf` object
1010
#' @name nc
1111
#' @docType data
12-
#' @keywords data
1312
#' @seealso \url{https://r-spatial.github.io/spdep/articles/sids.html}
13+
#' @examples
14+
#' \donttest{
15+
#' nc <- st_read(system.file("shape/nc.shp", package="sf"))
16+
#' }
1417
NULL

R/defunct.R

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#' Deprecated functions in `sf`
2-
#'
3-
#' These functions are provided for compatibility with older version of `sf`.
4-
#' They may eventually be completely removed.
5-
#' @md
6-
#' @rdname sf-defunct
1+
#' @title Deprecated functions in `sf`
72
#' @name sf-defunct
3+
#' @description
4+
#' These functions are provided for compatibility with older version of `sf`.
5+
#' They will eventually be completely removed.
6+
#'
7+
#' * Use [st_read()] instead of `st_read_db()`.
8+
#' * Use [st_write()] instead_of `st_write_db()`
89
#' @param conn open database connection
910
#' @param table table name
1011
#' @param geom_column deprecated. Geometry column name
@@ -13,21 +14,15 @@
1314
#' it will try to cast all the character columns, which can be long for very wide
1415
#' tables.
1516
#' @inheritParams st_read
16-
#' @export st_read_db st_write_db
17-
#' @aliases st_read_db, st_write_db
18-
#' @section Details:
19-
#' \tabular{rl}{
20-
#' \code{st_read_db} \tab now a synonym for \code{\link{st_read}}\cr
21-
#' \code{st_write_db} \tab now a synonym for \code{\link{st_write}}\cr
22-
#' }
23-
#'
2417
#' @export
18+
#' @keywords internal
2519
st_read_db <- function(conn = NULL, table = NULL, query = NULL,
2620
geom_column = NULL, EWKB = TRUE, ...) {
2721
.Defunct("st_read")
2822
}
2923

30-
#' @inheritDotParams dbWriteTable
24+
#' @rdname sf-defunct
25+
#' @inheritParams DBI::dbWriteTable
3126
#' @export
3227
st_write_db <- function(conn = NULL, obj, table = deparse(substitute(obj)), ...,
3328
drop = FALSE, append = FALSE) {

R/geom-predicates.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ st_relate = function(x, y, pattern = NA_character_, sparse = !is.na(pattern)) {
114114
#' @param x object of class \code{sf}, \code{sfc} or \code{sfg}
115115
#' @param y object of class \code{sf}, \code{sfc} or \code{sfg}; if missing, \code{x} is used
116116
#' @param sparse logical; should a sparse index list be returned (TRUE) or a dense logical matrix? See below.
117-
#' @param ... passed on to \link[s2]{s2_options}
117+
#' @inheritDotParams s2::s2_options
118118
#' @param prepared logical; prepare geometry for x, before looping over y? See Details.
119119
#' @details If \code{prepared} is \code{TRUE}, and \code{x} contains POINT geometries and \code{y} contains polygons, then the polygon geometries are prepared, rather than the points.
120120
#' @return If \code{sparse=FALSE}, \code{st_predicate} (with \code{predicate} e.g. "intersects") returns a dense logical matrix with element \code{i,j} \code{TRUE} when \code{predicate(x[i], y[j])} (e.g., when geometry of feature i and j intersect); if \code{sparse=TRUE}, an object of class \code{\link{sgbp}} with a sparse list representation of the same matrix, with list element \code{i} an integer vector with all indices j for which \code{predicate(x[i],y[j])} is \code{TRUE} (and hence a zero-length integer vector if none of them is \code{TRUE}). From the dense matrix, one can find out if one or more elements intersect by \code{apply(mat, 1, any)}, and from the sparse list by \code{lengths(lst) > 0}, see examples below.

R/geom-transformers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ st_line_sample = function(x, n, density, type = "regular", sample = NULL) {
11111111
}
11121112

11131113
#' Internal functions
1114-
#' @name internal
1114+
#' @keywords internal
11151115
#' @param msg error message
11161116
#' @export
11171117
.stop_geos = function(msg) { #nocov start

R/plot.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,8 @@ get_asp = function(bb) {
710710
asp
711711
}
712712

713-
714-
#' @export
713+
#' functions only exported to be used internally by stars
714+
#' @keywords internal
715715
#' @name stars
716716
#' @param bb ignore
717717
#' @param n ignore
@@ -720,6 +720,7 @@ get_asp = function(bb) {
720720
#' @param key.length ignore
721721
#' @param mfrow length-2 integer vector with number of rows, columns
722722
#' @param main main or sub title
723+
#' @export
723724
.get_layout = function(bb, n, total_size, key.pos, key.width, mfrow = NULL, main = NULL) {
724725
# return list with "m" matrix, "key.pos", "widths" and "heights" fields
725726
# if key.pos = -1 on input, it will be a return value, "optimally" placed
@@ -796,16 +797,15 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer
796797
st_bbox(st_transform(pts, merc))
797798
}
798799

799-
#' functions only exported to be used internally by stars
800-
#' @name stars
801-
#' @export
800+
#' @rdname stars
802801
#' @param side ignore
803802
#' @param at ignore
804803
#' @param labels ignore
805804
#' @param lon ignore
806805
#' @param lat ignore
807806
#' @param ndiscr ignore
808807
#' @param reset ignore
808+
#' @export
809809
.degAxis = function (side, at, labels, ..., lon, lat, ndiscr, reset) {
810810
if (missing(at))
811811
at = axTicks(side)
@@ -838,8 +838,7 @@ xy_from_r = function(r, l, o) {
838838
c(x, y)
839839
}
840840

841-
#' @name stars
842-
#' @export
841+
#' @rdname stars
843842
#' @param z ignore
844843
#' @param col ignore
845844
#' @param breaks ignore
@@ -850,6 +849,7 @@ xy_from_r = function(r, l, o) {
850849
#' @param ... ignore
851850
#' @param lab ignore
852851
#' @param cex.axis see \link{par}
852+
#' @export
853853
.image_scale = function(z, col, breaks = NULL, key.pos, add.axis = TRUE,
854854
at = NULL, ..., axes = FALSE, key.length, logz = FALSE, lab = "",
855855
cex.axis = par("cex.axis")) {
@@ -929,9 +929,9 @@ xy_from_r = function(r, l, o) {
929929
axis(key.pos, at = at, labels = labels, cex.axis = cex.axis)
930930
}
931931

932-
#' @name stars
933-
#' @export
932+
#' @rdname stars
934933
#' @param key.width ignore
934+
#' @export
935935
.image_scale_factor = function(z, col, key.pos, add.axis = TRUE,
936936
..., axes = FALSE, key.width, key.length, cex.axis = par("cex.axis")) {
937937

0 commit comments

Comments
 (0)