From 019b60dce45df8fb5b6c17d79f3eddbf0f237741 Mon Sep 17 00:00:00 2001 From: mtennekes Date: Mon, 12 Feb 2018 09:39:00 +0100 Subject: [PATCH 1/6] fixed smooth_map (which is now similar to sf branch) --- DESCRIPTION | 6 +++--- NEWS | 3 +++ R/smooth_map.R | 4 ++-- man/smooth_map.Rd | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0b77b13..ae2851b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,13 @@ Package: tmaptools Type: Package Title: Thematic Map Tools -Version: 1.2-2 +Version: 1.2-3 Authors@R: person("Martijn", "Tennekes", email="mtennekes@gmail.com", role=c("aut", "cre")) Description: Set of tools for reading and processing spatial data. The aim is to supply the workflow to create thematic maps. This package also facilitates 'tmap', the package for visualizing thematic maps. License: GPL-3 Encoding: UTF-8 LazyData: true -Date: 2017-11-24 +Date: 2018-02-12 Depends: R (>= 3.0), methods @@ -29,7 +29,7 @@ Imports: dichromat, XML Suggests: - tmap (>= 1.8-1), + tmap (>= 1.11-1), OpenStreetMap, png, shiny, diff --git a/NEWS b/NEWS index c921fac..cd3f980 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +version 1.2-3 +- fixed bug in smooth_map + version 1.2-2 - improved smooth_map diff --git a/R/smooth_map.R b/R/smooth_map.R index 62f5f5f..472ebd9 100644 --- a/R/smooth_map.R +++ b/R/smooth_map.R @@ -5,7 +5,7 @@ #' For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implemention is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. #' #' @param shp shape object of class \code{\link[sp:Spatial]{Spatial}}, \code{\link[raster:Raster-class]{Raster}}, or \code{sf}. Spatial points, polygons, and grids are supported. Spatial lines are not. -#' @param var variable name. Not needed for \code{\link[sp:SpatialPoints]{SpatialPoints}}. If missing, the first variable name is taken. +#' @param var variable name. Not needed for \code{\link[sp:SpatialPoints]{SpatialPoints}}. If missing, the first variable name is taken. For polygons, the variable should contain densities, not absolute numbers. #' @param nrow number of rows in the raster that is used to smooth the shape object. Only applicable if shp is not a \code{\link[sp:SpatialGridDataFrame]{SpatialGrid(DataFrame)}} or \code{\link[raster:Raster-class]{Raster}} #' @param ncol number of rows in the raster that is used to smooth the shape object. Only applicable if shp is not a \code{\link[sp:SpatialGridDataFrame]{SpatialGrid(DataFrame)}} or \code{\link[raster:Raster-class]{Raster}} #' @param N preferred number of points in the raster that is used to smooth the shape object. Only applicable if shp is not a \code{\link[sp:SpatialGridDataFrame]{SpatialGrid(DataFrame)}} or \code{\link[raster:Raster-class]{Raster}} @@ -208,7 +208,7 @@ smooth_map <- function(shp, var=NULL, nrow=NA, ncol=NA, N=250000, unit="km", uni # normalize r and x$fhat if (inherits(shp, "SpatialPoints")) { - norm_weight <- length(shp) * weight / sum(r[], na.rm=TRUE) + norm_weight <- length(shp) * weight / sum(r[], na.rm=TRUE) / cell.area } else { norm_weight <- sum(shp[], na.rm=TRUE) / sum(r[], na.rm=TRUE) } diff --git a/man/smooth_map.Rd b/man/smooth_map.Rd index 2f50f9f..25f20ed 100644 --- a/man/smooth_map.Rd +++ b/man/smooth_map.Rd @@ -14,7 +14,7 @@ smooth_map(shp, var = NULL, nrow = NA, ncol = NA, N = 250000, \arguments{ \item{shp}{shape object of class \code{\link[sp:Spatial]{Spatial}}, \code{\link[raster:Raster-class]{Raster}}, or \code{sf}. Spatial points, polygons, and grids are supported. Spatial lines are not.} -\item{var}{variable name. Not needed for \code{\link[sp:SpatialPoints]{SpatialPoints}}. If missing, the first variable name is taken.} +\item{var}{variable name. Not needed for \code{\link[sp:SpatialPoints]{SpatialPoints}}. If missing, the first variable name is taken. For polygons, the variable should contain densities, not absolute numbers.} \item{nrow}{number of rows in the raster that is used to smooth the shape object. Only applicable if shp is not a \code{\link[sp:SpatialGridDataFrame]{SpatialGrid(DataFrame)}} or \code{\link[raster:Raster-class]{Raster}}} From a4092b6ca4db53009b5fea870fc0babee41d3cf5 Mon Sep 17 00:00:00 2001 From: mtennekes Date: Tue, 13 Feb 2018 11:30:43 +0100 Subject: [PATCH 2/6] CRAN 1.2-3 submitted --- .travis.yml | 22 +++++++++++++++------- DESCRIPTION | 4 ++-- cran-comments.md | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 cran-comments.md diff --git a/.travis.yml b/.travis.yml index a2b7a9f..d8b378b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,23 @@ language: r cache: packages -addons: - apt: - packages: - - libv8-dev - - valgrind - before_install: - sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes - sudo apt-get --yes --force-yes update -qq - - sudo apt-get install --yes libudunits2-dev libproj-dev libgeos-dev libgdal-dev + # install tmap dependencies + - sudo apt-get install --yes libprotobuf-dev protobuf-compiler libv8-3.14-dev + # install tmap dependencies; for 16.04 libjq-dev this ppa is needed: + - sudo add-apt-repository -y ppa:opencpu/jq + - sudo apt-get --yes --force-yes update -qq + - sudo apt-get install libjq-dev + # units/udunits2 dependency: + - sudo apt-get install --yes libudunits2-dev + # sf dependencies: + - sudo apt-get install --yes libproj-dev libgeos-dev libgdal-dev + # other dependencies (indirect) + - sudo apt-get install -y libprotobuf-dev protobuf-compiler + - sudo apt-get install libssl-dev + - sudo apt-get install libcairo2-dev sudo: required @@ -24,3 +31,4 @@ r_packages: - rgeos - roxygen2 - rmarkdown + - tmap diff --git a/DESCRIPTION b/DESCRIPTION index ae2851b..23f75ca 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Description: Set of tools for reading and processing spatial data. The aim is to License: GPL-3 Encoding: UTF-8 LazyData: true -Date: 2018-02-12 +Date: 2018-02-13 Depends: R (>= 3.0), methods @@ -29,7 +29,7 @@ Imports: dichromat, XML Suggests: - tmap (>= 1.11-1), + tmap (>= 1.10), OpenStreetMap, png, shiny, diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..f19a234 --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,23 @@ +## Test environments +* local OS X install, R 3.4.1 +* ubuntu 12.04 (on travis-ci), R 3.4.1 +* win-builder (devel and release) + +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. + +## Reverse dependencies + +This is a new release, so there are no reverse dependencies. + +--- + +* I have run R CMD check on the NUMBER downstream dependencies. + (Summary at ...). + +* FAILURE SUMMARY + +* All revdep maintainers were notified of the release on RELEASE DATE. From 59459c1b1b39376b40313e8248d0169d35d1ef0b Mon Sep 17 00:00:00 2001 From: mtennekes Date: Tue, 13 Feb 2018 15:23:10 +0100 Subject: [PATCH 3/6] CRAN 1.2-3 --- cran-comments.md | 23 ----------------------- examples/aggregate_map.R | 2 +- man/aggregate_map.Rd | 2 +- 3 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 cran-comments.md diff --git a/cran-comments.md b/cran-comments.md deleted file mode 100644 index f19a234..0000000 --- a/cran-comments.md +++ /dev/null @@ -1,23 +0,0 @@ -## Test environments -* local OS X install, R 3.4.1 -* ubuntu 12.04 (on travis-ci), R 3.4.1 -* win-builder (devel and release) - -## R CMD check results - -0 errors | 0 warnings | 1 note - -* This is a new release. - -## Reverse dependencies - -This is a new release, so there are no reverse dependencies. - ---- - -* I have run R CMD check on the NUMBER downstream dependencies. - (Summary at ...). - -* FAILURE SUMMARY - -* All revdep maintainers were notified of the release on RELEASE DATE. diff --git a/examples/aggregate_map.R b/examples/aggregate_map.R index 2800370..7b80828 100644 --- a/examples/aggregate_map.R +++ b/examples/aggregate_map.R @@ -8,7 +8,6 @@ if (require(tmap)) { # map decreased by factor 4 for each dimension land4 <- aggregate_map(land, fact=4, agg.fun="modal") qtm(land4, raster="cover_cls") - } # map decreased by factor 8, where the variable trees is # aggregated with mean, min, and max @@ -19,6 +18,7 @@ if (require(tmap)) { tm_raster(c("trees.1", "trees.2", "trees.3"), title="Trees (%)") + tm_facets(free.scales=FALSE) + tm_layout(panel.labels = c("mean", "min", "max")) + } data(NLD_muni, NLD_prov) diff --git a/man/aggregate_map.Rd b/man/aggregate_map.Rd index 3773259..bb0c4f6 100644 --- a/man/aggregate_map.Rd +++ b/man/aggregate_map.Rd @@ -60,7 +60,6 @@ if (require(tmap)) { # map decreased by factor 4 for each dimension land4 <- aggregate_map(land, fact=4, agg.fun="modal") qtm(land4, raster="cover_cls") - } # map decreased by factor 8, where the variable trees is # aggregated with mean, min, and max @@ -71,6 +70,7 @@ if (require(tmap)) { tm_raster(c("trees.1", "trees.2", "trees.3"), title="Trees (\%)") + tm_facets(free.scales=FALSE) + tm_layout(panel.labels = c("mean", "min", "max")) + } data(NLD_muni, NLD_prov) From 85a69437532f6253f8cd8ca6af33853e8c7c2f7a Mon Sep 17 00:00:00 2001 From: mtennekes Date: Tue, 10 Apr 2018 08:57:22 +0200 Subject: [PATCH 4/6] VERSION 1.2-4 (added JSS paper references) --- .Rbuildignore | 1 + DESCRIPTION | 4 +- NEWS | 3 ++ R/aggregate_map.R | 1 + R/append_data.R | 1 + R/approx_areas.R | 1 + R/approx_distances.R | 1 + R/bb.R | 1 + R/calc_densities.R | 1 + R/crop_shape.R | 1 + R/geocode_OSM.R | 99 +++++++++++++++++++------------------- R/get_asp_ratio.R | 1 + R/get_brewer_pal.R | 1 + R/get_proj4_code.R | 1 + R/map_coloring.R | 1 + R/palette_explorer.R | 1 + R/pkg.R | 1 + R/read_GPX.R | 1 + R/read_osm.R | 1 + R/read_shape.R | 1 + R/sample_dots.R | 1 + R/set_projection.R | 1 + R/simplify_shape.R | 1 + R/smooth_map.R | 2 +- R/smooth_raster_cover.R | 35 +++++++------- cran-comments.md | 27 +++++++++++ inst/CITATION | 15 ++++++ man/aggregate_map.Rd | 3 ++ man/append_data.Rd | 3 ++ man/approx_areas.Rd | 3 ++ man/approx_distances.Rd | 3 ++ man/bb.Rd | 3 ++ man/calc_densities.Rd | 3 ++ man/crop_shape.Rd | 3 ++ man/geocode_OSM.Rd | 3 ++ man/get_asp_ratio.Rd | 3 ++ man/get_brewer_pal.Rd | 3 ++ man/get_proj4.Rd | 3 ++ man/map_coloring.Rd | 3 ++ man/palette_explorer.Rd | 2 + man/read_GPX.Rd | 3 ++ man/read_osm.Rd | 3 ++ man/read_shape.Rd | 3 ++ man/sample_dots.Rd | 3 ++ man/set_projection.Rd | 3 ++ man/simplify_shape.Rd | 3 ++ man/smooth_map.Rd | 3 ++ man/smooth_raster_cover.Rd | 3 ++ man/tmaptools-package.Rd | 3 ++ 49 files changed, 201 insertions(+), 69 deletions(-) create mode 100644 cran-comments.md create mode 100644 inst/CITATION diff --git a/.Rbuildignore b/.Rbuildignore index 522c98c..ed921fb 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -8,3 +8,4 @@ README .travis.yml appveyor.yml +^cran-comments\.md$ diff --git a/DESCRIPTION b/DESCRIPTION index 23f75ca..8451394 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,13 @@ Package: tmaptools Type: Package Title: Thematic Map Tools -Version: 1.2-3 +Version: 1.2-4 Authors@R: person("Martijn", "Tennekes", email="mtennekes@gmail.com", role=c("aut", "cre")) Description: Set of tools for reading and processing spatial data. The aim is to supply the workflow to create thematic maps. This package also facilitates 'tmap', the package for visualizing thematic maps. License: GPL-3 Encoding: UTF-8 LazyData: true -Date: 2018-02-13 +Date: 2018-04-10 Depends: R (>= 3.0), methods diff --git a/NEWS b/NEWS index cd3f980..96c61a5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +version 1.2-4 +- added references to JSS paper (including citation) + version 1.2-3 - fixed bug in smooth_map diff --git a/R/aggregate_map.R b/R/aggregate_map.R index 123618a..5676822 100644 --- a/R/aggregate_map.R +++ b/R/aggregate_map.R @@ -70,6 +70,7 @@ weighted.modal <- function(x, w, na.rm=FALSE) { #' @importFrom stats weighted.mean #' @return A shape object, in the same format as \code{shp} #' @example ./examples/aggregate_map.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export aggregate_map <- function(shp, by=NULL, fact=NULL, agg.fun=NULL, weights=NULL, na.rm=FALSE, ...) { weighted.mean <- NULL diff --git a/R/append_data.R b/R/append_data.R index 6e44866..955f0bf 100644 --- a/R/append_data.R +++ b/R/append_data.R @@ -20,6 +20,7 @@ #' @return Shape object with appended data. Tip: run \code{append_data} without assigning the result to check the coverage. #' @example ./examples/append_data.R #' @rdname append_data +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export append_data <- function(shp, data, key.shp = NULL, key.data = NULL, ignore.duplicates=FALSE, ignore.na=FALSE, fixed.order=is.null(key.data) && is.null(key.shp)) { is_sf <- inherits(shp, c("sf", "sfc")) diff --git a/R/approx_areas.R b/R/approx_areas.R index 0eb8ac4..8baabca 100644 --- a/R/approx_areas.R +++ b/R/approx_areas.R @@ -25,6 +25,7 @@ #' @seealso \code{\link{projection_units}} and \code{\link{approx_distances}} #' @importFrom rgeos gArea #' @importFrom geosphere areaPolygon +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export approx_areas <- function(shp, target="metric", orig=NA, to=NA, total.area=NA, show.warnings=TRUE) { diff --git a/R/approx_distances.R b/R/approx_distances.R index 2b66537..07149d0 100644 --- a/R/approx_distances.R +++ b/R/approx_distances.R @@ -13,6 +13,7 @@ #' @importFrom geosphere distGeo #' @example ./examples/approx_distances.R #' @seealso \code{\link{projection_units}} and \code{\link{approx_areas}} +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export approx_distances <- function(x, y = NULL, projection = NULL, target="metric", orig=NA, to=NA, show.warnings=TRUE) { ## set metric and imperial to defaults: km and mi diff --git a/R/bb.R b/R/bb.R index c6273a1..0007148 100644 --- a/R/bb.R +++ b/R/bb.R @@ -39,6 +39,7 @@ #' @importFrom rgeos gIntersection #' @example ./examples/bb.R #' @seealso \code{\link{geocode_OSM}} +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export bb <- function(x=NA, ext=NULL, cx=NULL, cy=NULL, width=NULL, height=NULL, xlim=NULL, ylim=NULL, relative = FALSE, current.projection=NULL, projection=NULL, as.extent=FALSE) { diff --git a/R/calc_densities.R b/R/calc_densities.R index a85d8fc..988045f 100644 --- a/R/calc_densities.R +++ b/R/calc_densities.R @@ -12,6 +12,7 @@ #' @param drop boolean that determines whether an one-column data-frame should be returned as a vector #' @keywords densities #' @return Vector or data.frame (depending on whether \code{length(var)==1} with density values. This can be appended directly to the shape file with \code{\link{append_data}} with \code{fixed.order=TRUE}. +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @example ./examples/calc_densities.R #' @export calc_densities <- function(shp, var, target="metric", orig=NA, to=NA, total.area=NA, suffix=NA, drop=TRUE) { diff --git a/R/crop_shape.R b/R/crop_shape.R index d93e5cc..6d0bb32 100644 --- a/R/crop_shape.R +++ b/R/crop_shape.R @@ -12,6 +12,7 @@ #' @seealso \code{\link{bb}} #' @importFrom raster trim mask brick #' @example ./examples/crop_shape.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @return cropped shape, in the same class as \code{x} crop_shape <- function(x, y, polygon = FALSE, ...) { is_sf <- inherits(x, c("sf", "sfc")) diff --git a/R/geocode_OSM.R b/R/geocode_OSM.R index c9404c7..1a5e071 100644 --- a/R/geocode_OSM.R +++ b/R/geocode_OSM.R @@ -1,7 +1,7 @@ #' Geocodes a location using OpenStreetMap Nominatim -#' +#' #' Geocodes a location (based on a search query) to coordinates and a bounding box. Similar to geocode from the ggmap package. It uses OpenStreetMap Nominatim. For processing large amount of queries, please read the usage policy (\url{http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy}). -#' +#' #' @param q a character (vector) that specifies a search query. For instance \code{"India"} or \code{"CBS Weg 11, Heerlen, Netherlands"}. #' @param projection projection in which the coordinates and bounding box are returned. Either a \code{\link[sp:CRS]{CRS}} object or a character value. If it is a character, it can either be a \code{PROJ.4} character string or a shortcut. See \code{\link{get_proj4}} for a list of shortcut values. By default latitude longitude coordinates. #' @param return.first.only Only return the first result @@ -14,38 +14,39 @@ #' @importFrom XML xmlChildren xmlRoot xmlAttrs xmlTreeParse xmlValue #' @example ./examples/geocode_OSM.R #' @seealso \code{\link{rev_geocode_OSM}}, \code{\link{bb}} +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} geocode_OSM <- function(q, projection=NULL, return.first.only=TRUE, details=FALSE, as.data.frame=NA, as.SPDF=FALSE, server="http://nominatim.openstreetmap.org") { n <- length(q) q2 <- gsub(" ", "+", enc2utf8(q), fixed = TRUE) addr <- paste0(server, "/search?q=", q2, "&format=xml&polygon=0&addressdetails=0") - + project <- !missing(projection) if (project) projection <- get_proj4(projection, as.CRS = TRUE) - - + + if (is.na(as.data.frame)) as.data.frame <- (n>1) if (as.SPDF) { as.data.frame <- TRUE return.first.only <- TRUE } - + output2 <- lapply(1:n, function(k) { tmpfile <- tempfile() suppressWarnings(download.file(addr[k], destfile = tmpfile, mode= "wb", quiet = TRUE)) - + doc <- xmlTreeParse(tmpfile, encoding="UTF-8") unlink(tmpfile) - - res <- xmlChildren(xmlRoot(doc)) - + + res <- xmlChildren(xmlRoot(doc)) + if (length(res)==0) { - warning(paste("No results found for \"", q[k], "\".", sep="")) #if (n==1) + warning(paste("No results found for \"", q[k], "\".", sep="")) #if (n==1) return(NULL) } - + idx <- if (return.first.only) 1 else 1:length(res) - + sn_names <- c("place_id", "osm_type", "osm_id", "place_rank", "display_name", "class", "type", "importance", "icon") output <- lapply(idx, function(i) { search_result <- xmlAttrs(res[[i]]) @@ -53,31 +54,31 @@ geocode_OSM <- function(q, projection=NULL, return.first.only=TRUE, details=FALS search_result_id <- search_result[sn_names] names(search_result_id) <- sn_names # in case of missings Encoding(search_result_id) <- "UTF-8" - + search_result_loc <- as.numeric(search_result[c("lat", "lon")]) names(search_result_loc) <- c("lat", "lon") - + search_result_bb <- as.numeric(unlist(strsplit(search_result["boundingbox"], ","))) - + if (!project) { names(search_result_bb) <- c("lat_min", "lat_max", "lon_min", "lon_max") b <- bb(xlim=search_result_bb[3:4], ylim=search_result_bb[1:2]) - + coords <- search_result_loc[c("lon", "lat")] names(coords) <- c("x", "y") - + } else { b <- bb(xlim=search_result_bb[3:4], ylim=search_result_bb[1:2], current.projection = .CRS_longlat, projection=projection) - + search_result_bb <- b[c(2,4,1,3)] names(search_result_bb) <- c("y_min", "y_max", "x_min", "x_max") - - + + p <- SpatialPoints(matrix(search_result_loc[2:1], nrow=1), proj4string=.CRS_longlat) p <- set_projection(p, projection=projection) coords <- as.vector(attr(p, "coords")) names(coords) <- c("x", "y") - + search_result_loc <- as.list(coords) names(search_result_loc) <- c("x", "y") } @@ -87,29 +88,29 @@ geocode_OSM <- function(q, projection=NULL, return.first.only=TRUE, details=FALS search_result_loc, search_result_bb) } else { - c(list(query=q[k], + c(list(query=q[k], coords=coords, bbox=b)) } - + if (details) res <- c(res, search_result_id) if (as.data.frame) res <- as.data.frame(res, stringsAsFactors=FALSE) res }) }) - + output3 <- do.call(c, output2) - + if (as.data.frame) { df <- do.call(rbind, output3) - + if (as.SPDF) { if (!project) { - spdf <- SpatialPointsDataFrame(df[, c("lon", "lat")], proj4string=.CRS_longlat, + spdf <- SpatialPointsDataFrame(df[, c("lon", "lat")], proj4string=.CRS_longlat, data = df, match.ID = FALSE) } else { - spdf <- SpatialPointsDataFrame(df[, c("x", "y")], proj4string=projection, + spdf <- SpatialPointsDataFrame(df[, c("x", "y")], proj4string=projection, data = df, match.ID = FALSE) } @@ -126,9 +127,9 @@ geocode_OSM <- function(q, projection=NULL, return.first.only=TRUE, details=FALS #' Reverse geocodes a location using OpenStreetMap Nominatim -#' +#' #' Reverse geocodes a location (based on spatial coordinates) to an address. It uses OpenStreetMap Nominatim. For processing large amount of queries, please read the usage policy (\url{http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy}). -#' +#' #' @param x x coordinate(s), or a \code{\link[sp:SpatialPoints]{SpatialPoints}} object #' @param y y coordinate(s) #' @param zoom zoom level @@ -141,15 +142,15 @@ geocode_OSM <- function(q, projection=NULL, return.first.only=TRUE, details=FALS #' @example ./examples/rev_geocode_OSM.R #' @seealso \code{\link{geocode_OSM}} rev_geocode_OSM <- function(x, y=NULL, zoom=NULL, projection=NULL, as.data.frame=NA, server="http://nominatim.openstreetmap.org") { - + project <- !missing(projection) - + if (project) projection <- get_proj4(projection, as.CRS = TRUE) - + if (inherits(x, "SpatialPoints")) { - + isproj <- is.projected(x) - + if (is.na(isproj)) { if (project) { x <- set_projection(x, current.projection = projection, projection=.CRS_longlat) @@ -183,9 +184,9 @@ rev_geocode_OSM <- function(x, y=NULL, zoom=NULL, projection=NULL, as.data.frame lat <- coords[,2] } } - + if (is.na(as.data.frame)) as.data.frame <- (n>1) - + if (missing(zoom)) { qzoom <- "" strzoom <- "" @@ -193,9 +194,9 @@ rev_geocode_OSM <- function(x, y=NULL, zoom=NULL, projection=NULL, as.data.frame qzoom <- paste0("&zoom=", zoom) strzoom <- paste0(", zoom = ", zoom) } - + addr <- paste0(server, "/reverse?format=xml&lat=", lat, "&lon=", lon, qzoom, "&addressdetails=1") - + dfs <- lapply(1:n, function(i) { # download query @@ -203,14 +204,14 @@ rev_geocode_OSM <- function(x, y=NULL, zoom=NULL, projection=NULL, as.data.frame suppressWarnings(download.file(addr[i], destfile = tmpfile, mode= "wb", quiet = TRUE)) doc <- xmlTreeParse(tmpfile, encoding="UTF-8") unlink(tmpfile) - + # read xml document - res <- xmlChildren(xmlRoot(doc)) - + res <- xmlChildren(xmlRoot(doc)) + # get name result_name <- xmlValue(res[[1]]) Encoding(result_name) <- "UTF-8" - + # get osm id, location, bbox search_result <- xmlAttrs(res[[1]]) search_result_id <- search_result[c("place_id", "osm_type", "osm_id", "ref")] @@ -220,12 +221,12 @@ rev_geocode_OSM <- function(x, y=NULL, zoom=NULL, projection=NULL, as.data.frame names(search_result_ll) <- c("lat", "lon") search_result_bb <- as.numeric(unlist(strsplit(search_result["boundingbox"], ","))) names(search_result_bb) <- c("lat_min", "lat_max", "lon_min", "lon_max") - + # get address addr_result <- xmlChildren(res[[2]]) dfnames <- names(addr_result) dfvalues <- lapply(1:length(addr_result), function(j) { - v <- xmlValue(addr_result[[j]]) + v <- xmlValue(addr_result[[j]]) Encoding(v) <- "UTF-8" v }) @@ -239,16 +240,16 @@ rev_geocode_OSM <- function(x, y=NULL, zoom=NULL, projection=NULL, as.data.frame search_result_bb, dfvalues) }) - + # cast to data.frame if (as.data.frame) { addrnames <- sort(unique(unlist(lapply(dfs, function(df) { names(df)[14:length(df)] })))) - + addrlist <- lapply(addrnames, function(a) NA) names(addrlist) <- addrnames - + do.call(rbind, c(lapply(dfs, function(df) { sel <- 14:length(df) addrlist[names(df)[sel]] <- df[sel] diff --git a/R/get_asp_ratio.R b/R/get_asp_ratio.R index 04d85f7..bb5b9e8 100644 --- a/R/get_asp_ratio.R +++ b/R/get_asp_ratio.R @@ -13,6 +13,7 @@ #' @import sp #' @importFrom raster couldBeLonLat #' @example ./examples/get_asp_ratio.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export get_asp_ratio <- function(x, is.projected = NA, width=700, height=700, res=100) { if (inherits(x, "tmap")) { diff --git a/R/get_brewer_pal.R b/R/get_brewer_pal.R index c65919f..4c7e1b3 100644 --- a/R/get_brewer_pal.R +++ b/R/get_brewer_pal.R @@ -12,6 +12,7 @@ #' @return vector of color values. It is silently returned when \code{plot=TRUE}. #' @example ./examples/get_brewer_pal.R #' @seealso \code{\link{palette_explorer}} +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @import grid #' @export get_brewer_pal <- function(palette, n=5, contrast=NA, stretch=TRUE, plot=TRUE) { diff --git a/R/get_proj4_code.R b/R/get_proj4_code.R index 1c0e857..e0b99f7 100644 --- a/R/get_proj4_code.R +++ b/R/get_proj4_code.R @@ -31,6 +31,7 @@ #' @importFrom rgdal CRSargs make_EPSG checkCRSArgs #' @import sp #' @seealso \url{http://en.wikipedia.org/wiki/List_of_map_projections} for a overview of projections. \url{http://trac.osgeo.org/proj/} for the \code{PROJ.4} project home page. An extensive list of \code{PROJ.4} codes can be created with rgdal's \code{\link[rgdal:make_EPSG]{make_EPSG}}. +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export get_proj4 <- function(x, as.CRS=FALSE) { if (is.null(x)) { diff --git a/R/map_coloring.R b/R/map_coloring.R index 3bdcc85..dfa303e 100644 --- a/R/map_coloring.R +++ b/R/map_coloring.R @@ -11,6 +11,7 @@ #' @return If \code{palette} is defined, a vector of colors is returned, otherwise a vector of color indices. #' @importFrom spdep poly2nb #' @example ./examples/map_coloring.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export map_coloring <- function(x, algorithm="greedy", ncols=NA, minimize=FALSE, palette=NULL, contrast=1) { if (inherits(x, c("sf", "sfc"))) x <- as(x, "Spatial") diff --git a/R/palette_explorer.R b/R/palette_explorer.R index 80334e0..d408a3c 100644 --- a/R/palette_explorer.R +++ b/R/palette_explorer.R @@ -86,6 +86,7 @@ is_light <- function(col) { #' @example ./examples/palette_explorer.R #' @seealso \code{\link{get_brewer_pal}}, \code{\link[dichromat:dichromat]{dichromat}}, \code{\link[RColorBrewer:RColorBrewer]{RColorBrewer}} #' @references \url{http://www.color-blindness.com/types-of-color-blindness/} +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} palette_explorer <- function() { if (!requireNamespace("shiny")) stop("shiny package needed for this function to work. Please install it.", call. = FALSE) if (!requireNamespace("shinyjs")) stop("shinyjs package needed for this function to work. Please install it.", call. = FALSE) diff --git a/R/pkg.R b/R/pkg.R index b81b672..0446983 100644 --- a/R/pkg.R +++ b/R/pkg.R @@ -63,6 +63,7 @@ #' @aliases tmaptools #' @docType package #' @author Martijn Tennekes \email{mtennekes@@gmail.com} +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @keywords GIS, thematic maps, spatial data NULL diff --git a/R/read_GPX.R b/R/read_GPX.R index 7ee0db4..dc5a976 100644 --- a/R/read_GPX.R +++ b/R/read_GPX.R @@ -9,6 +9,7 @@ #' @importFrom rgdal readOGR ogrInfo #' @export #' @example ./examples/read_GPX.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} read_GPX <- function(file, layers=c("waypoints", "tracks", "routes", "track_points", "route_points"), as.sf=FALSE) { if (!all(layers %in% c("waypoints", "tracks", "routes", "track_points", "route_points"))) stop("Incorrect layer(s)", call. = FALSE) diff --git a/R/read_osm.R b/R/read_osm.R index 84ea1c1..b9e99ce 100644 --- a/R/read_osm.R +++ b/R/read_osm.R @@ -16,6 +16,7 @@ #' @importFrom raster raster #' @export #' @example ./examples/read_osm.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @return The output of \code{read_osm} is a \code{\link[sp:SpatialGridDataFrame]{SpatialGridDataFrame}} if \code{raster=TRUE}, and otherwise a named list of \code{\link[sp:SpatialPolygonsDataFrame]{SpatialPolygonsDataFrame}}, \code{\link[sp:SpatialLinesDataFrame]{SpatialLinesDataFrame}}, and/or \code{\link[sp:SpatialPointsDataFrame]{SpatialPointsDataFrame}} objects. The names of this list are the names of arguments defined at \code{...}. read_osm <- function(x, raster=NA, zoom=NULL, type="osm", minNumTiles=NULL, mergeTiles=NULL, ...) { if (!get(".internet", envir = .TMAPTOOLS_CACHE)) stop("No internet connection found.") diff --git a/R/read_shape.R b/R/read_shape.R index dc10337..e3efc54 100644 --- a/R/read_shape.R +++ b/R/read_shape.R @@ -12,6 +12,7 @@ #' @param ... other parameters, such as \code{stringsAsFactors}, are passed on to \code{\link[rgdal:readOGR]{readOGR}} #' @return shape object from class \code{\link[sp:Spatial]{Spatial}} or \code{sf} if \code{as.sf = TRUE} #' @importFrom rgdal readOGR +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @import sp #' @export read_shape <- function(file, current.projection=NULL, as.sf=FALSE, ...){ diff --git a/R/sample_dots.R b/R/sample_dots.R index 6e649c6..4794a9c 100644 --- a/R/sample_dots.R +++ b/R/sample_dots.R @@ -22,6 +22,7 @@ #' @param ... other arguments passed on to \code{\link{calc_densities}} and \code{\link{approx_areas}} #' @export #' @example ./examples/sample_dots.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @importFrom raster raster extent rasterize couldBeLonLat crop sample_dots <- function(shp, vars=NULL, convert2density=FALSE, nrow=NA, ncol=NA, N=250000, npop=NA, n=10000, w=NA, shp.id=NULL, var.name="class", var.labels=vars, target="metric", orig=NA, to=NA, randomize=TRUE, output = c("points", "grid"), ...) { args <- list(...) diff --git a/R/set_projection.R b/R/set_projection.R index a19f596..5e9b116 100644 --- a/R/set_projection.R +++ b/R/set_projection.R @@ -23,6 +23,7 @@ #' @importFrom raster projectRaster #' @importFrom rgdal getPROJ4VersionInfo #' @return \code{set_projection} returns a (transformed) shape object with updated projection information. \code{get_projection} returns the \code{PROJ.4} character string of \code{shp}. +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export set_projection <- function(shp, projection=NA, current.projection=NA, overwrite.current.projection=FALSE) { shp.name <- deparse(substitute(shp)) diff --git a/R/simplify_shape.R b/R/simplify_shape.R index 99fd632..0d2bd5a 100644 --- a/R/simplify_shape.R +++ b/R/simplify_shape.R @@ -13,6 +13,7 @@ #' @importFrom rmapshaper ms_simplify #' @importFrom rgeos gIsValid gBuffer #' @return shape in the smae class as \code{shp} +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export simplify_shape <- function(shp, fact = 0.1, keep.units=FALSE, keep.subunits=FALSE, ...) { is_sf <- inherits(shp, c("sf", "sfc")) diff --git a/R/smooth_map.R b/R/smooth_map.R index 472ebd9..d0fb00a 100644 --- a/R/smooth_map.R +++ b/R/smooth_map.R @@ -44,8 +44,8 @@ #' @importFrom utils download.file head setTxtProgressBar tail txtProgressBar #' @import RColorBrewer #' @importFrom classInt classIntervals findCols - #' @example ./examples/smooth_map.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export smooth_map <- function(shp, var=NULL, nrow=NA, ncol=NA, N=250000, unit="km", unit.size=1000, smooth.raster=TRUE, nlevels=5, style = ifelse(is.null(breaks), "pretty", "fixed"), breaks = NULL, bandwidth=NA, threshold=0, cover.type=NA, cover=NULL, cover.threshold=.6, weight=1, extracting.method="full", buffer.width=NA, to.Raster=FALSE) { diff --git a/R/smooth_raster_cover.R b/R/smooth_raster_cover.R index b2a297c..b4a72d1 100644 --- a/R/smooth_raster_cover.R +++ b/R/smooth_raster_cover.R @@ -1,9 +1,9 @@ #' Get a smoothed cover of a raster object -#' +#' #' Get a smoothed cover of a raster object. From all non-missing values of a raster object, a 2D kernal density is applied. The output is a SpatialPolygons object. Used by \code{\link{smooth_map}}. -#' +#' #' For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implemention is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. -#' +#' #' @param shp raster object, from either \code{\link[sp:SpatialGridDataFrame]{SpatialGrid(DataFrame)}} or \code{\link[raster:Raster-class]{Raster}} class. #' @param var name of the variable from which missing values are flagged. If unspecified, the first variable will be taken. #' @param bandwidth single numeric value or vector of two numeric values that specifiy the bandwidth of the kernal density estimator. See details. @@ -11,18 +11,19 @@ #' @param output class of the returned object. One of: \code{\link[sp:SpatialPolygons]{SpatialPolygons}}, \code{\link[sp:SpatialLines]{SpatialLines}}, \code{\link[sp:SpatialGridDataFrame]{SpatialGridDataFrame}}, or \code{\link[raster:Raster-class]{RasterLayer}}. A vector of class names results in a list of output objects. #' @importFrom raster raster extent #' @importMethodsFrom raster as.matrix +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export smooth_raster_cover <- function(shp, var=NULL, bandwidth=NA, threshold=.6, output="SpatialPolygons") { - # convert to rasterlayer + # convert to rasterlayer if (!inherits(shp, "RasterLayer")) { if (missing(var)) var <- names(shp)[1] shp <- raster(shp, layer=var) } ncol <- ncol(shp) nrow <- nrow(shp) - - + + # get shape properties bbx <- bb(shp) prj <- get_projection(shp) @@ -39,40 +40,40 @@ smooth_raster_cover <- function(shp, var=NULL, bandwidth=NA, threshold=.6, outpu m_nna <- as.matrix(raster(shp, layer="N__NA")) m_nna <- matrix(as.integer(m_nna), ncol = ncol(m_nna)) x_nna <- kde2D(m_nna, bandwidth = bandwidth, gridsize=c(ncol, nrow), range.x=list(bbx[1,], bbx[2,])) - + # normalize results x_nna$fhat <- x_nna$fhat * (sum(shp$N__NA[]) / sum(x_nna$fhat, na.rm=TRUE)) - + # append to shape shp$NNA__VALUES <- as.vector(x_nna$fhat[, ncol(x_nna$fhat):1]) - + # find contour lines with one level (at threshold) and convert to spatial polygons - cl_nna <- grDevices::contourLines(x_nna$x1, x_nna$x2, x_nna$fhat, levels=threshold) + cl_nna <- grDevices::contourLines(x_nna$x1, x_nna$x2, x_nna$fhat, levels=threshold) if (!length(cl_nna)) stop("No contour lines are found. Try to decrease the bandwidth.") cl2_nna <- contour_lines_to_SLDF(cl_nna, proj4string = CRS(prj)) - - + + rect <- as(extent(bbx), "SpatialPolygons") rect <- set_projection(rect, current.projection = prj) - + cp_nna <- lines2polygons(ply = rect, lns = cl2_nna, rst = raster(shp, "NNA__VALUES"), lvls = threshold)[2,] - + ### OUTPUTS - + # Lines SL <- as(cl2_nna, "SpatialLines") # SpatialPolygons SP <- as(cp_nna, "SpatialPolygons") - + # SpatialGridDataFrame SG <- as(shp$NNA__VALUES, "SpatialGridDataFrame") SG@data <- data.frame(cover=SG$NNA__VALUES >= threshold, drop=FALSE) # RasterLayer RL <- raster(SG, layer="cover") - + if (length(output)==1) { switch(output, SpatialLines=SL, diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..9a4bab4 --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,27 @@ +## Test environments +* local OS X install, R 3.4.4 +* ubuntu 12.04 (on travis-ci), R 3.4.4 +* win-builder (devel and release) + +## Submission notes + +* The DOI in the CITATION is for a new JSS publication that will be registered after publication on CRAN. + +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. + +## Reverse dependencies + +This is a new release, so there are no reverse dependencies. + +--- + +* I have run R CMD check on the NUMBER downstream dependencies. + (Summary at ...). + +* FAILURE SUMMARY + +* All revdep maintainers were notified of the release on RELEASE DATE. diff --git a/inst/CITATION b/inst/CITATION new file mode 100644 index 0000000..82eecf0 --- /dev/null +++ b/inst/CITATION @@ -0,0 +1,15 @@ +bibentry(bibtype = "Article", + title = "{tmap}: Thematic Maps in {R}", + author = person(given = "Martijn", + family = "Tennekes", + email = "mtennekes@gmail.com"), + journal = "Journal of Statistical Software", + year = "2018", + volume = "84", + number = "6", + pages = "1--39", + doi = "10.18637/jss.v084.i06", + + header = "To cite tmap/tmaptools in publications use:" +) + diff --git a/man/aggregate_map.Rd b/man/aggregate_map.Rd index bb0c4f6..0b2629d 100644 --- a/man/aggregate_map.Rd +++ b/man/aggregate_map.Rd @@ -90,3 +90,6 @@ if (require(tmap)) { agg.fun = list(name="modal"), weights = "AREA")@data } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/append_data.Rd b/man/append_data.Rd index 6efa373..31df412 100644 --- a/man/append_data.Rd +++ b/man/append_data.Rd @@ -72,3 +72,6 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/approx_areas.Rd b/man/approx_areas.Rd index 03fafb5..b65029d 100644 --- a/man/approx_areas.Rd +++ b/man/approx_areas.Rd @@ -74,6 +74,9 @@ if (require(tmap)) { approx_areas(NLD_muni \%>\% set_projection(projection="longlat")) \%>\% summary_areas() } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \code{\link{projection_units}} and \code{\link{approx_distances}} } diff --git a/man/approx_distances.Rd b/man/approx_distances.Rd index eff8ff4..13eeef8 100644 --- a/man/approx_distances.Rd +++ b/man/approx_distances.Rd @@ -50,6 +50,9 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \code{\link{projection_units}} and \code{\link{approx_areas}} } diff --git a/man/bb.Rd b/man/bb.Rd index 734010a..4ed9d86 100644 --- a/man/bb.Rd +++ b/man/bb.Rd @@ -86,6 +86,9 @@ if (require(tmap)) { # shorter alternative: tm_shape(World, bbox="Italy") + tm_polygons() } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \code{\link{geocode_OSM}} } diff --git a/man/calc_densities.Rd b/man/calc_densities.Rd index 2814c8e..caf2513 100644 --- a/man/calc_densities.Rd +++ b/man/calc_densities.Rd @@ -44,4 +44,7 @@ if (require(tmap)) { tm_layout(panel.show = TRUE, panel.labels=c("Men", "Women")) } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \keyword{densities} diff --git a/man/crop_shape.Rd b/man/crop_shape.Rd index d306525..83eb705 100644 --- a/man/crop_shape.Rd +++ b/man/crop_shape.Rd @@ -40,6 +40,9 @@ if (require(tmap)) { tm_legend(frame=TRUE) } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \code{\link{bb}} } diff --git a/man/geocode_OSM.Rd b/man/geocode_OSM.Rd index 91b57f7..a8ac7c8 100644 --- a/man/geocode_OSM.Rd +++ b/man/geocode_OSM.Rd @@ -60,6 +60,9 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \code{\link{rev_geocode_OSM}}, \code{\link{bb}} } diff --git a/man/get_asp_ratio.Rd b/man/get_asp_ratio.Rd index 8a31926..de060f0 100644 --- a/man/get_asp_ratio.Rd +++ b/man/get_asp_ratio.Rd @@ -41,3 +41,6 @@ if (require(tmap)) { get_asp_ratio("Germany") #note: bb("Germany") uses geocode_OSM("Germany") } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/get_brewer_pal.Rd b/man/get_brewer_pal.Rd index 00ba099..3b23aa2 100644 --- a/man/get_brewer_pal.Rd +++ b/man/get_brewer_pal.Rd @@ -41,6 +41,9 @@ get_brewer_pal("RdYlGn", n=11, contrast=c(.4, 1)) get_brewer_pal("Set2", n = 12) get_brewer_pal("Set2", n = 12, stretch = FALSE) } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \code{\link{palette_explorer}} } diff --git a/man/get_proj4.Rd b/man/get_proj4.Rd index 1ea3f92..03e9e96 100644 --- a/man/get_proj4.Rd +++ b/man/get_proj4.Rd @@ -40,6 +40,9 @@ validated PROJ.4 character string, or, if \code{as.CRS=TRUE} a \code{\link[sp:CR \description{ Get full PROJ.4 string from an existing PROJ.4 string, a shortcut, or a \code{\link[sp:CRS]{CRS}} object. } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \url{http://en.wikipedia.org/wiki/List_of_map_projections} for a overview of projections. \url{http://trac.osgeo.org/proj/} for the \code{PROJ.4} project home page. An extensive list of \code{PROJ.4} codes can be created with rgdal's \code{\link[rgdal:make_EPSG]{make_EPSG}}. } diff --git a/man/map_coloring.Rd b/man/map_coloring.Rd index 31679ad..922c58f 100644 --- a/man/map_coloring.Rd +++ b/man/map_coloring.Rd @@ -47,3 +47,6 @@ if (require(tmap)) { } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/palette_explorer.Rd b/man/palette_explorer.Rd index 052e63a..2d1bb87 100644 --- a/man/palette_explorer.Rd +++ b/man/palette_explorer.Rd @@ -18,6 +18,8 @@ if (require(shiny) && require(shinyjs)) { } \references{ \url{http://www.color-blindness.com/types-of-color-blindness/} + +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} } \seealso{ \code{\link{get_brewer_pal}}, \code{\link[dichromat:dichromat]{dichromat}}, \code{\link[RColorBrewer:RColorBrewer]{RColorBrewer}} diff --git a/man/read_GPX.Rd b/man/read_GPX.Rd index a14fb28..df1fee8 100644 --- a/man/read_GPX.Rd +++ b/man/read_GPX.Rd @@ -52,3 +52,6 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/read_osm.Rd b/man/read_osm.Rd index a73618f..196287d 100644 --- a/man/read_osm.Rd +++ b/man/read_osm.Rd @@ -94,3 +94,6 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/read_shape.Rd b/man/read_shape.Rd index 7baa4d6..a108375 100644 --- a/man/read_shape.Rd +++ b/man/read_shape.Rd @@ -26,3 +26,6 @@ This function is a convenient wrapper of rgdal's \code{\link[rgdal:readOGR]{read For the Netherlands: often, the Dutch Rijksdriehoekstelsel (Dutch National Grid) projection is provided in the shape file without proper datum shift parameters to wgs84. This functions automatically adds these parameters. See \url{http://www.qgis.nl/2011/12/05/epsg28992-of-rijksdriehoekstelsel-verschuiving/} (in Dutch) for details. } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/sample_dots.Rd b/man/sample_dots.Rd index aa0354c..0f9fac3 100644 --- a/man/sample_dots.Rd +++ b/man/sample_dots.Rd @@ -61,3 +61,6 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/set_projection.Rd b/man/set_projection.Rd index 6c46407..6799aed 100644 --- a/man/set_projection.Rd +++ b/man/set_projection.Rd @@ -39,3 +39,6 @@ is used to get the projection information. \details{ For raster objects, the projection method is based on the type of data. For numeric layers, the bilinear method is used, and for categorical layers the nearest neighbor. See \code{\link[raster:projectRaster]{projectRaster}} for details. } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/simplify_shape.Rd b/man/simplify_shape.Rd index 08ff3f9..81f62b1 100644 --- a/man/simplify_shape.Rd +++ b/man/simplify_shape.Rd @@ -50,3 +50,6 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/smooth_map.Rd b/man/smooth_map.Rd index 25f20ed..64e9e48 100644 --- a/man/smooth_map.Rd +++ b/man/smooth_map.Rd @@ -177,3 +177,6 @@ if (require(tmap)) { } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/smooth_raster_cover.Rd b/man/smooth_raster_cover.Rd index 004f40a..65eb4af 100644 --- a/man/smooth_raster_cover.Rd +++ b/man/smooth_raster_cover.Rd @@ -24,3 +24,6 @@ Get a smoothed cover of a raster object. From all non-missing values of a raster \details{ For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implemention is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} diff --git a/man/tmaptools-package.Rd b/man/tmaptools-package.Rd index 5578cc4..cae2e2c 100644 --- a/man/tmaptools-package.Rd +++ b/man/tmaptools-package.Rd @@ -76,6 +76,9 @@ This page provides a brief overview of all package functions. } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \author{ Martijn Tennekes \email{mtennekes@gmail.com} } From 25a6330b25470882500317563a8c468f8e57a62a Mon Sep 17 00:00:00 2001 From: mtennekes Date: Tue, 10 Apr 2018 09:10:45 +0200 Subject: [PATCH 5/6] pretty handy, the spell check from devtools::release() --- R/aggregate_map.R | 2 +- R/approx_areas.R | 2 +- R/approx_distances.R | 6 +++--- R/bb.R | 2 +- R/bb_sp.R | 2 +- R/calc_densities.R | 4 ++-- R/geocode_OSM.R | 2 +- R/get_asp_ratio.R | 2 +- R/get_brewer_pal.R | 2 +- R/palette_explorer.R | 2 +- R/projection_units.R | 2 +- R/read_GPX.R | 4 ++-- R/read_osm.R | 2 +- R/sample_dots.R | 6 +++--- R/simplify_shape.R | 2 +- R/smooth_map.R | 4 ++-- R/smooth_raster_cover.R | 4 ++-- R/to_raster.R | 3 ++- man/aggregate_map.Rd | 2 +- man/approx_areas.Rd | 2 +- man/approx_distances.Rd | 6 +++--- man/bb.Rd | 2 +- man/bb_sp.Rd | 2 +- man/calc_densities.Rd | 4 ++-- man/get_asp_ratio.Rd | 2 +- man/get_brewer_pal.Rd | 2 +- man/palette_explorer.Rd | 2 +- man/points_to_raster.Rd | 3 +++ man/poly_to_raster.Rd | 2 +- man/projection_units.Rd | 2 +- man/read_GPX.Rd | 4 ++-- man/read_osm.Rd | 2 +- man/rev_geocode_OSM.Rd | 2 +- man/sample_dots.Rd | 6 +++--- man/simplify_shape.Rd | 2 +- man/smooth_map.Rd | 4 ++-- man/smooth_raster_cover.Rd | 4 ++-- 37 files changed, 56 insertions(+), 52 deletions(-) diff --git a/R/aggregate_map.R b/R/aggregate_map.R index 5676822..14d4a67 100644 --- a/R/aggregate_map.R +++ b/R/aggregate_map.R @@ -37,7 +37,7 @@ weighted.modal <- function(x, w, na.rm=FALSE) { #' Aggregate map #' -#' Aggregate spatial polygons, spatial lines or raster objects. For spatial polygons and lines, the units will be merged with the \code{by} variable. For rasters, the \code{fact} parameter determined how many rasters cells are aggregated both horizontally and vertically. Per data variable, an aggregation formula can be specified, by default mean for numeric and modal for categorical varaibles. +#' Aggregate spatial polygons, spatial lines or raster objects. For spatial polygons and lines, the units will be merged with the \code{by} variable. For rasters, the \code{fact} parameter determined how many rasters cells are aggregated both horizontally and vertically. Per data variable, an aggregation formula can be specified, by default mean for numeric and modal for categorical variables. #' #' This function is similar to \code{\link[raster:aggregate]{aggregate}} from the \code{raster} package. However, the aggregation can be specified in more detail: weights can be used (e.g. polygon area sizes). Also, an aggregation function can be specified per variable or raster layer. It is also possible to specify a general function for numeric data and a function for categorical data. #' diff --git a/R/approx_areas.R b/R/approx_areas.R index 8baabca..c245502 100644 --- a/R/approx_areas.R +++ b/R/approx_areas.R @@ -17,7 +17,7 @@ #' \item{other:}{Predefined values are "km", "m", "mi", and "ft". Other values can be specified as well, in which case \code{to} is required).}} #' These units are the output units. See \code{orig} for the coordinate units used by the shape \code{shp}. #' @param orig original unit, i.e. by which the coordinates are defined. By default, the value is taken from the crs projection string defined in \code{shp}. Not needed for non-projected shapes, since their areas are determined in another way (see details). -#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectameter), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. +#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. #' @param total.area total area size of \code{shp} in number of target units (defined by \code{target}). Useful if the total area of the \code{shp} differs from a reference total area value. For \code{"metric"} and \code{"imperial"} units, please provide the total area in squared kilometers respectively miles. #' @param show.warnings should warnings be shown? #' @return Numeric vector of area sizes. An attribute called unit is added to specify the used target units, which is especially useful when units were set to metric or imperial. diff --git a/R/approx_distances.R b/R/approx_distances.R index 07149d0..30bca3a 100644 --- a/R/approx_distances.R +++ b/R/approx_distances.R @@ -1,13 +1,13 @@ #' Approximate distances #' -#' Approximate distances between two points or across the horizontal and vertical centerlines of a bounding box. +#' Approximate distances between two points or across the horizontal and vertical center lines of a bounding box. #' -#' @param x object that can be coerced to a bounding box with \code{\link{bb}}, or a pair of coordintes (vector of two). In the former case, the distance across the horizontal and vertical centerlines of the bounding box are approximated. In the latter case, \code{y} is also required; the distance between points \code{x} amd \code{y} is approximated. +#' @param x object that can be coerced to a bounding box with \code{\link{bb}}, or a pair of coordinates (vector of two). In the former case, the distance across the horizontal and vertical centerlines of the bounding box are approximated. In the latter case, \code{y} is also required; the distance between points \code{x} and \code{y} is approximated. #' @param y a pair of coordintes, vector of two. Only required when \code{x} is also a pair of coordintes. #' @param projection projection code, needed in case \code{x} is a bounding box or when \code{x} and \code{y} are pairs of coordinates. See \code{\link{get_proj4}} #' @param target target unit, one of: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. #' @param orig original unit, i.e. by which \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. -#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectameter), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. +#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. #' @param show.warnings should warnings be shown? #' @return If \code{y} is specifyed, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance). #' @importFrom geosphere distGeo diff --git a/R/bb.R b/R/bb.R index 0007148..0566426 100644 --- a/R/bb.R +++ b/R/bb.R @@ -11,7 +11,7 @@ #' A new bounding box can be created from scratch as follows: #' \itemize{ #' \item Using the extension factor \code{ext}. -#' \item Setting the center coorinates \code{cx} and \code{cy}, together with the \code{width} and \code{height}. +#' \item Setting the center coordinates \code{cx} and \code{cy}, together with the \code{width} and \code{height}. #' \item Setting the x and y limits \code{xlim} and \code{ylim} #' } #' diff --git a/R/bb_sp.R b/R/bb_sp.R index 68b5389..1c95849 100644 --- a/R/bb_sp.R +++ b/R/bb_sp.R @@ -7,7 +7,7 @@ #' @param steps number of intermediate points along the shortest edge of the bounding box. The number of intermediate points along the longest edge scales with the aspect ratio. These intermediate points are needed if the bounding box is plotted in another projection. #' @param stepsize stepsize in terms of coordinates (usually meters when the shape is projected and degrees of longlat coordinates are used). If specified, it overrules \code{steps} #' @param earth.datum Geodetic datum to determine the earth boundary. By default \code{"WGS84"}, other frequently used datums are \code{"NAD83"} and \code{"NAD27"}. Any other \code{PROJ.4} character string can be used. See \code{\link{get_proj4}}. -#' @param bbx boundig box of the earth in a vector of 4 values: min longitude, max longitude, min latitude, max latitude. By default \code{c(-180, 180, -90, 90)}. If for some \code{projection}, a feasible solution does not exist, it may be wise to choose a smaller bbx, e.g. \code{c(-180, 180, -88, 88)}. However, this is also automatically done with the next argument, \code{buffer}. +#' @param bbx bounding box of the earth in a vector of 4 values: min longitude, max longitude, min latitude, max latitude. By default \code{c(-180, 180, -90, 90)}. If for some \code{projection}, a feasible solution does not exist, it may be wise to choose a smaller bbx, e.g. \code{c(-180, 180, -88, 88)}. However, this is also automatically done with the next argument, \code{buffer}. #' @param buffer In order to determine feasible earth bounding boxes in other projections, a buffer is used to decrease the bounding box by a small margin (default \code{1e-06}). This value is subtracted from each the bounding box coordinates. If it still does not result in a feasible bounding box, this procedure is repeated 5 times, where each time the buffer is multiplied by 10. Set \code{buffer=0} to disable this procedure. #' @param as.sf return object as an \code{sf} object #' @return \code{\link[sp:SpatialPolygons]{SpatialPolygons}} diff --git a/R/calc_densities.R b/R/calc_densities.R index 988045f..eebb58a 100644 --- a/R/calc_densities.R +++ b/R/calc_densities.R @@ -1,9 +1,9 @@ #' Calculate densities #' -#' Transpose quantitative variables to densitiy variables, which are often needed for choroplets. For example, the colors of a population density map should correspond population density counts rather than absolute population numbers. +#' Transpose quantitative variables to density variables, which are often needed for choropleths. For example, the colors of a population density map should correspond population density counts rather than absolute population numbers. #' #' @param shp a shape object, i.e., a \code{\link[sp:SpatialPolygonsDataFrame]{SpatialPolygons(DataFrame)}}, or a \code{sf} object that can be coerced as such. -#' @param var name(s) of a qualtity variable name contained in the \code{shp} data +#' @param var name(s) of a quantitative variable name contained in the \code{shp} data #' @param target the target unit, see \code{\link{approx_areas}}. Density values are calculated in \code{var/target^2}. #' @param orig original units, i.e. by which the coordinates are defined, see \code{\link{approx_areas}}. #' @param to multiplier used as follows: \code{orig * to = target}. See \code{\link{approx_areas}}. diff --git a/R/geocode_OSM.R b/R/geocode_OSM.R index 1a5e071..6514608 100644 --- a/R/geocode_OSM.R +++ b/R/geocode_OSM.R @@ -138,7 +138,7 @@ geocode_OSM <- function(q, projection=NULL, return.first.only=TRUE, details=FALS #' @param server OpenStreetMap Nominatim server name. Could also be a local OSM Nominatim server. #' @export #' @importFrom XML xmlChildren xmlRoot xmlAttrs xmlTreeParse xmlValue -#' @return A data frmame with all atributes that are contained in the search result +#' @return A data frame with all attributes that are contained in the search result #' @example ./examples/rev_geocode_OSM.R #' @seealso \code{\link{geocode_OSM}} rev_geocode_OSM <- function(x, y=NULL, zoom=NULL, projection=NULL, as.data.frame=NA, server="http://nominatim.openstreetmap.org") { diff --git a/R/get_asp_ratio.R b/R/get_asp_ratio.R index bb5b9e8..06568c5 100644 --- a/R/get_asp_ratio.R +++ b/R/get_asp_ratio.R @@ -5,7 +5,7 @@ #' The arguments \code{width}, \code{height}, and \code{res} are passed on to \code{\link[grDevices:png]{png}}. If \code{x} is a tmap object, a temporarily png image is created to calculate the aspect ratio of a tmap object. The default size of this image is 700 by 700 pixels at 100 dpi. #' #' @param x shape object (either \code{\link[sp:Spatial]{Spatial}}, a \code{\link[raster:Raster-class]{Raster}}, or an \code{sf}), a bounding box (that can be coerced by \code{\link{bb}}), or a \code{\link[tmap:tmap-element]{tmap}} object. -#' @param is.projected Logical that determined wether the coordinates of \code{x} are projected (\code{TRUE}) or longitude latitude coordinates (\code{FALSE}). By deafult, it is determined by the coordinates of \code{x}. +#' @param is.projected Logical that determined whether the coordinates of \code{x} are projected (\code{TRUE}) or longitude latitude coordinates (\code{FALSE}). By default, it is determined by the coordinates of \code{x}. #' @param width See details; only applicable if \code{x} is a \code{\link[tmap:tmap-element]{tmap}} object. #' @param height See details; only applicable if \code{x} is a \code{\link[tmap:tmap-element]{tmap}} object. #' @param res See details; only applicable if \code{x} is a \code{\link[tmap:tmap-element]{tmap}} object. diff --git a/R/get_brewer_pal.R b/R/get_brewer_pal.R index 4c7e1b3..f4a57f6 100644 --- a/R/get_brewer_pal.R +++ b/R/get_brewer_pal.R @@ -7,7 +7,7 @@ #' @param palette name of the color brewer palette. Run \code{\link{palette_explorer}} (or \code{\link[RColorBrewer:display.brewer.pal]{display.brewer.pal}}) for options. #' @param n number of colors #' @param contrast a vector of two numbers between 0 and 1 that defines the contrast range of the palette. Applicable to sequential and diverging palettes. For sequential palettes, 0 stands for the leftmost color and 1 the rightmost color. For instance, when \code{contrast=c(.25, .75)}, then the palette ranges from 1/4 to 3/4 of the available color range. For diverging palettes, 0 stands for the middle color and 1 for both outer colors. If only one number is provided, the other number is set to 0. The default value depends on \code{n}. See details. -#' @param stretch logical that determines whether intermediate colors are used for a cateogorical palette when \code{n} is greater than the number of available colors. +#' @param stretch logical that determines whether intermediate colors are used for a categorical palette when \code{n} is greater than the number of available colors. #' @param plot should the palette be plot, or only returned? If \code{TRUE} the palette is silently returned. #' @return vector of color values. It is silently returned when \code{plot=TRUE}. #' @example ./examples/get_brewer_pal.R diff --git a/R/palette_explorer.R b/R/palette_explorer.R index d408a3c..f3f783b 100644 --- a/R/palette_explorer.R +++ b/R/palette_explorer.R @@ -79,7 +79,7 @@ is_light <- function(col) { #' Explore color palettes #' -#' This interactive tool shows all Color Brewer palettes, where the number of colors can be adjusted as well as the constrast range. Categorical (qualitative) palettes can be stretched when the number of colors exceeds the number of palette colors. Output code needed to get the desired color values is generated. Finally, all colors can be tested for color blindness. +#' This interactive tool shows all Color Brewer palettes, where the number of colors can be adjusted as well as the contrast range. Categorical (qualitative) palettes can be stretched when the number of colors exceeds the number of palette colors. Output code needed to get the desired color values is generated. Finally, all colors can be tested for color blindness. #' @export #' @importFrom grDevices col2rgb #' @importFrom dichromat dichromat diff --git a/R/projection_units.R b/R/projection_units.R index 9132870..0cf5357 100644 --- a/R/projection_units.R +++ b/R/projection_units.R @@ -8,7 +8,7 @@ #' @param x A projection (see \code{\link{get_proj4}}) or a shape (from class \code{\link[sp:Spatial]{Spatial}}, \code{\link[raster:Raster-class]{Raster}}), or \code{sf}. #' @param target target unit, one of: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. #' @param orig units by the \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. -#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectameter), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. +#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. #' @param latitude latitude. Needed if the projection coordinates are in latitude longitude units. In that case the \code{orig} will be defined as longitude coordinates at latitude \code{latitude}. #' @param show.warnings should warnings be shown? #' @return list with the following items, \code{orig}, \code{target}, and \code{to} either according the specified argument, or determined determined. The value is \code{NA} for items that cannot be determined. The final item is \code{projected}, which is determined using \code{\link{is_projected}} diff --git a/R/read_GPX.R b/R/read_GPX.R index dc5a976..7444e85 100644 --- a/R/read_GPX.R +++ b/R/read_GPX.R @@ -3,9 +3,9 @@ #' Read a GPX file. By default, it reads all possible GPX layers, and only returns shapes for layers that have any features. #' #' @param file a GPX filename (including directory) -#' @param layers vector of GPX layers. Possible options are \code{"waypoints"}, \code{"tracks"}, \code{"routes"}, \code{"track_points"}, \code{"route_points"}. By dedault, all those layers are read. +#' @param layers vector of GPX layers. Possible options are \code{"waypoints"}, \code{"tracks"}, \code{"routes"}, \code{"track_points"}, \code{"route_points"}. By default, all those layers are read. #' @param as.sf should \code{sf} objects be returned? -#' @return for each defiend layer, a shape is returned (only if the layer has any features). If only one layer is defined, the corresponding shape is returned. If more than one layer is defined, a list of shape objects, one for each layer, is returned. +#' @return for each defined layer, a shape is returned (only if the layer has any features). If only one layer is defined, the corresponding shape is returned. If more than one layer is defined, a list of shape objects, one for each layer, is returned. #' @importFrom rgdal readOGR ogrInfo #' @export #' @example ./examples/read_GPX.R diff --git a/R/read_osm.R b/R/read_osm.R index b9e99ce..a13c084 100644 --- a/R/read_osm.R +++ b/R/read_osm.R @@ -2,7 +2,7 @@ #' #' Read Open Street Map data. Either OSM tiles are read and returned as a spatial raster, or vectorized OSM data are queried and returned as spatial polygons, lines, and/or points. #' -#' @param x object that can be coerced to a bounding box with \code{\link{bb}} (e.g. an existing bounding box or a shape), or an \code{\link[osmar:osmar]{osmar}} object. In the first case, other arguments can be passed on to \code{\link{bb}} (see \code{...}). If an existing bounding box is specified in projected coordinates, plesae specify \code{current.projection}. +#' @param x object that can be coerced to a bounding box with \code{\link{bb}} (e.g. an existing bounding box or a shape), or an \code{\link[osmar:osmar]{osmar}} object. In the first case, other arguments can be passed on to \code{\link{bb}} (see \code{...}). If an existing bounding box is specified in projected coordinates, please specify \code{current.projection}. #' @param raster logical that determines whether a raster or vector shapes are returned. In the latter case, specify the vector selections (see argument \code{...}). By default, \code{raster=TRUE} if no vector selections are made, and \code{raster=FALSE} otherwise. #' @param zoom passed on to \code{\link[OpenStreetMap:openmap]{openmap}}. Only applicable when \code{raster=TRUE}. #' @param type tile provider, by default \code{"osm"}, which corresponds to OpenStreetMap Mapnik. See \code{\link[OpenStreetMap:openmap]{openmap}} for options. Only applicable when \code{raster=TRUE}. diff --git a/R/sample_dots.R b/R/sample_dots.R index 4794a9c..d6c74e5 100644 --- a/R/sample_dots.R +++ b/R/sample_dots.R @@ -3,12 +3,12 @@ #' Sample dots from spatial polygons according to a spatial distribution of a population. The population may consist of classes. The output, a SpatialPointsDataFrame, can be used to create a dot map (see \code{\link[tmap:tm_dots]{tm_dots}}), where the dots are colored according to the classes. #' #' @param shp A shape object, more specifically, a \code{\link[sp:SpatialPolygonsDataFrame]{SpatialPolygonsDataFrame}} or an \code{sf} object that can be coerced as such. -#' @param vars Names of one or more variables that are contained in \code{shp}. If \code{vars} is not provided, the dots are sampled uniformly. If \code{vars} consists of one variable name, the dots are sampled according to the distribution of the corresponding variable. If \code{vars} consist of more than one variable names, then the dots are sampled according to the distributions of those variables. A categorical variable is added that contains the distrubtion classes (see \code{var.name}). +#' @param vars Names of one or more variables that are contained in \code{shp}. If \code{vars} is not provided, the dots are sampled uniformly. If \code{vars} consists of one variable name, the dots are sampled according to the distribution of the corresponding variable. If \code{vars} consist of more than one variable names, then the dots are sampled according to the distributions of those variables. A categorical variable is added that contains the distribution classes (see \code{var.name}). #' @param convert2density Should the variables be converted to density values? Density values are used for the sampling algorithm, so use \code{TRUE} when the values are absolute counts. #' @param nrow Number of grid rows -#' @param ncol Number of grid colums +#' @param ncol Number of grid columns #' @param N Number of grid points -#' @param npop Population total. If \code{NA}, it is recontructed from the data. If density values are specified, the population total is approximated using the polygon areas (see also \code{target}, \code{orig} and \code{to}). +#' @param npop Population total. If \code{NA}, it is reconstructed from the data. If density values are specified, the population total is approximated using the polygon areas (see also \code{target}, \code{orig} and \code{to}). #' @param n Number of sampled dots #' @param w Number of population units per dot. It is the population total divided by \code{n}. If specified, \code{n} is calculated accordingly. #' @param shp.id Name of the variable of \code{shp} that contains the polygon identifying numbers or names. diff --git a/R/simplify_shape.R b/R/simplify_shape.R index 0d2bd5a..57ab846 100644 --- a/R/simplify_shape.R +++ b/R/simplify_shape.R @@ -12,7 +12,7 @@ #' @example ./examples/simplify_shape.R #' @importFrom rmapshaper ms_simplify #' @importFrom rgeos gIsValid gBuffer -#' @return shape in the smae class as \code{shp} +#' @return shape in the same class as \code{shp} #' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @export simplify_shape <- function(shp, fact = 0.1, keep.units=FALSE, keep.subunits=FALSE, ...) { diff --git a/R/smooth_map.R b/R/smooth_map.R index d0fb00a..e2a89ca 100644 --- a/R/smooth_map.R +++ b/R/smooth_map.R @@ -2,7 +2,7 @@ #' #' Create a smooth map from a shape object. A 2D kernel density estimator is applied to the shape, which can be a spatial points, polygons, or raster object. Various format are returned: a smooth raster, contour lines, and polygons. The covered area can be specified, i.e., the area outside of it is extracted from the output. #' -#' For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implemention is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. +#' For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implementation is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. #' #' @param shp shape object of class \code{\link[sp:Spatial]{Spatial}}, \code{\link[raster:Raster-class]{Raster}}, or \code{sf}. Spatial points, polygons, and grids are supported. Spatial lines are not. #' @param var variable name. Not needed for \code{\link[sp:SpatialPoints]{SpatialPoints}}. If missing, the first variable name is taken. For polygons, the variable should contain densities, not absolute numbers. @@ -15,7 +15,7 @@ #' @param nlevels preferred number of levels #' @param style method to cut the color scale: e.g. "fixed", "equal", "pretty", "quantile", or "kmeans". See the details in \code{\link[classInt:classIntervals]{classIntervals}}. #' @param breaks in case \code{style=="fixed"}, breaks should be specified -#' @param bandwidth single numeric value or vector of two numeric values that specifiy the bandwidth of the kernal density estimator. By default, it is 1/50th of the shortest side in units (specified with \code{unit.size}). +#' @param bandwidth single numeric value or vector of two numeric values that specify the bandwidth of the kernal density estimator. By default, it is 1/50th of the shortest side in units (specified with \code{unit.size}). #' @param threshold threshold value when a 2D kernel density is applied. Density values below this threshold will be set to \code{NA}. Only applicable when \code{shp} is a \code{\link[sp:SpatialPoints]{SpatialPoints}} or \code{smooth.raster=TRUE}. #' @param cover.type character value that specifies the type of raster cover, in other words, how the boundaries are specified. Options: \code{"original"} uses the same boundaries as \code{shp} (default for polygons), \code{"smooth"} calculates a smooth boundary based on the 2D kernal density (determined by \code{\link{smooth_raster_cover}}), \code{"rect"} uses the bounding box of \code{shp} as boundaries (default for spatial points and grids). #' @param cover \code{\link[sp:SpatialPolygons]{SpatialPolygons}} shape that determines the covered area in which the contour lines are placed. If specified, \code{cover.type} is ignored. diff --git a/R/smooth_raster_cover.R b/R/smooth_raster_cover.R index b4a72d1..2374f6a 100644 --- a/R/smooth_raster_cover.R +++ b/R/smooth_raster_cover.R @@ -2,11 +2,11 @@ #' #' Get a smoothed cover of a raster object. From all non-missing values of a raster object, a 2D kernal density is applied. The output is a SpatialPolygons object. Used by \code{\link{smooth_map}}. #' -#' For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implemention is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. +#' For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implementation is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. #' #' @param shp raster object, from either \code{\link[sp:SpatialGridDataFrame]{SpatialGrid(DataFrame)}} or \code{\link[raster:Raster-class]{Raster}} class. #' @param var name of the variable from which missing values are flagged. If unspecified, the first variable will be taken. -#' @param bandwidth single numeric value or vector of two numeric values that specifiy the bandwidth of the kernal density estimator. See details. +#' @param bandwidth single numeric value or vector of two numeric values that specify the bandwidth of the kernal density estimator. See details. #' @param threshold numeric value between 0 and 1 that determines which part of the estimated 2D kernal density is returned as cover. #' @param output class of the returned object. One of: \code{\link[sp:SpatialPolygons]{SpatialPolygons}}, \code{\link[sp:SpatialLines]{SpatialLines}}, \code{\link[sp:SpatialGridDataFrame]{SpatialGridDataFrame}}, or \code{\link[raster:Raster-class]{RasterLayer}}. A vector of class names results in a list of output objects. #' @importFrom raster raster extent diff --git a/R/to_raster.R b/R/to_raster.R index dfb242a..de9911f 100644 --- a/R/to_raster.R +++ b/R/to_raster.R @@ -14,6 +14,7 @@ #' @export #' @importFrom raster raster extent rasterize #' @example ./examples/points_to_raster.R +#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} #' @seealso \code{\link{poly_to_raster}} points_to_raster <- function(shp, nrow=NA, ncol=NA, N=250000, by=NULL, to.Raster=FALSE) { if (inherits(shp, c("sf", "sfc"))) shp <- as(shp, "Spatial") @@ -85,7 +86,7 @@ points_to_raster <- function(shp, nrow=NA, ncol=NA, N=250000, by=NULL, to.Raster #' @param nrow number of raster rows. If \code{NA}, it is automatically determined by \code{N} and the aspect ratio of \code{shp}. #' @param ncol number of raster columns. If \code{NA}, it is automatically determined by \code{N} and the aspect ratio of \code{shp}. #' @param N preferred number of raster cells. -#' @param use.cover logical; should the cover method be used? This method determines per raster cell which polygon has the highest cover fraction. This method is better, but very slow, since N times the number of polygons combinations are processed (using the \code{getCover} argument of \code{\link[raster:rasterize]{rasterize}}). By default, when a raster cell is covered by multiple polygons, the last polygon is taken (see \code{fun} argment of \code{\link[raster:rasterize]{rasterize}})) +#' @param use.cover logical; should the cover method be used? This method determines per raster cell which polygon has the highest cover fraction. This method is better, but very slow, since N times the number of polygons combinations are processed (using the \code{getCover} argument of \code{\link[raster:rasterize]{rasterize}}). By default, when a raster cell is covered by multiple polygons, the last polygon is taken (see \code{fun} argument of \code{\link[raster:rasterize]{rasterize}})) #' @param copy.data should the polygon data be appended to the raster? Only recommended when \code{N} is small. #' @param to.Raster logical; should the output be a \code{\link[raster:Raster-class]{Raster}} object (\code{TRUE}), or a \code{\link[sp:SpatialGridDataFrame]{SpatialGridDataFrame}} (\code{FALSE}). If \code{TRUE}, a \code{RasterBrick} is returned when \code{by} is specified, and a \code{RasterLayer} when \code{by} is unspecified. For very large rasters, use \code{TRUE}, since large \code{\link[raster:Raster-class]{Raster}} objects are accessed from disk. #' @param ... arguments passed on to \code{\link[raster:rasterize]{rasterize}} diff --git a/man/aggregate_map.Rd b/man/aggregate_map.Rd index 0b2629d..7f7c268 100644 --- a/man/aggregate_map.Rd +++ b/man/aggregate_map.Rd @@ -40,7 +40,7 @@ These predefined functions can be used: \code{"mean"}, \code{"modal"}, \code{"fi A shape object, in the same format as \code{shp} } \description{ -Aggregate spatial polygons, spatial lines or raster objects. For spatial polygons and lines, the units will be merged with the \code{by} variable. For rasters, the \code{fact} parameter determined how many rasters cells are aggregated both horizontally and vertically. Per data variable, an aggregation formula can be specified, by default mean for numeric and modal for categorical varaibles. +Aggregate spatial polygons, spatial lines or raster objects. For spatial polygons and lines, the units will be merged with the \code{by} variable. For rasters, the \code{fact} parameter determined how many rasters cells are aggregated both horizontally and vertically. Per data variable, an aggregation formula can be specified, by default mean for numeric and modal for categorical variables. } \details{ This function is similar to \code{\link[raster:aggregate]{aggregate}} from the \code{raster} package. However, the aggregation can be specified in more detail: weights can be used (e.g. polygon area sizes). Also, an aggregation function can be specified per variable or raster layer. It is also possible to specify a general function for numeric data and a function for categorical data. diff --git a/man/approx_areas.Rd b/man/approx_areas.Rd index b65029d..b8762ae 100644 --- a/man/approx_areas.Rd +++ b/man/approx_areas.Rd @@ -22,7 +22,7 @@ These units are the output units. See \code{orig} for the coordinate units used \item{orig}{original unit, i.e. by which the coordinates are defined. By default, the value is taken from the crs projection string defined in \code{shp}. Not needed for non-projected shapes, since their areas are determined in another way (see details).} -\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectameter), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} +\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} \item{total.area}{total area size of \code{shp} in number of target units (defined by \code{target}). Useful if the total area of the \code{shp} differs from a reference total area value. For \code{"metric"} and \code{"imperial"} units, please provide the total area in squared kilometers respectively miles.} diff --git a/man/approx_distances.Rd b/man/approx_distances.Rd index 13eeef8..bc5413c 100644 --- a/man/approx_distances.Rd +++ b/man/approx_distances.Rd @@ -8,7 +8,7 @@ approx_distances(x, y = NULL, projection = NULL, target = "metric", orig = NA, to = NA, show.warnings = TRUE) } \arguments{ -\item{x}{object that can be coerced to a bounding box with \code{\link{bb}}, or a pair of coordintes (vector of two). In the former case, the distance across the horizontal and vertical centerlines of the bounding box are approximated. In the latter case, \code{y} is also required; the distance between points \code{x} amd \code{y} is approximated.} +\item{x}{object that can be coerced to a bounding box with \code{\link{bb}}, or a pair of coordinates (vector of two). In the former case, the distance across the horizontal and vertical centerlines of the bounding box are approximated. In the latter case, \code{y} is also required; the distance between points \code{x} and \code{y} is approximated.} \item{y}{a pair of coordintes, vector of two. Only required when \code{x} is also a pair of coordintes.} @@ -18,7 +18,7 @@ approx_distances(x, y = NULL, projection = NULL, target = "metric", \item{orig}{original unit, i.e. by which \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}.} -\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectameter), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} +\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} \item{show.warnings}{should warnings be shown?} } @@ -26,7 +26,7 @@ approx_distances(x, y = NULL, projection = NULL, target = "metric", If \code{y} is specifyed, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance). } \description{ -Approximate distances between two points or across the horizontal and vertical centerlines of a bounding box. +Approximate distances between two points or across the horizontal and vertical center lines of a bounding box. } \examples{ \dontrun{ diff --git a/man/bb.Rd b/man/bb.Rd index 4ed9d86..c669b14 100644 --- a/man/bb.Rd +++ b/man/bb.Rd @@ -54,7 +54,7 @@ An existing bounding box (defined by \code{x}) can be modified as follows: A new bounding box can be created from scratch as follows: \itemize{ \item Using the extension factor \code{ext}. -\item Setting the center coorinates \code{cx} and \code{cy}, together with the \code{width} and \code{height}. +\item Setting the center coordinates \code{cx} and \code{cy}, together with the \code{width} and \code{height}. \item Setting the x and y limits \code{xlim} and \code{ylim} } } diff --git a/man/bb_sp.Rd b/man/bb_sp.Rd index 8be5e29..0dd8a10 100644 --- a/man/bb_sp.Rd +++ b/man/bb_sp.Rd @@ -23,7 +23,7 @@ bb_earth(projection = NULL, stepsize = 1, earth.datum = "WGS84", \item{earth.datum}{Geodetic datum to determine the earth boundary. By default \code{"WGS84"}, other frequently used datums are \code{"NAD83"} and \code{"NAD27"}. Any other \code{PROJ.4} character string can be used. See \code{\link{get_proj4}}.} -\item{bbx}{boundig box of the earth in a vector of 4 values: min longitude, max longitude, min latitude, max latitude. By default \code{c(-180, 180, -90, 90)}. If for some \code{projection}, a feasible solution does not exist, it may be wise to choose a smaller bbx, e.g. \code{c(-180, 180, -88, 88)}. However, this is also automatically done with the next argument, \code{buffer}.} +\item{bbx}{bounding box of the earth in a vector of 4 values: min longitude, max longitude, min latitude, max latitude. By default \code{c(-180, 180, -90, 90)}. If for some \code{projection}, a feasible solution does not exist, it may be wise to choose a smaller bbx, e.g. \code{c(-180, 180, -88, 88)}. However, this is also automatically done with the next argument, \code{buffer}.} \item{buffer}{In order to determine feasible earth bounding boxes in other projections, a buffer is used to decrease the bounding box by a small margin (default \code{1e-06}). This value is subtracted from each the bounding box coordinates. If it still does not result in a feasible bounding box, this procedure is repeated 5 times, where each time the buffer is multiplied by 10. Set \code{buffer=0} to disable this procedure.} } diff --git a/man/calc_densities.Rd b/man/calc_densities.Rd index caf2513..8510e84 100644 --- a/man/calc_densities.Rd +++ b/man/calc_densities.Rd @@ -10,7 +10,7 @@ calc_densities(shp, var, target = "metric", orig = NA, to = NA, \arguments{ \item{shp}{a shape object, i.e., a \code{\link[sp:SpatialPolygonsDataFrame]{SpatialPolygons(DataFrame)}}, or a \code{sf} object that can be coerced as such.} -\item{var}{name(s) of a qualtity variable name contained in the \code{shp} data} +\item{var}{name(s) of a quantitative variable name contained in the \code{shp} data} \item{target}{the target unit, see \code{\link{approx_areas}}. Density values are calculated in \code{var/target^2}.} @@ -28,7 +28,7 @@ calc_densities(shp, var, target = "metric", orig = NA, to = NA, Vector or data.frame (depending on whether \code{length(var)==1} with density values. This can be appended directly to the shape file with \code{\link{append_data}} with \code{fixed.order=TRUE}. } \description{ -Transpose quantitative variables to densitiy variables, which are often needed for choroplets. For example, the colors of a population density map should correspond population density counts rather than absolute population numbers. +Transpose quantitative variables to density variables, which are often needed for choropleths. For example, the colors of a population density map should correspond population density counts rather than absolute population numbers. } \examples{ if (require(tmap)) { diff --git a/man/get_asp_ratio.Rd b/man/get_asp_ratio.Rd index de060f0..6c22613 100644 --- a/man/get_asp_ratio.Rd +++ b/man/get_asp_ratio.Rd @@ -10,7 +10,7 @@ get_asp_ratio(x, is.projected = NA, width = 700, height = 700, \arguments{ \item{x}{shape object (either \code{\link[sp:Spatial]{Spatial}}, a \code{\link[raster:Raster-class]{Raster}}, or an \code{sf}), a bounding box (that can be coerced by \code{\link{bb}}), or a \code{\link[tmap:tmap-element]{tmap}} object.} -\item{is.projected}{Logical that determined wether the coordinates of \code{x} are projected (\code{TRUE}) or longitude latitude coordinates (\code{FALSE}). By deafult, it is determined by the coordinates of \code{x}.} +\item{is.projected}{Logical that determined whether the coordinates of \code{x} are projected (\code{TRUE}) or longitude latitude coordinates (\code{FALSE}). By default, it is determined by the coordinates of \code{x}.} \item{width}{See details; only applicable if \code{x} is a \code{\link[tmap:tmap-element]{tmap}} object.} diff --git a/man/get_brewer_pal.Rd b/man/get_brewer_pal.Rd index 3b23aa2..5d77518 100644 --- a/man/get_brewer_pal.Rd +++ b/man/get_brewer_pal.Rd @@ -14,7 +14,7 @@ get_brewer_pal(palette, n = 5, contrast = NA, stretch = TRUE, \item{contrast}{a vector of two numbers between 0 and 1 that defines the contrast range of the palette. Applicable to sequential and diverging palettes. For sequential palettes, 0 stands for the leftmost color and 1 the rightmost color. For instance, when \code{contrast=c(.25, .75)}, then the palette ranges from 1/4 to 3/4 of the available color range. For diverging palettes, 0 stands for the middle color and 1 for both outer colors. If only one number is provided, the other number is set to 0. The default value depends on \code{n}. See details.} -\item{stretch}{logical that determines whether intermediate colors are used for a cateogorical palette when \code{n} is greater than the number of available colors.} +\item{stretch}{logical that determines whether intermediate colors are used for a categorical palette when \code{n} is greater than the number of available colors.} \item{plot}{should the palette be plot, or only returned? If \code{TRUE} the palette is silently returned.} } diff --git a/man/palette_explorer.Rd b/man/palette_explorer.Rd index 2d1bb87..c441223 100644 --- a/man/palette_explorer.Rd +++ b/man/palette_explorer.Rd @@ -7,7 +7,7 @@ palette_explorer() } \description{ -This interactive tool shows all Color Brewer palettes, where the number of colors can be adjusted as well as the constrast range. Categorical (qualitative) palettes can be stretched when the number of colors exceeds the number of palette colors. Output code needed to get the desired color values is generated. Finally, all colors can be tested for color blindness. +This interactive tool shows all Color Brewer palettes, where the number of colors can be adjusted as well as the contrast range. Categorical (qualitative) palettes can be stretched when the number of colors exceeds the number of palette colors. Output code needed to get the desired color values is generated. Finally, all colors can be tested for color blindness. } \examples{ \dontrun{ diff --git a/man/points_to_raster.Rd b/man/points_to_raster.Rd index 7d92799..81d31d7 100644 --- a/man/points_to_raster.Rd +++ b/man/points_to_raster.Rd @@ -53,6 +53,9 @@ if (require(tmap)) { } } } +\references{ +Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} +} \seealso{ \code{\link{poly_to_raster}} } diff --git a/man/poly_to_raster.Rd b/man/poly_to_raster.Rd index 9e8baf2..3812b32 100644 --- a/man/poly_to_raster.Rd +++ b/man/poly_to_raster.Rd @@ -18,7 +18,7 @@ poly_to_raster(shp, r = NULL, nrow = NA, ncol = NA, N = 250000, \item{N}{preferred number of raster cells.} -\item{use.cover}{logical; should the cover method be used? This method determines per raster cell which polygon has the highest cover fraction. This method is better, but very slow, since N times the number of polygons combinations are processed (using the \code{getCover} argument of \code{\link[raster:rasterize]{rasterize}}). By default, when a raster cell is covered by multiple polygons, the last polygon is taken (see \code{fun} argment of \code{\link[raster:rasterize]{rasterize}}))} +\item{use.cover}{logical; should the cover method be used? This method determines per raster cell which polygon has the highest cover fraction. This method is better, but very slow, since N times the number of polygons combinations are processed (using the \code{getCover} argument of \code{\link[raster:rasterize]{rasterize}}). By default, when a raster cell is covered by multiple polygons, the last polygon is taken (see \code{fun} argument of \code{\link[raster:rasterize]{rasterize}}))} \item{copy.data}{should the polygon data be appended to the raster? Only recommended when \code{N} is small.} diff --git a/man/projection_units.Rd b/man/projection_units.Rd index 9eaee34..62e6ae4 100644 --- a/man/projection_units.Rd +++ b/man/projection_units.Rd @@ -14,7 +14,7 @@ projection_units(x = NA, target = "m", orig = NA, to = NA, \item{orig}{units by the \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}.} -\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectameter), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} +\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} \item{latitude}{latitude. Needed if the projection coordinates are in latitude longitude units. In that case the \code{orig} will be defined as longitude coordinates at latitude \code{latitude}.} diff --git a/man/read_GPX.Rd b/man/read_GPX.Rd index df1fee8..012ed13 100644 --- a/man/read_GPX.Rd +++ b/man/read_GPX.Rd @@ -10,12 +10,12 @@ read_GPX(file, layers = c("waypoints", "tracks", "routes", "track_points", \arguments{ \item{file}{a GPX filename (including directory)} -\item{layers}{vector of GPX layers. Possible options are \code{"waypoints"}, \code{"tracks"}, \code{"routes"}, \code{"track_points"}, \code{"route_points"}. By dedault, all those layers are read.} +\item{layers}{vector of GPX layers. Possible options are \code{"waypoints"}, \code{"tracks"}, \code{"routes"}, \code{"track_points"}, \code{"route_points"}. By default, all those layers are read.} \item{as.sf}{should \code{sf} objects be returned?} } \value{ -for each defiend layer, a shape is returned (only if the layer has any features). If only one layer is defined, the corresponding shape is returned. If more than one layer is defined, a list of shape objects, one for each layer, is returned. +for each defined layer, a shape is returned (only if the layer has any features). If only one layer is defined, the corresponding shape is returned. If more than one layer is defined, a list of shape objects, one for each layer, is returned. } \description{ Read a GPX file. By default, it reads all possible GPX layers, and only returns shapes for layers that have any features. diff --git a/man/read_osm.Rd b/man/read_osm.Rd index 196287d..4ae587c 100644 --- a/man/read_osm.Rd +++ b/man/read_osm.Rd @@ -17,7 +17,7 @@ osm_line(query) osm_point(query) } \arguments{ -\item{x}{object that can be coerced to a bounding box with \code{\link{bb}} (e.g. an existing bounding box or a shape), or an \code{\link[osmar:osmar]{osmar}} object. In the first case, other arguments can be passed on to \code{\link{bb}} (see \code{...}). If an existing bounding box is specified in projected coordinates, plesae specify \code{current.projection}.} +\item{x}{object that can be coerced to a bounding box with \code{\link{bb}} (e.g. an existing bounding box or a shape), or an \code{\link[osmar:osmar]{osmar}} object. In the first case, other arguments can be passed on to \code{\link{bb}} (see \code{...}). If an existing bounding box is specified in projected coordinates, please specify \code{current.projection}.} \item{raster}{logical that determines whether a raster or vector shapes are returned. In the latter case, specify the vector selections (see argument \code{...}). By default, \code{raster=TRUE} if no vector selections are made, and \code{raster=FALSE} otherwise.} diff --git a/man/rev_geocode_OSM.Rd b/man/rev_geocode_OSM.Rd index 7d89303..b313924 100644 --- a/man/rev_geocode_OSM.Rd +++ b/man/rev_geocode_OSM.Rd @@ -21,7 +21,7 @@ rev_geocode_OSM(x, y = NULL, zoom = NULL, projection = NULL, \item{server}{OpenStreetMap Nominatim server name. Could also be a local OSM Nominatim server.} } \value{ -A data frmame with all atributes that are contained in the search result +A data frame with all attributes that are contained in the search result } \description{ Reverse geocodes a location (based on spatial coordinates) to an address. It uses OpenStreetMap Nominatim. For processing large amount of queries, please read the usage policy (\url{http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy}). diff --git a/man/sample_dots.Rd b/man/sample_dots.Rd index 0f9fac3..cbe5f0f 100644 --- a/man/sample_dots.Rd +++ b/man/sample_dots.Rd @@ -13,17 +13,17 @@ sample_dots(shp, vars = NULL, convert2density = FALSE, nrow = NA, \arguments{ \item{shp}{A shape object, more specifically, a \code{\link[sp:SpatialPolygonsDataFrame]{SpatialPolygonsDataFrame}} or an \code{sf} object that can be coerced as such.} -\item{vars}{Names of one or more variables that are contained in \code{shp}. If \code{vars} is not provided, the dots are sampled uniformly. If \code{vars} consists of one variable name, the dots are sampled according to the distribution of the corresponding variable. If \code{vars} consist of more than one variable names, then the dots are sampled according to the distributions of those variables. A categorical variable is added that contains the distrubtion classes (see \code{var.name}).} +\item{vars}{Names of one or more variables that are contained in \code{shp}. If \code{vars} is not provided, the dots are sampled uniformly. If \code{vars} consists of one variable name, the dots are sampled according to the distribution of the corresponding variable. If \code{vars} consist of more than one variable names, then the dots are sampled according to the distributions of those variables. A categorical variable is added that contains the distribution classes (see \code{var.name}).} \item{convert2density}{Should the variables be converted to density values? Density values are used for the sampling algorithm, so use \code{TRUE} when the values are absolute counts.} \item{nrow}{Number of grid rows} -\item{ncol}{Number of grid colums} +\item{ncol}{Number of grid columns} \item{N}{Number of grid points} -\item{npop}{Population total. If \code{NA}, it is recontructed from the data. If density values are specified, the population total is approximated using the polygon areas (see also \code{target}, \code{orig} and \code{to}).} +\item{npop}{Population total. If \code{NA}, it is reconstructed from the data. If density values are specified, the population total is approximated using the polygon areas (see also \code{target}, \code{orig} and \code{to}).} \item{n}{Number of sampled dots} diff --git a/man/simplify_shape.Rd b/man/simplify_shape.Rd index 81f62b1..e291ba9 100644 --- a/man/simplify_shape.Rd +++ b/man/simplify_shape.Rd @@ -19,7 +19,7 @@ simplify_shape(shp, fact = 0.1, keep.units = FALSE, keep.subunits = FALSE, \item{...}{other arguments passed on to the underlying function \code{\link[rmapshaper:ms_simplify]{ms_simplify}} (except for the arguments \code{input}, \code{keep}, \code{keep_shapes} and \code{explode})} } \value{ -shape in the smae class as \code{shp} +shape in the same class as \code{shp} } \description{ Simplify a shape consisting of polygons or lines. This can be useful for shapes that are too detailed for visualization, especially along natural borders such as coastlines and rivers. The number of coordinates is reduced. diff --git a/man/smooth_map.Rd b/man/smooth_map.Rd index 64e9e48..3ebd4ac 100644 --- a/man/smooth_map.Rd +++ b/man/smooth_map.Rd @@ -34,7 +34,7 @@ smooth_map(shp, var = NULL, nrow = NA, ncol = NA, N = 250000, \item{breaks}{in case \code{style=="fixed"}, breaks should be specified} -\item{bandwidth}{single numeric value or vector of two numeric values that specifiy the bandwidth of the kernal density estimator. By default, it is 1/50th of the shortest side in units (specified with \code{unit.size}).} +\item{bandwidth}{single numeric value or vector of two numeric values that specify the bandwidth of the kernal density estimator. By default, it is 1/50th of the shortest side in units (specified with \code{unit.size}).} \item{threshold}{threshold value when a 2D kernel density is applied. Density values below this threshold will be set to \code{NA}. Only applicable when \code{shp} is a \code{\link[sp:SpatialPoints]{SpatialPoints}} or \code{smooth.raster=TRUE}.} @@ -67,7 +67,7 @@ List with the following items: Create a smooth map from a shape object. A 2D kernel density estimator is applied to the shape, which can be a spatial points, polygons, or raster object. Various format are returned: a smooth raster, contour lines, and polygons. The covered area can be specified, i.e., the area outside of it is extracted from the output. } \details{ -For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implemention is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. +For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implementation is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. } \examples{ \dontrun{ diff --git a/man/smooth_raster_cover.Rd b/man/smooth_raster_cover.Rd index 65eb4af..db9e940 100644 --- a/man/smooth_raster_cover.Rd +++ b/man/smooth_raster_cover.Rd @@ -12,7 +12,7 @@ smooth_raster_cover(shp, var = NULL, bandwidth = NA, threshold = 0.6, \item{var}{name of the variable from which missing values are flagged. If unspecified, the first variable will be taken.} -\item{bandwidth}{single numeric value or vector of two numeric values that specifiy the bandwidth of the kernal density estimator. See details.} +\item{bandwidth}{single numeric value or vector of two numeric values that specify the bandwidth of the kernal density estimator. See details.} \item{threshold}{numeric value between 0 and 1 that determines which part of the estimated 2D kernal density is returned as cover.} @@ -22,7 +22,7 @@ smooth_raster_cover(shp, var = NULL, bandwidth = NA, threshold = 0.6, Get a smoothed cover of a raster object. From all non-missing values of a raster object, a 2D kernal density is applied. The output is a SpatialPolygons object. Used by \code{\link{smooth_map}}. } \details{ -For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implemention is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. +For the estimation of the 2D kernal density, code is borrowed from \code{\link[KernSmooth:bkde2D]{bkde2D}}. This implementation is slightly different: \code{\link[KernSmooth:bkde2D]{bkde2D}} takes point coordinates and applies linear binning, whereas in this function, the data is already binned, with values 1 if the values of \code{var} are not missing and 0 if values of \code{var} are missing. } \references{ Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI} From 560389097cc4c83ee16e8766122ba244aa8ed88e Mon Sep 17 00:00:00 2001 From: mtennekes Date: Tue, 10 Apr 2018 16:03:41 +0200 Subject: [PATCH 6/6] CRAN VERSION 1.2-4 --- R/approx_areas.R | 2 +- R/approx_distances.R | 4 ++-- R/projection_units.R | 2 +- cran-comments.md | 17 ++++------------- man/approx_areas.Rd | 2 +- man/approx_distances.Rd | 4 ++-- man/projection_units.Rd | 2 +- 7 files changed, 12 insertions(+), 21 deletions(-) diff --git a/R/approx_areas.R b/R/approx_areas.R index c245502..8fb3d0f 100644 --- a/R/approx_areas.R +++ b/R/approx_areas.R @@ -17,7 +17,7 @@ #' \item{other:}{Predefined values are "km", "m", "mi", and "ft". Other values can be specified as well, in which case \code{to} is required).}} #' These units are the output units. See \code{orig} for the coordinate units used by the shape \code{shp}. #' @param orig original unit, i.e. by which the coordinates are defined. By default, the value is taken from the crs projection string defined in \code{shp}. Not needed for non-projected shapes, since their areas are determined in another way (see details). -#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. +#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectometer equals 100 meters. #' @param total.area total area size of \code{shp} in number of target units (defined by \code{target}). Useful if the total area of the \code{shp} differs from a reference total area value. For \code{"metric"} and \code{"imperial"} units, please provide the total area in squared kilometers respectively miles. #' @param show.warnings should warnings be shown? #' @return Numeric vector of area sizes. An attribute called unit is added to specify the used target units, which is especially useful when units were set to metric or imperial. diff --git a/R/approx_distances.R b/R/approx_distances.R index 30bca3a..0a46834 100644 --- a/R/approx_distances.R +++ b/R/approx_distances.R @@ -7,9 +7,9 @@ #' @param projection projection code, needed in case \code{x} is a bounding box or when \code{x} and \code{y} are pairs of coordinates. See \code{\link{get_proj4}} #' @param target target unit, one of: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. #' @param orig original unit, i.e. by which \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. -#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. +#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectometer equals 100 meters. #' @param show.warnings should warnings be shown? -#' @return If \code{y} is specifyed, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance). +#' @return If \code{y} is specified, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance). #' @importFrom geosphere distGeo #' @example ./examples/approx_distances.R #' @seealso \code{\link{projection_units}} and \code{\link{approx_areas}} diff --git a/R/projection_units.R b/R/projection_units.R index 0cf5357..390ce84 100644 --- a/R/projection_units.R +++ b/R/projection_units.R @@ -8,7 +8,7 @@ #' @param x A projection (see \code{\link{get_proj4}}) or a shape (from class \code{\link[sp:Spatial]{Spatial}}, \code{\link[raster:Raster-class]{Raster}}), or \code{sf}. #' @param target target unit, one of: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. #' @param orig units by the \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}. -#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters. +#' @param to multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectometer equals 100 meters. #' @param latitude latitude. Needed if the projection coordinates are in latitude longitude units. In that case the \code{orig} will be defined as longitude coordinates at latitude \code{latitude}. #' @param show.warnings should warnings be shown? #' @return list with the following items, \code{orig}, \code{target}, and \code{to} either according the specified argument, or determined determined. The value is \code{NA} for items that cannot be determined. The final item is \code{projected}, which is determined using \code{\link{is_projected}} diff --git a/cran-comments.md b/cran-comments.md index 9a4bab4..fd5d06a 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,9 +1,9 @@ ## Test environments -* local OS X install, R 3.4.4 * ubuntu 12.04 (on travis-ci), R 3.4.4 +* ubuntu 17.10, R 3.4.4 * win-builder (devel and release) -## Submission notes +## Submission note * The DOI in the CITATION is for a new JSS publication that will be registered after publication on CRAN. @@ -11,17 +11,8 @@ 0 errors | 0 warnings | 1 note -* This is a new release. +* See submission note above ## Reverse dependencies -This is a new release, so there are no reverse dependencies. - ---- - -* I have run R CMD check on the NUMBER downstream dependencies. - (Summary at ...). - -* FAILURE SUMMARY - -* All revdep maintainers were notified of the release on RELEASE DATE. +The only reverse dependency is tmap, which runs with tmaptools 1.2-4. diff --git a/man/approx_areas.Rd b/man/approx_areas.Rd index b8762ae..aba7019 100644 --- a/man/approx_areas.Rd +++ b/man/approx_areas.Rd @@ -22,7 +22,7 @@ These units are the output units. See \code{orig} for the coordinate units used \item{orig}{original unit, i.e. by which the coordinates are defined. By default, the value is taken from the crs projection string defined in \code{shp}. Not needed for non-projected shapes, since their areas are determined in another way (see details).} -\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} +\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectometer equals 100 meters.} \item{total.area}{total area size of \code{shp} in number of target units (defined by \code{target}). Useful if the total area of the \code{shp} differs from a reference total area value. For \code{"metric"} and \code{"imperial"} units, please provide the total area in squared kilometers respectively miles.} diff --git a/man/approx_distances.Rd b/man/approx_distances.Rd index bc5413c..75d2289 100644 --- a/man/approx_distances.Rd +++ b/man/approx_distances.Rd @@ -18,12 +18,12 @@ approx_distances(x, y = NULL, projection = NULL, target = "metric", \item{orig}{original unit, i.e. by which \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}.} -\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} +\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectometer equals 100 meters.} \item{show.warnings}{should warnings be shown?} } \value{ -If \code{y} is specifyed, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance). +If \code{y} is specified, a list of two: unit and dist. Else, a list of three: unit, hdist (horizontal distance) and vdist (vertical distance). } \description{ Approximate distances between two points or across the horizontal and vertical center lines of a bounding box. diff --git a/man/projection_units.Rd b/man/projection_units.Rd index 62e6ae4..f46bc5c 100644 --- a/man/projection_units.Rd +++ b/man/projection_units.Rd @@ -14,7 +14,7 @@ projection_units(x = NA, target = "m", orig = NA, to = NA, \item{orig}{units by the \code{x} is defined. Only needed if this information is missing from \code{x} and \code{x} is projected. Options: \code{"m"}, \code{"km"}, \code{"mi"}, and \code{"ft"}.} -\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectameter equals 100 meters.} +\item{to}{multiplier used as follows: \code{orig * to = target}. Only needed when \code{orig} or \code{target} is unknown. For instance, if \code{target} is set to \code{"hm"} (hectometer), and \code{orig} is \code{"m"}, then \code{to} should be 100, meaning 1 hectometer equals 100 meters.} \item{latitude}{latitude. Needed if the projection coordinates are in latitude longitude units. In that case the \code{orig} will be defined as longitude coordinates at latitude \code{latitude}.}