Skip to content

Commit

Permalink
restore basic functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosci committed Mar 15, 2018
1 parent f2998f6 commit b4502a1
Show file tree
Hide file tree
Showing 40 changed files with 1,496 additions and 173 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
^landscapetools\.Rproj$
^\.Rproj\.user$
^appveyor\.yml$
^README\.Rmd$
^\.travis\.yml$
^CODE_OF_CONDUCT\.md$
^LICENSE\.md$
^CONTRIBUTING\.md$
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false
cache: packages
25 changes: 25 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Contributor Code of Conduct

As contributors and maintainers of this project, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for
everyone, regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.

Examples of unacceptable behavior by participants include the use of sexual language or
imagery, derogatory comments or personal attacks, trolling, public or private harassment,
insults, or other unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not aligned to this
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
from the project team.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
opening an issue or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the Contributor Covenant
(http://contributor-covenant.org), version 1.0.0, available at
http://contributor-covenant.org/version/1/0/0/
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# CONTRIBUTING #

### Please contribute!

We love collaboration.

### Bugs?

* Submit an issue on the Issues page [here](https://github.com/marcosci/nlmr/issues)

### Code contributions

* Fork this repo to your Github account
* Clone your version on your account down to your machine from your account, e.g,. `git clone https://github.com/<yourgithubusername>/nlmr.git`
* Make sure to track progress upstream (i.e., on our version of `scrubr` at `ropensci/scrubr`) by doing `git remote add upstream https://github.com/ropensci/nlmr.git`. Before making changes make sure to pull changes in from upstream by doing either `git fetch upstream` then merge later or `git pull upstream` to fetch and merge in one step
* Make your changes (bonus points for making changes on a new branch)
* If you alter package functionality at all (e.g., the code itself, not just documentation)
please do write some tests to cover the new functionality.
* Push up to your account
* Submit a pull request to home base at `ropensci/nlmr`

### Questions? Get in touch: [[email protected]](mailto:[email protected])

### Thanks for contributing!
26 changes: 22 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
Package: landscapetools
Version: 0.0.0.9000
Version: 0.1
Title: What the Package Does (One Line, Title Case)
Description: What the package does (one paragraph).
Authors@R: person("First", "Last", , "[email protected]", c("aut", "cre"))
License: What license it uses
Authors@R: c(person("Marco", "Sciaini", email = "[email protected]", role = c("aut", "cre")),
person("Matthias", "Fritsch", email = "[email protected]", role = c("aut")))
License: GPL-3
Encoding: UTF-8
LazyData: true
ByteCompile: true
Suggests:
testthat
testthat,
nlmr
URL: https://github.com/marcosci/landscapetools
BugReports: https://github.com/marcosci/landscapetools/issues
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.0.1
Imports:
magrittr,
checkmate,
dplyr,
extrafont,
ggplot2,
purrr,
raster,
rasterVis,
tibble,
tidyr,
viridis
595 changes: 595 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Generated by roxygen2: fake comment so roxygen2 overwrites silently.
exportPattern("^[^\\.]")
# Generated by roxygen2: do not edit by hand

export("%>%")
export(theme_nlm)
export(theme_nlm_discrete)
export(theme_nlm_grey)
export(theme_nlm_grey_discrete)
export(util_binarize)
export(util_calc_boundaries)
export(util_classify)
export(util_facetplot)
export(util_import_roboto_condensed)
export(util_merge)
export(util_plot)
export(util_plot_grey)
export(util_raster2tibble)
export(util_rescale)
export(util_tibble2raster)
export(util_w2cp)
importFrom(magrittr,"%>%")
15 changes: 15 additions & 0 deletions R/landscapetools.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' landscapetools
#'
#' \emph{landscapetools} is
#'
#' @details ...
#'

# nocov start
# nolint start
"_PACKAGE"

globalVariables(c("value", "."))

# nolint end
# nocov end
77 changes: 38 additions & 39 deletions R/theme_nlm.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@
#'
#' @description Opinionated ggplot2 theme to visualize NLM raster.
#'
#' @param base_family [\code{character}()] base font family size
#' @param base_size [\code{numeric}(1)] base font size
#' @param plot_title_family [\code{character}()] plot title family
#' @param plot_title_face [\code{character}()] plot title face
#' @param plot_title_size [\code{character}()] plot title size
#' @param plot_title_margin [\code{numeric}(1)] plot title margin
#' @param plot_margin [\code{character}()]
#' plot margin (specify with \code{ggplot2::margin})
#' @param subtitle_family [\code{character}()] plot subtitle family
#' @param subtitle_face [\code{character}()]` plot subtitle face
#' @param subtitle_size [\code{numeric}(1)] plot subtitle size
#' @param subtitle_margin [\code{numeric}(1)]
#' @param base_family base font family size
#' @param base_size base font size
#' @param plot_title_family plot title family
#' @param plot_title_face plot title face
#' @param plot_title_size plot title size
#' @param plot_title_margin plot title margin
#' @param plot_margin plot margin (specify with `ggplot2::margin``)
#' @param subtitle_family plot subtitle family
#' @param subtitle_face plot subtitle face
#' @param subtitle_size plot subtitle size
#' @param subtitle_margin
#' plot subtitle margin bottom (single numeric value)
#' @param strip_text_family [\code{character}()] facet facet label font family
#' @param strip_text_face [\code{character}()] facet facet label font face
#' @param strip_text_size [\code{numeric}(1)]
#' facet label font family, face and size
#' @param caption_family [\code{character}()] plot caption family
#' @param caption_face [\code{character}()] plot caption face
#' @param caption_size [\code{numeric}(1)] plot caption size
#' @param caption_margin [\code{numeric}(1)] plot caption margin
#' @param legend_title [\code{character}()] Title of the legend (default "Z")
#' @param legend_labels [\code{character}()] Labels for the legend ticks, if
#' @param strip_text_family facet facet label font family
#' @param strip_text_face facet facet label font face
#' @param strip_text_size facet label font family, face and size
#' @param caption_family plot caption family
#' @param caption_face plot caption face
#' @param caption_size plot caption size
#' @param caption_margin plot caption margin
#' @param legend_title Title of the legend (default `"Z"`)
#' @param legend_labels Labels for the legend ticks, if
#' used with \code{\link{util_plot}} they are automatically derived.
#' @param ratio [\code{character}()]
#' @param ratio
#' ratio for tiles (default 1, if your raster is not a square the ratio should
#' be \code{raster::nrow(x) / raster::ncol(x)})
#' @param viridis_scale [\code{character}(1)]
#' @param viridis_scale
#' Five options are available: "viridis - magma" (= "A"),
#' "viridis - inferno" (= "B"),
#' "viridis - plasma" (= "C"),
#' "viridis - viridis" (= "D", the default option)
#' "viridis - viridis" (= "D", the default option),
#' "viridis - cividis" (= "E")
#'
#' @details
#' A focused theme to visualize raster data that sets a lot of defaults for the
Expand All @@ -55,7 +54,7 @@
#' # nolint start
#' \dontrun{
#' # simulate NLM
#' x <- nlm_random(ncol = 75,
#' x <- nlmr::nlm_random(ncol = 75,
#' nrow = 75)
#' # classify
#' y <- c(0.5, 0.15, 0.25)
Expand Down Expand Up @@ -111,20 +110,20 @@ NULL

#' @rdname theme_nlm
#' @export
theme_nlm <- function(base_family = "serif",
theme_nlm <- function(base_family = "plain",
base_size = 11.5,
plot_title_family = "serif",
plot_title_family = "plain",
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = "serif",
subtitle_family = "plain",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = "serif",
caption_family = "plain",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand Down Expand Up @@ -197,20 +196,20 @@ theme_nlm <- function(base_family = "serif",
#' @rdname theme_nlm
#' @export
theme_nlm_discrete <- function(
base_family = "serif",
base_family = "plain",
base_size = 11.5,
plot_title_family = base_family,
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = "serif",
subtitle_family = "plain",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = "serif",
caption_family = "plain",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand Down Expand Up @@ -289,20 +288,20 @@ theme_nlm_discrete <- function(

#' @rdname theme_nlm
#' @export
theme_nlm_grey <- function(base_family = "serif",
theme_nlm_grey <- function(base_family = "plain",
base_size = 11.5,
plot_title_family = base_family,
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = "serif",
subtitle_family = "plain",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = "serif",
caption_family = "plain",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand Down Expand Up @@ -375,20 +374,20 @@ theme_nlm_grey <- function(base_family = "serif",
#' @rdname theme_nlm
#' @export
theme_nlm_grey_discrete <-
function(base_family = "serif",
function(base_family = "plain",
base_size = 11.5,
plot_title_family = base_family,
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = "serif",
subtitle_family = "plain",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = "serif",
caption_family = "plain",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand Down
11 changes: 5 additions & 6 deletions R/util_binarize.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#' Binarize continuous raster values
#'
#' @description Classify continuous raster values into binary map cells based upon given
#' break(s).
#' break(`s`).
#'
#' @details Breaks are considered to be habitat percentages (p). If more than
#' @details Breaks are considered to be habitat percentages (`p`). If more than
#' one percentage is given multiple layers are written in the same brick.
#'
#' @param x [\code{Raster* object}]
#'
#' @param breaks a vector with one or more break percentages
#' @param x Raster* object
#'
#' @param breaks Vector with one or more break percentages
#'
#' @return RasterLayer / RasterBrick
#'
#' @examples
#' rndMap <- nlm_random(10, 10)
#' rndMap <- nlmr::nlm_random(10, 10)
#' breaks <- c(0.3, 0.5, 0.7, 0.9)
#' rnd_bin <- util_binarize(rndMap, breaks)
#' util_plot(rnd_bin)
Expand Down
4 changes: 2 additions & 2 deletions R/util_calcboundaries.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#' @description Determine upper class boundaries for classification of a matrix with values ranging 0-1 based upon an
#' vector of cumulative proportions.
#'
#' @param x [\code{matrix(x,y)}]\cr 2D matrix of data values.
#' @param cumulative_proportions [\code{numerical}]\cr Vector of class cumulative proportions, as generated by \code{w2cp}.
#' @param x 2D matrix of data values.
#' @param cumulative_proportions Vector of class cumulative proportions, as generated by `w2cp`.
#'
#'
#' @return Numerical vector with boundaries for matrix classification
Expand Down
11 changes: 4 additions & 7 deletions R/util_classify.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@
#' If the numerical vector of weightings does not sum up to 1, the sum of the
#' weightings is divided by the number of elements in the weightings vector and this is then used for the classification.
#'
#' @param x [\code{matrix(x,y)}]\cr
#' 2D matrix of data values.
#' @param weighting [\code{numerical}]\cr
#' Vector of numeric values.
#' @param level_names [\code{character}]\cr
#' Vector of names for the factor levels.
#' @param x 2D matrix
#' @param weighting Vector of numeric values.
#' @param level_names Vector of names for the factor levels.
#'
#' @return RasterLayer
#'
#' @examples
#' x <- nlm_random(10, 10)
#' x <- nlmr::nlm_random(10, 10)
#' y <- c(0.5, 0.25, 0.25)
#' util_classify(x, y, level_names = c("Land Use 1", "Land Use 2", "Land Use 3"))
#'
Expand Down
10 changes: 5 additions & 5 deletions R/util_facetplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
#' size of the maps it is advisable to store the plot in an object and print it to
#' a file. This will help with compressing and rendering the image.
#'
#' @param x [\code{Raster* object}] (Layer, Stack, Brick) or a list of rasterLayers.
#' @param x Raster* Layer, Stack, Brick or a list of rasterLayers.
#' @param nrow,ncol Number of rows and columns.
#'
#' @return ggplot
#'
#' @examples
#' \dontrun{
#' l1 <- nlm_fBm(64, 64)
#' l2 <- nlm_planargradient(64, 64)
#' l3 <- nlm_randomrectangularcluster(ncol = 60, nrow = 60, minl = 5, maxl = 10)
#' l4 <- nlm_random(64, 64)
#' l1 <- nlmr::nlm_fBm(64, 64)
#' l2 <- nlmr::nlm_planargradient(64, 64)
#' l3 <- nlmr::nlm_randomrectangularcluster(ncol = 60, nrow = 60, minl = 5, maxl = 10)
#' l4 <- nlmr::nlm_random(64, 64)
#'
#' bri1 <- raster::brick(l1, l2)
#' util_facetplot(bri1)
Expand Down
Loading

0 comments on commit b4502a1

Please sign in to comment.