Skip to content

Commit

Permalink
k
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Mar 30, 2020
1 parent 082b7fb commit 56f961c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
6 changes: 6 additions & 0 deletions R/AAgeneric_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@ if (!isGeneric("unique")) { setGeneric("unique", function(x, incomparables=FALSE
if (!isGeneric("union")) {setGeneric("union", function(x, y)standardGeneric("union"))}
if (!isGeneric("values")) { setGeneric("values", function(x, ...) standardGeneric("values")) }
if (!isGeneric("values<-")) { setGeneric("values<-", function(x, value) standardGeneric("values<-"))}
if (!isGeneric("which.max")) {setGeneric("which.max", function(x)standardGeneric("which.max"))}
if (!isGeneric("which.min")) {setGeneric("which.min", function(x)standardGeneric("which.min"))}

if (!isGeneric('writeRaster')) {setGeneric('writeRaster', function(x, filename, ...) standardGeneric('writeRaster'))}
if (!isGeneric('writeValues')) { setGeneric('writeValues', function(x, v, start) standardGeneric('writeValues')) }



if (!isGeneric("xres")) { setGeneric("xres", function(x) standardGeneric("xres")) }
if (!isGeneric("yres")) { setGeneric("yres", function(x) standardGeneric("yres")) }
if (!isGeneric("zonal")) {setGeneric("zonal", function(x, z, ...) standardGeneric("zonal"))}
Expand Down
4 changes: 2 additions & 2 deletions R/netCDFwriteCD.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
zname <- 'time'
}
if (cls == 'Date') {
zatt <- list('units=days since 1970-01-01 00:00:00')
zatt <- list('units=days since 1970-1-1')
zunit <- 'days'
} else {
zatt <- list('units=seconds since 1970-01-01 00:00:00')
zatt <- list('units=seconds since 1970-1-1 00:00:00')
zunit <- 'seconds'
}
}
Expand Down
17 changes: 0 additions & 17 deletions R/which.max.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
# Version 1.0
# Licence GPL v3

if (!isGeneric("which.max")) {
setGeneric("which.max", function(x)
standardGeneric("which.max"))
}


if (!isGeneric("which.min")) {
setGeneric("which.min", function(x)
standardGeneric("which.min"))
}



setMethod("which.max", "RasterLayer",
function(x) {
m <- maxValue(x, warn=FALSE)
Expand Down Expand Up @@ -119,7 +106,3 @@ setMethod("which.max", "RasterStackBrick",
}
)





9 changes: 8 additions & 1 deletion R/xyCell.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,19 @@ if (!isGeneric("coordinates")) {
}


setMethod('coordinates', signature(obj='Raster'),
setMethod("coordinates", signature(obj="Raster"),
function(obj, ...){
xyFromCell(obj, cell=1:ncell(obj), ...)
}
)

setMethod("coordinates", signature(obj="Extent"),
function(obj, ...){
e <- as.vector(obj)
rbind(cbind(e[1], e[3:4]), cbind(e[2], e[4:3]))
}
)


setMethod("yFromCell", signature(object="Raster",cell="numeric"),
function(object, cell) {
Expand Down
2 changes: 2 additions & 0 deletions man/xyFromCell.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
\alias{xyFromCell,Raster-method}
\alias{coordinates}
\alias{coordinates,Raster-method}
\alias{coordinates,Extent-method}


\title{Coordinates from a row, column or cell number}
Expand All @@ -32,6 +33,7 @@ These functions get coordinates of the center of raster cells for a row, column,
\S4method{yFromCell}{Raster,numeric}(object, cell)
\S4method{xyFromCell}{BasicRaster,ANY}(object, cell, spatial=FALSE, ...)
\S4method{coordinates}{Raster}(obj, ...)
\S4method{coordinates}{Extent}(obj, ...)
}


Expand Down
2 changes: 1 addition & 1 deletion src/modal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ double getMode(NumericVector values, int ties) {
int n = values.length();
IntegerVector counts(n);

if (ties < 3) {
if (ties < 2) {
std::sort(values.begin(), values.end());
}

Expand Down

0 comments on commit 56f961c

Please sign in to comment.