-
Notifications
You must be signed in to change notification settings - Fork 4
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 #48 from ITSLeeds/max-dist
max_dist and max_dest for points_to_od()
- Loading branch information
Showing
10 changed files
with
206 additions
and
72 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 |
---|---|---|
|
@@ -19,3 +19,4 @@ | |
^\.binder$ | ||
^\.vscode$ | ||
^CRAN-SUBMISSION$ | ||
^ad-hoc-tests$ |
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,6 +1,6 @@ | ||
Package: od | ||
Title: Manipulate and Map Origin-Destination Data | ||
Version: 0.4.4 | ||
Version: 0.5.0 | ||
Authors@R: c( | ||
person("Robin", "Lovelace", email = "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0001-5679-6536")), | ||
|
@@ -27,6 +27,7 @@ Depends: R (>= 3.4.0) | |
Imports: | ||
sfheaders, | ||
methods, | ||
nngeo, | ||
vctrs | ||
Suggests: | ||
sf, | ||
|
@@ -35,6 +36,6 @@ Suggests: | |
tinytest, | ||
covr, | ||
lwgeom | ||
RoxygenNote: 7.2.3 | ||
RoxygenNote: 7.3.2 | ||
VignetteBuilder: knitr | ||
Roxygen: list(markdown = TRUE) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/.quarto/ |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
format: gfm | ||
--- | ||
|
||
This document tests the new `max-dist` functionality in PR [#48](https://github.com/ITSLeeds/od/pull/48). | ||
|
||
Let's start the test documented in the PR with the installed version of the package. | ||
|
||
```{r} | ||
remotes::install_cran("od") | ||
library(sf) | ||
``` | ||
|
||
# Test 1: 1000 points | ||
|
||
|
||
```{r} | ||
p = pct::get_centroids_ew() | ||
p = p[1:1000,] | ||
system.time(r1 <- od::points_to_od(p)) | ||
head(r1) | ||
nrow(r1) | ||
``` | ||
|
||
Now let's test the new `max-dist` functionality. | ||
|
||
|
||
```{r} | ||
if (!file.exists("DESCRIPTION")) { | ||
setwd("..") | ||
} | ||
devtools::load_all() | ||
system.time(r2 <- points_to_od(p)) | ||
head(r2) | ||
nrow(r2) | ||
``` | ||
|
||
|
||
```{r} | ||
system.time(r3 <- points_to_od(p, max_dist = 1000)) | ||
head(r3) | ||
nrow(r3) | ||
``` | ||
|
||
The benchmark shows that the new `max-dist` functionality is faster than the original implementation for large datasets. | ||
|
||
Let's compare the results. | ||
|
||
|
||
```{r} | ||
waldo::compare(head(r1), head(r2)) | ||
r2_sorted = r2 |> | ||
dplyr::arrange(desc(O), desc(D)) | ||
r1_sorted = r1 |> | ||
dplyr::arrange(desc(O), desc(D)) | ||
waldo::compare(head(r1_sorted), head(r2_sorted)) | ||
``` | ||
|
||
Let's plot the results for the max-dist = 1000 case. | ||
|
||
|
||
```{r} | ||
r3_sf = od::od_to_sf(r3, p) | ||
plot(sf::st_geometry(p), col = "red") | ||
plot(sf::st_geometry(r3_sf), add = TRUE) | ||
``` | ||
|
||
# Test 2: od_coordinates |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.