Skip to content

Commit

Permalink
Merge pull request #31 from ropensci/fix-crs
Browse files Browse the repository at this point in the history
Update projection following GDAL, PROJ
  • Loading branch information
robitalec committed Jul 2, 2020
2 parents 560bb7a + ddd3bf0 commit 2a5ce33
Show file tree
Hide file tree
Showing 22 changed files with 190 additions and 181 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Suggests:
rmarkdown,
asnipe
SystemRequirements: GEOS (>= 3.2.0)
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
BugReports: https://github.com/ropensci/spatsoc/issues
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# v 0.1.14
* updated tests, man and vignettes following new handling of projections in sp ([PR 31](https://github.com/ropensci/spatsoc/pull/31), [R spatial information](https://www.r-spatial.org/r/2020/03/17/wkt.html))
* clarified explicit drop of NAs in dyadID in edge list vignette

# v 0.1.13 (2020-03-25)
Expand Down
11 changes: 4 additions & 7 deletions R/build_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
#'
#' \code{build_lines} creates a \code{SpatialLines} object from a \code{data.table}. The function accepts a \code{data.table} with relocation data, individual identifiers a sorting column and a \code{projection}. The relocation data is transformed into \code{SpatialLines} for each individual and optionally, each \code{splitBy}. Relocation data should be in two columns representing the X and Y coordinates.
#'
#' The \code{DT} must be a \code{data.table}. If your data is a \code{data.frame}, you can convert it by reference using \code{\link[data.table:setDT]{data.table::setDT}}.
#'
#' The \code{id}, \code{coords}, \code{sortBy} (and optional \code{splitBy}) arguments expect the names of respective columns in \code{DT} which correspond to the individual identifier, X and Y coordinates, sorting column, and additional splitting columns.
#'
#' The \code{projection} expects a \code{PROJ.4} character string (such as those available on \url{https://spatialreference.org/}).
#' The \code{projection} argument expects a character string defining the EPSG code. For example, for UTM zone 21N (EPSG 32736), the projection argument is "+init=epsg:32736". See \url{https://spatialreference.org/}) for a list of EPSG codes. Please note, R spatial has followed updates to GDAL and PROJ for handling projections, see more at \url{https://www.r-spatial.org/r/2020/03/17/wkt.html}.
#'
#' The \code{sortBy} is used to order the input \code{data.table} when creating \code{SpatialLines}. It must a \code{POSIXct} to ensure the rows are sorted by date time.
#'
Expand All @@ -20,6 +16,7 @@
#' An error is returned when an individual has less than 2 relocations, making it impossible to build a line.
#'
#' @inheritParams group_lines
#' @inheritParams build_polys
#'
#' @export
#'
Expand All @@ -38,8 +35,8 @@
#' # Cast the character column to POSIXct
#' DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
#'
#' # Proj4 string for example data
#' utm <- '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
#' # EPSG code for example data
#' utm <- '+init=epsg:32736'
#'
#' # Build lines for each individual
#' build_lines(DT, projection = utm, id = 'ID', coords = c('X', 'Y'),
Expand Down
8 changes: 4 additions & 4 deletions R/build_polys.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#' The \code{id}, \code{coords} (and optional \code{splitBy}) arguments expect the names of respective columns in \code{DT} which correspond to the individual identifier, X and Y coordinates, and additional grouping columns.
#'
#' The \code{projection} expects a \code{PROJ.4} character string (such as those available on \url{https://spatialreference.org/}). \code{build_polys} expects planar coordinates (not unprojected latitude, longitude).
#' The \code{projection} argument expects a character string defining the EPSG code. For example, for UTM zone 21N (EPSG 32736), the projection argument is "+init=epsg:32736". See \url{https://spatialreference.org/}) for a list of EPSG codes. Please note, R spatial has followed updates to GDAL and PROJ for handling projections, see more at \url{https://www.r-spatial.org/r/2020/03/17/wkt.html}.
#'
#' The \code{hrType} must be either one of "kernel" or "mcp". The \code{hrParams} must be a named list of arguments matching those of \code{adehabitatHR::kernelUD} and \code{adehabitatHR::getverticeshr} or \code{adehabitatHR::mcp}.
#'
Expand All @@ -21,7 +21,7 @@
#'
#' @inheritParams group_polys
#' @param spPts alternatively, provide solely a SpatialPointsDataFrame with one column representing the ID of each point.
#'
#' @param projection character string defining the EPSG code. For example, for UTM zone 21N (EPSG 32736), the projection argument is "+init=epsg:32736". See details.
#' @export
#'
#' @family Build functions
Expand All @@ -37,8 +37,8 @@
#' # Cast the character column to POSIXct
#' DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
#'
#' # Proj4 string for example data
#' utm <- '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
#' # EPSG code for example data
#' utm <- '+init=epsg:32736'
#'
#' # Build polygons for each individual using kernelUD and getverticeshr
#' build_polys(DT, projection = utm, hrType = 'kernel',
Expand Down
3 changes: 2 additions & 1 deletion R/get_gbi.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
#' DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
#' DT[, yr := year(datetime)]
#'
#' utm <- '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
#' # EPSG code for example data
#' utm <- '+init=epsg:32736'
#'
#' group_polys(DT, area = FALSE, hrType = 'mcp',
#' hrParams = list(percent = 95),
Expand Down
12 changes: 6 additions & 6 deletions R/group_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#' sorting, timegroup (generated by \code{group_times}) and additional grouping
#' columns.
#'
#' The \code{projection} argument expects a character string defining the EPSG code. For example, for UTM zone 21N (EPSG 32736), the projection argument is "+init=epsg:32736". See \url{https://spatialreference.org/}) for a list of EPSG codes. Please note, R spatial has followed updates to GDAL and PROJ for handling projections, see more at \url{https://www.r-spatial.org/r/2020/03/17/wkt.html}.
#'
#' The \code{sortBy} is used to order the input \code{data.table} when creating
#' \code{SpatialLines}. It must a \code{POSIXct} to ensure the rows are sorted
#' by date time. The \code{projection} expects a \code{PROJ.4} character string
#' (such as those available on \url{https://spatialreference.org/}). \code{group_lines}
#' expects planar coordinates (not unprojected latitude, longitude).
#' by date time.
#'
#' The \code{threshold} must be provided in the units of the coordinates. The
#' \code{threshold} can be equal to 0 if strict overlap is required, else it
Expand Down Expand Up @@ -59,7 +59,7 @@
#'
#'
#' @inheritParams group_pts
#' @param projection PROJ.4 character string
#' @inheritParams build_polys
#' @param threshold The width of the buffer around the lines in the units of the
#' projection. Supply 0 to compare intersection without buffering.
#' @param spLines Alternatively to providing a DT, provide a SpatialLines object
Expand All @@ -86,8 +86,8 @@
#' # Cast the character column to POSIXct
#' DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
#'
#' # Proj4 string for example data
#' utm <- '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
#' # EPSG code for example data
#' utm <- '+init=epsg:32736'
#'
#' \donttest{group_lines(DT, threshold = 50, projection = utm, sortBy = 'datetime',
#' id = 'ID', coords = c('X', 'Y'))}
Expand Down
18 changes: 8 additions & 10 deletions R/group_polys.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
#' \code{data.frame}, you can convert it by reference using
#' \code{\link[data.table:setDT]{data.table::setDT}}.
#'
#'
#' The \code{id}, \code{coords} (and optional \code{splitBy}) arguments expect
#' the names of respective columns in \code{DT} which correspond to the
#' individual identifier, X and Y coordinates, and additional grouping columns.
#'
#' The \code{projection} expects a \code{PROJ.4} character string (such as those
#' available on \url{https://spatialreference.org/}). \code{group_polys} expects planar
#' coordinates (not unprojected latitude, longitude).
#' The \code{projection} argument expects a character string defining the EPSG code. For example, for UTM zone 21N (EPSG 32736), the projection argument is "+init=epsg:32736". See \url{https://spatialreference.org/}) for a list of EPSG codes. Please note, R spatial has followed updates to GDAL and PROJ for handling projections, see more at \url{https://www.r-spatial.org/r/2020/03/17/wkt.html}.
#'
#' The \code{hrType} must be either one of "kernel" or "mcp". The
#' \code{hrParams} must be a named list of arguments matching those of
Expand Down Expand Up @@ -48,6 +45,7 @@
#'
#' @inheritParams group_pts
#' @inheritParams group_lines
#' @inheritParams build_polys
#' @param area boolean indicating either overlap group (when \code{FALSE}) or
#' area and proportion of overlap (when \code{TRUE})
#' @param hrType type of HR estimation, either 'mcp' or 'kernel'
Expand All @@ -69,15 +67,15 @@
#' # Cast the character column to POSIXct
#' DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
#'
#' # Proj4 string for example data
#' utm <- '+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
#' # EPSG code for example data
#' utm <- '+init=epsg:32736'
#'
#' group_polys(DT, area = FALSE, 'mcp', list(percent = 95),
#' projection = utm,
#' group_polys(DT, area = FALSE, hrType = 'mcp',
#' hrParams = list(percent = 95), projection = utm,
#' id = 'ID', coords = c('X', 'Y'))
#'
#' areaDT <- group_polys(DT, area = TRUE, 'mcp', list(percent = 95),
#' projection = utm,
#' areaDT <- group_polys(DT, area = TRUE, hrType = 'mcp',
#' hrParams = list(percent = 95), projection = utm,
#' id = 'ID', coords = c('X', 'Y'))
group_polys <-
function(DT = NULL,
Expand Down
8 changes: 4 additions & 4 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
],
"issueTracker": "https://github.com/ropensci/spatsoc/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.13",
"version": "0.1.14",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"version": "4.0.0",
"version": "4.0.2",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.0.0 (2020-04-24)",
"runtimePlatform": "R version 4.0.2 (2020-06-22)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -227,7 +227,7 @@
],
"releaseNotes": "https://github.com/ropensci/spatsoc//blob/master/NEWS.md",
"readme": "https://github.com/ropensci/spatsoc/blob/master/README.md",
"fileSize": "662.408KB",
"fileSize": "663.098KB",
"contIntegration": "https://codecov.io/gl/robit.a/spatsoc",
"developmentStatus": "http://www.repostatus.org/#active",
"review": {
Expand Down
6 changes: 4 additions & 2 deletions man/DT.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions man/build_lines.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/build_polys.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/get_gbi.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/group_lines.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions man/group_polys.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/testthat/test-build-lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ library(spatsoc)

DT <- fread('../testdata/DT.csv')

utm <-
'+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs'
utm <- '+init=epsg:32736'

DT[, datetime := as.POSIXct(datetime)]

Expand Down
Loading

0 comments on commit 2a5ce33

Please sign in to comment.