Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

50 dev version of od causing simodels to fail #51

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 34 additions & 28 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
Package: od
Title: Manipulate and Map Origin-Destination Data
Version: 0.5.0
Version: 0.5.1
Authors@R: c(
person("Robin", "Lovelace", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5679-6536")),
person("David", "Cooley", role = c("ctb"))
)
Description: The aim of 'od' is to provide tools and example datasets for working with
origin-destination ('OD') datasets of the type used to describe aggregate
urban mobility patterns (Carey et al. 1981) <doi:10.1287/trsc.15.1.32>.
The package builds on functions for working with 'OD' data in the package 'stplanr',
(Lovelace and Ellison 2018) <doi:10.32614/RJ-2018-053> with a focus on computational
efficiency and support for the 'sf' class system (Pebesma 2018) <doi:10.32614/RJ-2018-009>.
With few dependencies and a simple class system based on data frames,
the package is intended to facilitate efficient analysis of 'OD' datasets
and to provide a place for developing new functions.
The package enables the creation and analysis of geographic entities
representing large scale mobility patterns,
from daily travel between zones in cities to migration between countries.
person("Robin", "Lovelace", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5679-6536")),
person("Malcolm", "Morgan", role = "aut",
comment = c(ORCID = "0000-0002-9488-9183")),
person("David", "Cooley", role = "ctb")
)
Description: The aim of 'od' is to provide tools and example datasets for
working with origin-destination ('OD') datasets of the type used to
describe aggregate urban mobility patterns (Carey et al. 1981)
<doi:10.1287/trsc.15.1.32>. The package builds on functions for
working with 'OD' data in the package 'stplanr', (Lovelace and Ellison
2018) <doi:10.32614/RJ-2018-053> with a focus on computational
efficiency and support for the 'sf' class system (Pebesma 2018)
<doi:10.32614/RJ-2018-009>. With few dependencies and a simple class
system based on data frames, the package is intended to facilitate
efficient analysis of 'OD' datasets and to provide a place for
developing new functions. The package enables the creation and
analysis of geographic entities representing large scale mobility
patterns, from daily travel between zones in cities to migration
between countries.
License: GPL-3
URL: https://github.com/itsleeds/od, https://itsleeds.github.io/od/
BugReports: https://github.com/itsleeds/od/issues
Encoding: UTF-8
LazyData: true
Depends: R (>= 3.4.0)
Depends:
R (>= 3.4.0)
Imports:
sfheaders,
methods,
sfheaders,
vctrs
Suggests:
sf,
knitr,
rmarkdown,
tinytest,
covr,
knitr,
lwgeom,
nngeo
RoxygenNote: 7.3.2
VignetteBuilder: knitr
nngeo,
rmarkdown,
sf,
tinytest
VignetteBuilder:
knitr
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# od 0.5.1 (2024-08)

* Bug fix that was causing incorrect column names (#50)

# od 0.5.0 (2024-08)

* New `max_dist` argument in `points_to_od()` (also applicable to `points_to_odl()`) to limit the distance between origins and destinations. Credit to Malcolm Morgan @mem48 for this contribution, closing 4-year-old issue #18.
Expand Down
5 changes: 5 additions & 0 deletions R/od-funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,8 @@ od_filter_destinations = function(x, codes) {
sel_d_in_codes = x[[2]] %in% codes
x[sel_d_in_codes, ]
}
# See https://stackoverflow.com/a/67872362
od_expand = function(ids) {
rev(expand.grid(rev(ids), stringsAsFactors = FALSE))
}
# od_expand(list(O = 1:3, D = 1:2))
13 changes: 10 additions & 3 deletions R/points_to_od.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' @export
#' @examples
#' library(sf)
#' p = od_data_centroids[1:3, ]
#' p = od_data_centroids[1:2, ]
#' points_to_od(p)
#' points_to_od(p, ids_only = TRUE)
#' (l = points_to_odl(p, interzone_only = TRUE))
Expand Down Expand Up @@ -99,7 +99,8 @@ points_to_od.sf = function(p, pd = NULL, interzone_only = FALSE, ids_only = FALS
D = pd[[1]][unlist(nn, use.names = FALSE)]
)
} else {
odf = data.frame(expand.grid(p[[1]], pd[[1]], stringsAsFactors = FALSE))
ids = list(O = p[[1]], D = pd[[1]])
odf = od_expand(ids)
}

if (interzone_only) {
Expand Down Expand Up @@ -148,7 +149,8 @@ points_to_odl = function(p, pd = NULL, crs = 4326, ...) {
#' @export
coords_to_od = function(p, interzone_only = FALSE, ids_only = FALSE) {
id = seq(nrow(p))
odf = data.frame(expand.grid(id, id, stringsAsFactors = FALSE)[2:1])
ids = list(O = id, D = id)
odf = od_expand(ids)
if (interzone_only) {
odf = od_interzone(odf)
}
Expand Down Expand Up @@ -184,3 +186,8 @@ od_interzone = function(x) {
od_intrazone = function(x) {
x[x[[1]] == x[[2]], ]
}
# See https://stackoverflow.com/a/67872362
od_expand = function(ids) {
rev(expand.grid(rev(ids), stringsAsFactors = FALSE))
}
# od_expand(list(O = 1:3, D = 1:2))
2 changes: 1 addition & 1 deletion man/points_to_od.Rd

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

Loading