Skip to content

Commit

Permalink
exploring upstream edzer#107
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbivand committed Jun 15, 2021
1 parent cfa5953 commit fbe5b88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion R/CRS-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ setMethod("rebuild_CRS", signature(obj = "CRS"),


"CRS" <- function(projargs=NA_character_, doCheckCRSArgs=TRUE,
SRS_string=NULL, get_source_if_boundcrs=TRUE) {
SRS_string=NULL, get_source_if_boundcrs=TRUE, from_sf=FALSE) {
# cautious change BDR 150424
# trap NULL too 200225
if (is.null(projargs))
Expand All @@ -32,6 +32,13 @@ setMethod("rebuild_CRS", signature(obj = "CRS"),
# condition added 140301
stopifnot(is.logical(doCheckCRSArgs))
stopifnot(length(doCheckCRSArgs) == 1L)
# https://github.com/edzer/sp/issues/107
# https://github.com/rvalavi/blockCV/issues/18
if (from_sf && !is.na(projargs) && !is.null(SRS_string)) {
res <- new("CRS", projargs=projargs)
comment(res) <- SRS_string
return(res)
}
stopifnot(is.logical(get_source_if_boundcrs))
stopifnot(length(get_source_if_boundcrs) == 1L)
stopifnot(is.character(projargs))
Expand Down
4 changes: 3 additions & 1 deletion man/CRS-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ Objects can be created by calls of the form \code{CRS("projargs")}, where "proja
}
}
\usage{
CRS(projargs, doCheckCRSArgs=TRUE, SRS_string=NULL, get_source_if_boundcrs=TRUE)
CRS(projargs, doCheckCRSArgs=TRUE, SRS_string=NULL,
get_source_if_boundcrs=TRUE, from_sf=FALSE)
identicalCRS(x,y)
}
\arguments{
\item{projargs}{A character string of projection arguments; the arguments must be entered exactly as in the PROJ.4 documentation; if the projection is unknown, use \code{as.character(NA)}, it may be missing or an empty string of zero length and will then set to the missing value. With \pkg{rgdal} built with PROJ >= 6 and GDAL >= 3, the \code{+init=} key may only be used with value \code{epsg:<code>}. From \pkg{sp} version 1.4-4, the string associated with the SRS_string argument may be entered as-is and will be set as SRS_string if the projargs argument does not begin with a \code{+} (suggested by Mikko Vihtakari).}
\item{doCheckCRSArgs}{default TRUE, must be set to FALSE by package developers including \code{CRS} in an S4 class definition to avoid uncontrollable loading of the \pkg{rgdal} namespace}
\item{SRS_string}{default NULL, only used when \pkg{rgdal} is built with PROJ >= 6 and GDAL >= 3; a valid WKT string or SRS definition such as \code{"EPSG:4326"} or \code{"ESRI:102761"}}
\item{get_source_if_boundcrs}{(from \pkg{rgdal} 1.5-17, default TRUE) The presence of the \code{+towgs84=} key in a Proj4 string \code{projargs=} argument value may promote the output WKT2 CRS to BOUNDCRS for PROJ >= 6 and GDAL >= 3, which is a coordinate operation from the input datum to WGS84. This is often unfortunate, so a PROJ function is called through \pkg{rgdal} to retrieve the underlying source definition.}
\item{from_sf}{default false, set by \pkg{sf} coercion method to simply copy in projargs and WKT2_2019 comment values}
\item{x}{object having a \link{proj4string} method,
or if \code{y} is missing, list with objects that have a \code{proj4string} method}
\item{y}{object of class \link{Spatial}, or having a \link{proj4string} method}
Expand Down

0 comments on commit fbe5b88

Please sign in to comment.