From 623ccedb30ef8e840b6b0eaccb4c34e301ed61b4 Mon Sep 17 00:00:00 2001 From: ando Date: Tue, 17 Sep 2024 11:51:11 +0900 Subject: [PATCH] :sparkles: Add function to set events to network --- NAMESPACE | 5 ++ R/create-road-network.R | 51 +++++++++++++++-- R/create-segmented-network.R | 45 ++++++++++++--- R/create-spatiotemporal-event.R | 10 ---- R/set-events.R | 53 ++++++++++++++++++ README.Rmd | 4 +- README.md | 9 ++- man/figures/README-example-3.png | Bin 0 -> 6817 bytes man/print.spatiotemporal_event.Rd | 23 -------- ...create_road_network.Rd => road_network.Rd} | 9 ++- ...mented_network.Rd => segmented_network.Rd} | 12 +++- man/set_events.Rd | 34 +++++++++++ pkgdown/_pkgdown.yml | 2 +- 13 files changed, 203 insertions(+), 54 deletions(-) create mode 100644 R/set-events.R create mode 100644 man/figures/README-example-3.png delete mode 100644 man/print.spatiotemporal_event.Rd rename man/{create_road_network.Rd => road_network.Rd} (75%) rename man/{create_segmented_network.Rd => segmented_network.Rd} (67%) create mode 100644 man/set_events.Rd diff --git a/NAMESPACE b/NAMESPACE index 9a7eb0f..0de2979 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,6 +4,8 @@ S3method(create_linestring,coordinates) S3method(create_linestring,numeric) S3method(create_points,coordinates) S3method(create_points,numeric) +S3method(create_road_network,sf) +S3method(create_segmented_network,road_network) S3method(create_spatiotemporal_event,sf) S3method(extract_segmented_network_nodes,road_network) S3method(plot,road_network) @@ -12,6 +14,8 @@ S3method(print,coordinates) S3method(print,road_network) S3method(print,segmented_network) S3method(print,spatiotemporal_event) +S3method(set_events,road_network) +S3method(set_events,segmented_network) S3method(split_linestring,LINESTRING) S3method(split_linestring,sfc_LINESTRING) S3method(summary,road_network) @@ -47,6 +51,7 @@ export(get_adjacent_links) export(get_connected_links) export(remove_points_near_endpoints) export(sample_points_along_linestring) +export(set_events) export(split_linestring) export(transform_to_cartesian) export(transform_to_geographic) diff --git a/R/create-road-network.R b/R/create-road-network.R index 22816f1..34ab7b4 100644 --- a/R/create-road-network.R +++ b/R/create-road-network.R @@ -6,7 +6,11 @@ #' #' @param roads A linestring object representing roads. #' @param directed Logical indicating whether the road network is directed. +#' @param events A `sf` object representing events. +#' @param ... Additional arguments passed to or from other methods. #' @returns A road network object. +#' @name road_network +#' @aliases create_road_network #' @export #' @examples #' # Create the road network @@ -15,7 +19,14 @@ #' #' # Plot the road network #' plot(road_network) -create_road_network <- function(roads, directed = FALSE) { +create_road_network <- function(roads, directed = FALSE, events = NULL, ...) { + UseMethod("create_road_network") +} + +#' @export +create_road_network.sf <- function(roads, + directed = FALSE, + events = NULL, ...) { # Extract nodes and links of road network nodes <- extract_road_network_nodes(roads) links <- extract_road_network_links(roads, nodes) @@ -31,6 +42,11 @@ create_road_network <- function(roads, directed = FALSE) { roads = roads ), class = "road_network") + # Assign events to the road network + if (!is.null(events)) { + road_network <- set_events(road_network, events) + } + return(road_network) } @@ -52,17 +68,42 @@ print.road_network <- function(x, ...) { print(as.data.frame(x$links)[1:5, ], ...) cat("...", nrow(x$links) - 5, "more links\n") } + if ("events" %in% names(x)) { + cat("\n") + cat("Events:\n") + if (nrow(x$links) <= 5) { + print(as.data.frame(x$events), ...) + } else { + print(as.data.frame(x$events)[1:5, ], ...) + cat("...", nrow(x$links) - 5, "more events\n") + } + } } #' @export -plot.road_network <- function(x, y, ...) { +plot.road_network <- function(x, y, mode = c("default", "event"), ...) { + # Match the mode argument + mode <- match.arg(mode) + + # Check if events are assigned to the road network + if (mode == "event" && !("events" %in% names(x))) { + stop("no events assigned to the road network") + } + plot(x$links$geometry, lwd = 1, ...) - plot(x$nodes$geometry, cex = 1, pch = 16, add = TRUE, ...) + if (mode == "event") { + plot(x$events$geometry, cex = 1, pch = 4, col = "red", add = TRUE, ...) + } else { + plot(x$nodes$geometry, cex = 1, pch = 16, add = TRUE, ...) + } } #' @export summary.road_network <- function(object, ...) { cat("Road network summary\n") - cat("Number of nodes: ", nrow(object$nodes), "\n") - cat("Number of links: ", nrow(object$links), "\n") + cat("Number of nodes: ", nrow(object$nodes), "\n") + cat("Number of links: ", nrow(object$links), "\n") + if ("events" %in% names(object)) { + cat("Number of events: ", nrow(object$events), "\n") + } } diff --git a/R/create-segmented-network.R b/R/create-segmented-network.R index d7224e3..6da0673 100644 --- a/R/create-segmented-network.R +++ b/R/create-segmented-network.R @@ -6,7 +6,11 @@ #' @param road_network A `road_network` object representing the input road #' network. #' @param segment_length A numeric value specifying the length of each segment. +#' @param events A `sf` object representing events. +#' @param ... Additional arguments passed to or from other methods. #' @return A `segmented_network` object. +#' @name segmented_network +#' @aliases create_segmented_network #' @export #' @examples #' # Create a road network @@ -21,7 +25,17 @@ #' #' # Plot the segmented road network #' plot(segmented_network) -create_segmented_network <- function(road_network, segment_length = 1) { +create_segmented_network <- function(road_network, + segment_length = 1, + events = NULL, ...) { + UseMethod("create_segmented_network") +} + +#' @rdname segmented_network +#' @export +create_segmented_network.road_network <- function(road_network, + segment_length = 1, + events = NULL, ...) { # Extract nodes and links of segmented road network nodes <- extract_segmented_network_nodes(road_network, segment_length) links <- extract_segmented_network_links(road_network, nodes) @@ -38,11 +52,20 @@ create_segmented_network <- function(road_network, segment_length = 1) { graph = graph, nodes = nodes, links = links, - events = NULL, origin_network = road_network, segment_length = segment_length ), class = "segmented_network") + # Assign events to the segmented network + if (!is.null(events)) { + if (!is.null(road_network$events)) { + warning("events already exist in the road network") + } + segmented_network <- set_events(segmented_network, events) + } else if ("events" %in% names(road_network)) { + segmented_network <- set_events(segmented_network, road_network$event) + } + return(segmented_network) } @@ -110,13 +133,17 @@ plot_coloured_segmented_network <- function(network_linestrings, ...) { par(fig = c(0, 0.8, 0, 1), mar = c(5, 4, 4, 2)) plot(network_linestrings, lwd = 1, ...) - plot( - network_linestrings, - col = get_heatmap_colours(segment_values), - lwd = ifelse(segment_values == 0, 1, 2), - add = TRUE, - ... - ) + if (max(segment_values) == 0) { + warning("all segment values are zero") + } else { + plot( + network_linestrings, + col = get_heatmap_colours(segment_values), + lwd = ifelse(segment_values == 0, 1, 2), + add = TRUE, + ... + ) + } } plot_legends <- function(segment_values, mode, ...) { diff --git a/R/create-spatiotemporal-event.R b/R/create-spatiotemporal-event.R index dc55b70..8cb94e2 100644 --- a/R/create-spatiotemporal-event.R +++ b/R/create-spatiotemporal-event.R @@ -40,17 +40,7 @@ create_spatiotemporal_event.sf <- function(x, return(x) } -#' Print a spatiotemporal event collection -#' -#' This function prints a summary of a spatiotemporal event collection object. -#' -#' @param x A `spatiotemporal_event` object. -#' @param ... Additional arguments passed to or from other methods. -#' @return The `spatiotemporal_event` object, invisibly. #' @export -#' @examples -#' spatiotemporal_events <- create_spatiotemporal_event(sample_accidents) -#' print(spatiotemporal_events) print.spatiotemporal_event <- function(x, ...) { cat("Spatiotemporal event collection with", nrow(x), "events and", ncol(x) - 2, "fields", fill = TRUE) diff --git a/R/set-events.R b/R/set-events.R new file mode 100644 index 0000000..370fbf9 --- /dev/null +++ b/R/set-events.R @@ -0,0 +1,53 @@ +#' Set events on a space. +#' +#' This function sets events on a space. +#' +#' @param x A `road_network` or `segmented_network` object. +#' @param events A `sf` object representing events. +#' @param ... Additional arguments passed to or from other methods. +#' @return The input object with the events added. +#' @export +#' @examples +#' # Create the road network +#' road_network <- create_road_network(sample_roads) +#' +#' # Set accidents on the road network +#' road_network <- set_events(road_network, sample_accidents) +set_events <- function(x, events, ...) { + UseMethod("set_events") +} + +#' @rdname set_events +#' @export +set_events.road_network <- function(x, events, ...) { + x <- validate_and_set_events(x, events) + + return(x) +} + +#' @rdname set_events +#' @export +set_events.segmented_network <- function(x, events, ...) { + x <- validate_and_set_events(x, events) + + # Count events on each link + event_counts <- table(st_nearest_feature(events, x$links)) + # Get the indices of the links with events + link_indices <- as.integer(names(event_counts)) + # Update the count of events of each link + x$links$count[link_indices] <- event_counts + + return(x) +} + +validate_and_set_events <- function(x, events) { + if (!inherits(events, "sf")) { + stop("events must be a `sf` object") + } + if ("events" %in% names(x)) { + warning("events have already been set on the road network") + } + x$events <- events + + return(x) +} diff --git a/README.Rmd b/README.Rmd index 7ce3cc1..db45f9c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -49,10 +49,12 @@ library(pavement) segmented_network <- sample_roads |> create_road_network() |> + set_events(sample_accidents) |> create_segmented_network(segment_length = 0.5) |> - assign_event_to_link(events = sample_accidents) + convolute_segmented_network() plot(segmented_network, mode = "event") plot(segmented_network, mode = "count") +plot(segmented_network, mode = "density") ``` ## Code of conduct diff --git a/README.md b/README.md index 9072bf5..0fefcc2 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,9 @@ library(pavement) segmented_network <- sample_roads |> create_road_network() |> + set_events(sample_accidents) |> create_segmented_network(segment_length = 0.5) |> - assign_event_to_link(events = sample_accidents) + convolute_segmented_network() plot(segmented_network, mode = "event") ``` @@ -59,6 +60,12 @@ plot(segmented_network, mode = "count") +``` r +plot(segmented_network, mode = "density") +``` + + + ## Code of conduct Please note that this project is released with a [Contributor Code of diff --git a/man/figures/README-example-3.png b/man/figures/README-example-3.png new file mode 100644 index 0000000000000000000000000000000000000000..df1bbea2094c0d4ad3799eeb8947a424ca75b1e9 GIT binary patch literal 6817 zcmeHMc~p|?*2f{o5;Q%Uo&(vWsbzy{DMD%4c+|S)kSDR!%*Trm`8b0Lr zl}Vb3>e@)intd#lmAh1-5N!i2WZ&=gYCDtvEAoG97hi8Qp(j2wD?#7W@PE|{B1TxK z&+{75UJ<%!{yWBQe70y|)~4fg-hfXl9mJMXY6nc2j8SkVBx4u`e278aaL!}ZnnVS0PcX=@hmqh2Mu-Tj@_Ve;OKicgN=M+qKBs8(;78inrDY>2|tDKtz?xc05ztJhhwK1UptT>r2$h zTFr-aKCJUclvQ$bNYAGzBae3A!nt7^QqKpxrx=@6!OoaDk~NeS z!9K!0j=qT|s@NFY9}8nv*#Nn=iw_qnGpQ>eW1R(?bW$qhc{JZss=}rDS+o z`9fRsNrkLlEHsWB$rxUPAkMX~AvAJ%o8;@+?Q5f<(9Fdb3(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FtF1y%PN?d!Z2VFHPUS6);mI&}TV($G@WGhvbZ4hn^Z^ zUps)L9H%5HI+>C$8sMu!MY9*Q8u0MZ64tu9zk0mL=O3RqMM>|C?Ez$$tgMFK=N#4o zy(VY5qz-!g^{WT+lB@DJuOnfD84{%7qicIU|L2a)OphsJup{u#DI;z8;Z#hE=48DZ z7XO6g$9t0Z)!Z#)-N8*rvVyYLse+6bbD%`0$C0NLy+Pt zk+&06_P8 z%BEXz$=fuDH6ZA(Wr4o%PJPo9Adt(!nZH1cP9(uI!Ezus`+9ow&jTN4TUd*;!E8V| zB3=$~UhlX9Uk9Rh$0dupANPTrG9NhQOrESrCYdQ^epSl5eLt@z#95~3CmizT^HD&J z5kPXD`riD_AU>nPc~ez~zW}N8NZ@Yh&OIiJYWaYS9af%9>geP=*gd@m0njWG2K6Kg z`e+7@2TPqF8MZT}okl?)?qZEJmg#Art)-@r(M^S#1*>j+3j!Eo->5(z{;5OgP6J(p z=91j4seIh#CkrK@ujpHnyF42WR02%`D7NwnDBm5$b0G!5X;f9k(DWly~3dv7#o+Hnd5m`!->0r7QoYQ0+hntzF^YRgFGA65nUy!^{?kmVp>Y6=(g zWx(9*APMZE4u%-aB8MWFa^Ml3VH}D=xV$|@3{{2P0*N<=WS%<3mIW3~UjGC7gZ>vG n|M%O$zt6$`A3m6Tci8B*+DYGJEDn5gg6!YpzWaqsVDkR}2?64M literal 0 HcmV?d00001 diff --git a/man/print.spatiotemporal_event.Rd b/man/print.spatiotemporal_event.Rd deleted file mode 100644 index 2a26b8c..0000000 --- a/man/print.spatiotemporal_event.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/create-spatiotemporal-event.R -\name{print.spatiotemporal_event} -\alias{print.spatiotemporal_event} -\title{Print a spatiotemporal event collection} -\usage{ -\method{print}{spatiotemporal_event}(x, ...) -} -\arguments{ -\item{x}{A \code{spatiotemporal_event} object.} - -\item{...}{Additional arguments passed to or from other methods.} -} -\value{ -The \code{spatiotemporal_event} object, invisibly. -} -\description{ -This function prints a summary of a spatiotemporal event collection object. -} -\examples{ -spatiotemporal_events <- create_spatiotemporal_event(sample_accidents) -print(spatiotemporal_events) -} diff --git a/man/create_road_network.Rd b/man/road_network.Rd similarity index 75% rename from man/create_road_network.Rd rename to man/road_network.Rd index 8ef00b8..fb09f2c 100644 --- a/man/create_road_network.Rd +++ b/man/road_network.Rd @@ -1,15 +1,20 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/create-road-network.R -\name{create_road_network} +\name{road_network} +\alias{road_network} \alias{create_road_network} \title{Create a road network from roads} \usage{ -create_road_network(roads, directed = FALSE) +create_road_network(roads, directed = FALSE, events = NULL, ...) } \arguments{ \item{roads}{A linestring object representing roads.} \item{directed}{Logical indicating whether the road network is directed.} + +\item{events}{A \code{sf} object representing events.} + +\item{...}{Additional arguments passed to or from other methods.} } \value{ A road network object. diff --git a/man/create_segmented_network.Rd b/man/segmented_network.Rd similarity index 67% rename from man/create_segmented_network.Rd rename to man/segmented_network.Rd index 51854b4..3c4eb60 100644 --- a/man/create_segmented_network.Rd +++ b/man/segmented_network.Rd @@ -1,16 +1,24 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/create-segmented-network.R -\name{create_segmented_network} +\name{segmented_network} +\alias{segmented_network} \alias{create_segmented_network} +\alias{create_segmented_network.road_network} \title{Create a segmented road network} \usage{ -create_segmented_network(road_network, segment_length = 1) +create_segmented_network(road_network, segment_length = 1, events = NULL, ...) + +\method{create_segmented_network}{road_network}(road_network, segment_length = 1, events = NULL, ...) } \arguments{ \item{road_network}{A \code{road_network} object representing the input road network.} \item{segment_length}{A numeric value specifying the length of each segment.} + +\item{events}{A \code{sf} object representing events.} + +\item{...}{Additional arguments passed to or from other methods.} } \value{ A \code{segmented_network} object. diff --git a/man/set_events.Rd b/man/set_events.Rd new file mode 100644 index 0000000..d535d4d --- /dev/null +++ b/man/set_events.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/set-events.R +\name{set_events} +\alias{set_events} +\alias{set_events.road_network} +\alias{set_events.segmented_network} +\title{Set events on a space.} +\usage{ +set_events(x, events, ...) + +\method{set_events}{road_network}(x, events, ...) + +\method{set_events}{segmented_network}(x, events, ...) +} +\arguments{ +\item{x}{A \code{road_network} or \code{segmented_network} object.} + +\item{events}{A \code{sf} object representing events.} + +\item{...}{Additional arguments passed to or from other methods.} +} +\value{ +The input object with the events added. +} +\description{ +This function sets events on a space. +} +\examples{ +# Create the road network +road_network <- create_road_network(sample_roads) + +# Set accidents on the road network +road_network <- set_events(road_network, sample_accidents) +} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 3f06cc9..5dc1034 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -74,7 +74,7 @@ reference: links and leveraging the detailed network structure, you can identify areas with high event frequency with these functions. contents: - - create_spatiotemporal_event + - spatiotemporal_event - assign_event_to_link - convolute_segmented_network - starts_with("compute_")