Skip to content

Commit

Permalink
rc
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Jul 18, 2019
1 parent feb6ae2 commit 19db583
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
1 change: 1 addition & 0 deletions R/AAgeneric_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (!isGeneric("extend")) {setGeneric("extend", function(x, y, ...) standardGene
if (!isGeneric("extract")) { setGeneric("extract", function(x, y, ...) standardGeneric("extract"))}
if (!isGeneric("flip")) { setGeneric("flip", function(x, direction, ...) standardGeneric("flip")) }
if (!isGeneric("focal")) { setGeneric("focal", function(x, ...) standardGeneric("focal"))}
if (!isGeneric("freq")) {setGeneric("freq", function(x, ...) standardGeneric("freq"))}
if (!isGeneric("geom")) { setGeneric("geom", function(x, ...) standardGeneric("geom"))}
if (!isGeneric("gridDistance")) {setGeneric("gridDistance", function(x, ...) standardGeneric("gridDistance"))}
if (!isGeneric("head")) { setGeneric("head", function(x, ...) standardGeneric("head"))}
Expand Down
4 changes: 2 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
.Call(`_raster_dest_point`, xybd, lonlat, a, f)
}

.reclassify <- function(d, rcl, dolowest, doright, NAonly, NAval) {
.Call(`_raster_reclassify`, d, rcl, dolowest, doright, NAonly, NAval)
.reclassify <- function(d, rcl, dolowest, doright, doleftright, NAonly, NAval) {
.Call(`_raster_reclassify`, d, rcl, dolowest, doright, doleftright, NAonly, NAval)
}

.terrain <- function(d, dim, res, unit, option, geo, gy) {
Expand Down
4 changes: 0 additions & 4 deletions R/freq.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Licence GPL v3


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


setMethod('freq', signature(x='RasterLayer'),
Expand Down
11 changes: 9 additions & 2 deletions R/reclassify.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ function(x, rcl, filename='', include.lowest=FALSE, right=TRUE, ...) {
}
names(out) <- names(x)
include.lowest <- as.integer(include.lowest)
if (is.na(right)) {
leftright <- TRUE
right <- TRUE
} else {
leftright <- FALSE
}
right <- as.integer(right)
#hasNA <- as.integer(hasNA)
onlyNA <- as.integer(onlyNA)
Expand All @@ -80,8 +86,9 @@ function(x, rcl, filename='', include.lowest=FALSE, right=TRUE, ...) {
rcl <- rcl[ , 2:3, drop=FALSE]
}


if (canProcessInMemory(out)) {
out <- setValues(out, .reclassify(values(x), rcl, include.lowest, right, onlyNA, valNA))
out <- setValues(out, .reclassify(values(x), rcl, include.lowest, right, leftright, onlyNA, valNA))
if ( filename != "" ) {
out <- writeRaster(out, filename=filename, ...)
}
Expand All @@ -95,7 +102,7 @@ function(x, rcl, filename='', include.lowest=FALSE, right=TRUE, ...) {

for (i in 1:tr$n) {
vals <- getValues( x, row=tr$row[i], nrows=tr$nrows[i] )
vals <- .reclassify(vals, rcl, include.lowest, right, onlyNA, valNA)
vals <- .reclassify(vals, rcl, include.lowest, right, leftright, onlyNA, valNA)
if (nl > 1) {
vals <- matrix(vals, ncol=nl)
}
Expand Down
47 changes: 24 additions & 23 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,51 +244,51 @@ BEGIN_RCPP
END_RCPP
}
// aggregate_get
NumericMatrix aggregate_get(NumericMatrix d, NumericVector dims);
Rcpp::NumericMatrix aggregate_get(Rcpp::NumericMatrix d, Rcpp::NumericVector dims);
RcppExport SEXP _raster_aggregate_get(SEXP dSEXP, SEXP dimsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< NumericVector >::type dims(dimsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type dims(dimsSEXP);
rcpp_result_gen = Rcpp::wrap(aggregate_get(d, dims));
return rcpp_result_gen;
END_RCPP
}
// aggregate_fun
NumericMatrix aggregate_fun(NumericMatrix d, NumericVector dims, bool narm, int fun);
Rcpp::NumericMatrix aggregate_fun(Rcpp::NumericMatrix d, Rcpp::NumericVector dims, bool narm, int fun);
RcppExport SEXP _raster_aggregate_fun(SEXP dSEXP, SEXP dimsSEXP, SEXP narmSEXP, SEXP funSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< NumericVector >::type dims(dimsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type dims(dimsSEXP);
Rcpp::traits::input_parameter< bool >::type narm(narmSEXP);
Rcpp::traits::input_parameter< int >::type fun(funSEXP);
rcpp_result_gen = Rcpp::wrap(aggregate_fun(d, dims, narm, fun));
return rcpp_result_gen;
END_RCPP
}
// get_area_polygon
NumericVector get_area_polygon(NumericMatrix d, bool lonlat);
Rcpp::NumericVector get_area_polygon(Rcpp::NumericMatrix d, bool lonlat);
RcppExport SEXP _raster_get_area_polygon(SEXP dSEXP, SEXP lonlatSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< bool >::type lonlat(lonlatSEXP);
rcpp_result_gen = Rcpp::wrap(get_area_polygon(d, lonlat));
return rcpp_result_gen;
END_RCPP
}
// point_distance
NumericVector point_distance(NumericMatrix p1, NumericMatrix p2, bool lonlat, double a, double f);
Rcpp::NumericVector point_distance(Rcpp::NumericMatrix p1, Rcpp::NumericMatrix p2, bool lonlat, double a, double f);
RcppExport SEXP _raster_point_distance(SEXP p1SEXP, SEXP p2SEXP, SEXP lonlatSEXP, SEXP aSEXP, SEXP fSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericMatrix >::type p1(p1SEXP);
Rcpp::traits::input_parameter< NumericMatrix >::type p2(p2SEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type p1(p1SEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type p2(p2SEXP);
Rcpp::traits::input_parameter< bool >::type lonlat(lonlatSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
Rcpp::traits::input_parameter< double >::type f(fSEXP);
Expand All @@ -297,13 +297,13 @@ BEGIN_RCPP
END_RCPP
}
// distanceToNearestPoint
NumericVector distanceToNearestPoint(NumericMatrix d, NumericMatrix p, bool lonlat, double a, double f);
Rcpp::NumericVector distanceToNearestPoint(Rcpp::NumericMatrix d, Rcpp::NumericMatrix p, bool lonlat, double a, double f);
RcppExport SEXP _raster_distanceToNearestPoint(SEXP dSEXP, SEXP pSEXP, SEXP lonlatSEXP, SEXP aSEXP, SEXP fSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< NumericMatrix >::type p(pSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type p(pSEXP);
Rcpp::traits::input_parameter< bool >::type lonlat(lonlatSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
Rcpp::traits::input_parameter< double >::type f(fSEXP);
Expand All @@ -312,13 +312,13 @@ BEGIN_RCPP
END_RCPP
}
// directionToNearestPoint
NumericVector directionToNearestPoint(NumericMatrix d, NumericMatrix p, bool lonlat, bool degrees, bool from, double a, double f);
Rcpp::NumericVector directionToNearestPoint(Rcpp::NumericMatrix d, Rcpp::NumericMatrix p, bool lonlat, bool degrees, bool from, double a, double f);
RcppExport SEXP _raster_directionToNearestPoint(SEXP dSEXP, SEXP pSEXP, SEXP lonlatSEXP, SEXP degreesSEXP, SEXP fromSEXP, SEXP aSEXP, SEXP fSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< NumericMatrix >::type p(pSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type d(dSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type p(pSEXP);
Rcpp::traits::input_parameter< bool >::type lonlat(lonlatSEXP);
Rcpp::traits::input_parameter< bool >::type degrees(degreesSEXP);
Rcpp::traits::input_parameter< bool >::type from(fromSEXP);
Expand All @@ -329,12 +329,12 @@ BEGIN_RCPP
END_RCPP
}
// dest_point
NumericMatrix dest_point(NumericMatrix xybd, bool lonlat, double a, double f);
Rcpp::NumericMatrix dest_point(Rcpp::NumericMatrix xybd, bool lonlat, double a, double f);
RcppExport SEXP _raster_dest_point(SEXP xybdSEXP, SEXP lonlatSEXP, SEXP aSEXP, SEXP fSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericMatrix >::type xybd(xybdSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type xybd(xybdSEXP);
Rcpp::traits::input_parameter< bool >::type lonlat(lonlatSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
Rcpp::traits::input_parameter< double >::type f(fSEXP);
Expand All @@ -343,18 +343,19 @@ BEGIN_RCPP
END_RCPP
}
// reclassify
Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, bool dolowest, bool doright, bool NAonly, double NAval);
RcppExport SEXP _raster_reclassify(SEXP dSEXP, SEXP rclSEXP, SEXP dolowestSEXP, SEXP dorightSEXP, SEXP NAonlySEXP, SEXP NAvalSEXP) {
Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, bool dolowest, bool doright, bool doleftright, bool NAonly, double NAval);
RcppExport SEXP _raster_reclassify(SEXP dSEXP, SEXP rclSEXP, SEXP dolowestSEXP, SEXP dorightSEXP, SEXP doleftrightSEXP, SEXP NAonlySEXP, SEXP NAvalSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type d(dSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type rcl(rclSEXP);
Rcpp::traits::input_parameter< bool >::type dolowest(dolowestSEXP);
Rcpp::traits::input_parameter< bool >::type doright(dorightSEXP);
Rcpp::traits::input_parameter< bool >::type doleftright(doleftrightSEXP);
Rcpp::traits::input_parameter< bool >::type NAonly(NAonlySEXP);
Rcpp::traits::input_parameter< double >::type NAval(NAvalSEXP);
rcpp_result_gen = Rcpp::wrap(reclassify(d, rcl, dolowest, doright, NAonly, NAval));
rcpp_result_gen = Rcpp::wrap(reclassify(d, rcl, dolowest, doright, doleftright, NAonly, NAval));
return rcpp_result_gen;
END_RCPP
}
Expand Down Expand Up @@ -458,7 +459,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_raster_distanceToNearestPoint", (DL_FUNC) &_raster_distanceToNearestPoint, 5},
{"_raster_directionToNearestPoint", (DL_FUNC) &_raster_directionToNearestPoint, 7},
{"_raster_dest_point", (DL_FUNC) &_raster_dest_point, 4},
{"_raster_reclassify", (DL_FUNC) &_raster_reclassify, 6},
{"_raster_reclassify", (DL_FUNC) &_raster_reclassify, 7},
{"_raster_do_terrains", (DL_FUNC) &_raster_do_terrains, 7},
{"_raster_doCellFromXY", (DL_FUNC) &_raster_doCellFromXY, 8},
{"_raster_doXYFromCell", (DL_FUNC) &_raster_doXYFromCell, 7},
Expand Down
7 changes: 1 addition & 6 deletions src/reclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
#include <Rcpp.h>

// [[Rcpp::export(name = ".reclassify")]]
Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, bool dolowest, bool doright, bool NAonly, double NAval) {
Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, bool dolowest, bool doright, bool doleftright, bool NAonly, double NAval) {

double lowval, lowres;
size_t a = rcl.nrow();
size_t nc = rcl.ncol();
size_t b = a * 2;

bool doleftright = false;
if (std::isnan(doright)) {
doleftright = true;
}

size_t n = d.size();

Expand Down

0 comments on commit 19db583

Please sign in to comment.