Skip to content

Commit

Permalink
version 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dario Masante authored and cran-robot committed Sep 7, 2016
1 parent e9b1bef commit 8e0b1e7
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 55 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
Package: landscapeR
Title: Categorical Landscape Simulation Facilities
Version: 1.1.1
Date: 2016-08-31
Title: Categorical Landscape Simulation Facility
Version: 1.1.2
Date: 2016-09-07
Authors@R: c(person(given = "Dario", family = "Masante", role = c("aut", "cre"), email = "[email protected]"))
Copyright: Natural Environment Research Council (NERC) and Centre for
Ecology and Hydrology (CEH)
URL: https://github.com/dariomasante/landscapeR
BugReports: https://github.com/dariomasante/landscapeR/issues
Imports: raster
Suggests: knitr, rmarkdown
Description: Package is aimed at simulating categorical maps on actual geographical realms, starting from either empty landscapes, or landscapes provided by the user (e.g. land use maps). landscapeR allows to tweak or create landscapes while retaining a high degree of control on its features, without the hassle of specifying each location attribute. In this it differs from other tools which generate null or neutral landscape in a theoretical space. The basic algorithm currently implemented uses a simple agent style/cellular automata growth model, with no rules (apart from areas of exclusion). Outputs are raster dataset exportable to any common GIS format.
Description: Simulates categorical maps on actual geographical realms, starting from either empty landscapes or landscapes provided by the user (e.g. land use maps). Allows to tweak or create landscapes while retaining a high degree of control on its features, without the hassle of specifying each location attribute. In this it differs from other tools which generate null or neutral landscapes in a theoretical space. The basic algorithm currently implemented uses a simple agent style/cellular automata growth model, with no rules (apart from areas of exclusion). Outputs are raster dataset exportable to any common GIS format.
License: GPL (>= 3)
LazyLoad: yes
LazyData: TRUE
NeedsCompilation: no
RoxygenNote: 5.0.1
VignetteBuilder: knitr
Packaged: 2016-08-31 11:57:20 UTC; dmasan
Packaged: 2016-09-07 11:22:17 UTC; dmasan
Author: Dario Masante [aut, cre]
Maintainer: Dario Masante <[email protected]>
Repository: CRAN
Date/Publication: 2016-08-31 14:55:47
Date/Publication: 2016-09-07 14:41:34
12 changes: 6 additions & 6 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
303e5163cfde7076bef8e6a772b3aa89 *DESCRIPTION
4b48ba9f5ec2f7179275812e51efb358 *DESCRIPTION
61a106d579400fccc0ec8efc6d500d6d *NAMESPACE
1e99ff8ad4de85ec84ab921035a463d9 *NEWS.md
7cb151654e8ea7de65e62f09c6c7afec *NEWS.md
b75f528daa3b271a7015d49cd186f3f6 *R/expandClass.R
08127e0bda7cbdf93ab1755412b87cce *R/landscapeR-package.R
4a1f72da6bd08a8ee32db7ab65efc1d6 *R/makeClass.R
09bf83e8deb24866d53c660a2ca5c6c0 *R/makeClass.R
d7728388222b867a1653574da7e0d3c2 *R/makeLine.R
b43ef2ab9e8a680dcbfd8164ffb522e7 *R/makePatch.R
a6cedcdefcbdb4832022d78fd3c5977f *R/makePatch.R
6e7a0f6ed46c094b03637803ebfb5059 *R/rmSingle.R
fe7ff7e0947c9daab2b4b00cf6d3e0c7 *R/zzz.R
6424e2146149baa0cfc45a5600dcc513 *build/vignette.rds
6fbe40d2a4c543685ea49b7d68d82b2c *inst/COPYRIGHTS
464726e62c6ad0fe485a4b76f0a6567e *inst/doc/landscapeR.R
01ab4ef1bc8374abb04acc2ed251db32 *inst/doc/landscapeR.Rmd
db4c399909f3e18e8e22365257742ba4 *inst/doc/landscapeR.html
69af454b18c51a43d4ce4d8c8458ba74 *inst/doc/landscapeR.html
e0a0184bc8a14d18e6b2108e701825a4 *man/expandClass.Rd
061baabcad8fd0f72cd37264dd888970 *man/landscapeR-package.Rd
5339e574f87235fd0f82291592526f30 *man/makeClass.Rd
ba89a8a6b8966f9c45ee861154fe59d5 *man/makeLine.Rd
3e876f5cef42dd2568f6d278aa76e689 *man/makePatch.Rd
67c94c78c8a133c470bce484ecb61c16 *man/makePatch.Rd
71d7f5b8af09f17c4a3c2ff31673f644 *man/rmSingle.Rd
01ab4ef1bc8374abb04acc2ed251db32 *vignettes/landscapeR.Rmd
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
landscapeR v1.1.2 (Patch release date: 2016-09-07)
-----------------------------------------------
CHANGES:

* Bug fix in 'makeClass'
* Clarified error messages


landscapeR v1.1.1 (Patch release date: 2016-08-31)
-----------------------------------------------
CHANGES:

* Fixed bug in 'rmSingle'
* Replaced outdated version of documentation


landscapeR v1.1 (Release date: 2016-08-30)
-----------------------------------------------
CHANGES:

* Removed dependency from package 'fastmatch'
* Changed 'makePatch' and 'expandClass' function internals to gain significant speed improvements
* Updated and improved error/warning messages and exception handling
Expand All @@ -18,6 +28,7 @@ CHANGES:
* Fixed author list to CRAN standards

NEW:

* Added vignette
* Added function 'rmSingle' to remove single tones and reduce salt-pepper effect
* Added function 'makeLine' to create linear features (directional and convoluted). Beta version.
Expand All @@ -28,4 +39,5 @@ NEW:
landscapeR v1.0.0 (Release date: 2016-05-22)
-----------------------------------------------
NEW FEATURES:

* First release on CRAN
35 changes: 23 additions & 12 deletions R/makeClass.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,39 @@ makeClass <- function(context, npatch, size, pts = NULL, bgr=0, edge=FALSE, rast
edge=FALSE
warning('Edge output reset to FALSE. edge=TRUE only when raster output is not required (i.e. rast=FALSE)')
}
if(is.null(pts)){
pts <- sample.int(length(context), npatch)
}
pts <- .toCellIndex(context, pts)
invalidPts <- which(pts > length(context) | pts < 1 | pts %% 1 != 0 | is.na(pts))
if(length(invalidPts) > 0){
stop('Seed point ', pts[invalidPts], ' not valid.')
}
if(length(pts) != npatch){ stop('Number of patches not matching number of seed points provided') }

mtx <- t(raster::as.matrix(context))
if(length(size)==1){
size <- rep(size, npatch)
}
bgrCells <- which(is.element(mtx, bgr))
if(length(bgrCells) == 0){
stop('No background cells available with value ', bgr, '. Try checking argument "bgr".')
}
if(length(bgr > 1)){
bgrCells <- which(is.element(mtx, bgr))
bgr <- bgr[1]
mtx[bgrCells] <- bgr
}
if(is.null(pts)){
pts <- sample(bgrCells, npatch)
}
pts <- .toCellIndex(context, pts)
## invalidPts <- which(pts > length(mtx) | pts < 1 | pts %% 1 != 0 | is.na(pts))
## if(length(invalidPts) > 0){
if(length(pts) != npatch){ stop('Number of patches not matching number of seed points provided.') }
invalidPts <- !is.element(pts, bgrCells)
if(any(invalidPts)){
if(all(invalidPts)){
stop('All seed points invalid.')
} else {
warning('Invalid seed points: ', paste(pts[invalidPts], collapse='; '), '\n Invalid points were ignored.')
pts <- pts[!invalidPts]
size <- size[!invalidPts]
npatch <- length(pts)
}
}
lst <- list()
for(np in 1:npatch){
l <- makePatch(context=mtx, spt=pts[np], size=size[np], bgr=bgr, edge=edge, val=val)
l <- makePatch(context=mtx, spt=pts[np], size=size[np], bgr=bgr, edge=edge, val=val, rast = FALSE)
if(edge==TRUE){
eg <- l[[2]]
l <- l[[1]]
Expand Down
4 changes: 2 additions & 2 deletions R/makePatch.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#" Create a single patch. Note that function \code{makeClass} should be used preferably (see details).
#" Create a single patch
#'
#' @description Function will create a single patch. \strong{NOTE}: \code{makeClass} should be used preferably when creating a single patch, as better error and exception handling is provided.
#' @param context Raster object or matrix, an empty landscape raster or a mask indicating where the patch cannot be generated (see bgr below).
#' @param size integer. Size of the patch to be generated, as number of raster cells.
#' @param spt integer or matrix. The seed point location around which the patch is generated (a random point is given by default). It can be an integer, as index of the cell in the raster, or a two columns matrix indicating x and y coordinates (an integer vector of length 2 is accepted too).
Expand All @@ -11,7 +12,6 @@
#' list of two vectors is returned: one for the inner raster cells and the second for cells at the edge of the patch.
#' @details The patch is created starting from the seed point and iteratively sampling randomly neighbouring cells at the edge of the patch.
#' There is a tolerance of +/- 3 cells from the patch size declared in \code{size} argument.
#' Note that \code{makeClass} should be used preferably when creating a single patch, as better error and exception handling is provided for there.
#' Also, argument \code{bgr} accepts a single value only, unlike \code{makeClass} that accept multiple.
#' @examples
#' library(raster)
Expand Down
Loading

0 comments on commit 8e0b1e7

Please sign in to comment.