-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from r-spatialecology/main
📝 Update DOCS for CRAN
- Loading branch information
Showing
34 changed files
with
370 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
Type: Package | ||
Package: onpoint | ||
Title: Helper Functions for Point Pattern Analysis | ||
Version: 1.0 | ||
Version: 1.0.1 | ||
Authors@R: | ||
person("Maximillian H.K.", "Hesselbarth", | ||
email = "[email protected]", | ||
role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-1125-9918")) | ||
Maintainer: Maximillian H.K. Hesselbarth <[email protected]> | ||
Description: | ||
Growing collection of small helper functions for point pattern analysis. Most functions | ||
are designed to work with the 'spatstat' package. | ||
Growing collection of helper functions for point pattern analysis. Most functions | ||
are designed to work with the 'spatstat' (<http://spatstat.org>) package. The focus of | ||
most functions are either null models or summary functions for spatial point patterns. | ||
For a detailed description of all null models and summary functions, see | ||
Wiegand and Moloney (2014, ISBN:9781420082548). | ||
URL: https://r-spatialecology.github.io/onpoint/ | ||
BugReports: https://github.com/r-spatialecology/onpoint/issues | ||
License: GPL (>= 3) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,42 @@ | ||
#' calc_area | ||
#' | ||
#' @description Calculate area of polygon | ||
#' | ||
#' @param x matrix | ||
#' | ||
#' @details | ||
#' Calculate area of polygon | ||
#' | ||
#' @aliases calc_area | ||
#' @rdname calc_area | ||
#' | ||
#' @keywords internal | ||
#' | ||
#' @export | ||
calc_area <- function(x){ | ||
|
||
# check if polygon is closed | ||
if (x[1, 1] != x[nrow(x), 1] || x[1, 2] != x[nrow(x), 2]) { | ||
# close the polygon | ||
x <- rbind(x, x[1, ]) | ||
} | ||
|
||
# get number of rows | ||
nrow_x <- nrow(x) | ||
|
||
# get coordinates | ||
x_coord <- x[ ,1] | ||
y_coord <- x[, 2] | ||
|
||
area <- abs(sum((x_coord[2:nrow_x] - x_coord[1:nrow_x - 1]) * | ||
(y_coord[2:nrow_x] + y_coord[1:nrow_x - 1])) / 2) | ||
|
||
return(area) | ||
} | ||
#' calc_area | ||
#' | ||
#' @description Calculate area of polygon | ||
#' | ||
#' @param x matrix with x,y coordinates. | ||
#' | ||
#' @details | ||
#' Calculate area of polygon in input units. If the polygon is not closed, the first | ||
#' coordinate is used as last coordinate to close it. | ||
#' | ||
#' @return numeric | ||
#' | ||
#' @examples | ||
#' dat <- matrix(data = c(0, 0, 0, 10, 10, 10, 10, 0), ncol = 2, byrow = TRUE) | ||
#' calc_area(x = dat) | ||
#' | ||
#' @aliases calc_area | ||
#' @rdname calc_area | ||
#' | ||
#' @keywords internal | ||
#' | ||
#' @export | ||
calc_area <- function(x){ | ||
|
||
# check if polygon is closed | ||
if (x[1, 1] != x[nrow(x), 1] || x[1, 2] != x[nrow(x), 2]) { | ||
# close the polygon | ||
x <- rbind(x, x[1, ]) | ||
} | ||
|
||
# get number of rows | ||
nrow_x <- nrow(x) | ||
|
||
# get coordinates | ||
x_coord <- x[ ,1] | ||
y_coord <- x[, 2] | ||
|
||
area <- abs(sum((x_coord[2:nrow_x] - x_coord[1:nrow_x - 1]) * | ||
(y_coord[2:nrow_x] + y_coord[1:nrow_x - 1])) / 2) | ||
|
||
return(area) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.