saferactive / trafficalmr Goto Github PK
View Code? Open in Web Editor NEWR package to support road safety and traffic calming measures
Home Page: https://saferactive.github.io/trafficalmr/
License: GNU General Public License v3.0
R package to support road safety and traffic calming measures
Home Page: https://saferactive.github.io/trafficalmr/
License: GNU General Public License v3.0
Strange one, hard to debug, saying there is no sf column name: https://github.com/saferactive/trafficalmr/runs/1233734119#step:12:134
> x = osm_main_roads(tc_data_osm)
> junctions = osm_get_junctions(x)
Error in st_geometry.sf(x) :
attr(obj, "sf_column") does not point to a geometry column.
Did you rename it, without setting st_geometry(obj) <- "newname"?
Calls: osm_get_junctions ... st_cast.sf -> st_cast -> st_geometry -> st_geometry.sf
Execution halted
Heads-up @mem48 there is an error when I run this function:
(Heads-up also @joeytalbot sorry for being slow on this!)
region_name = "Isle of Wight"
> # region_name = "Greater London" # test for London
> osm = osmextract::oe_get(region_name)
> osm = osm_main_roads(osm)
> osm = sf::st_transform(osm, 27700)
> osm = osm_consolidate(osm)
Error in `[.data.frame`(x, i, j, drop = drop) :
undefined columns selected
ct has code
The docs say:
#' @param segment numeric, max length of segments in metres
This implies that longer segments will results in fewer output objects.
However, the opposite is true, as shown below on the osm_cleaning
branch:
> nrow(x) / nrow(osm_consolidated)
[1] 1.258448
> osm_consolidated_1000m = osm_consolidate(x, segment = 1000)
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
Warning message:
In st_cast.sf(xmlsB, "LINESTRING") :
repeating attributes for all sub-geometries for which they may not be constant
> nrow(x) / nrow(osm_consolidated_1000m)
[1] 1.408046
> osm_consolidated_200m = osm_consolidate(x, segment = 200)
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s
Warning message:
In st_cast.sf(xmlsB, "LINESTRING") :
repeating attributes for all sub-geometries for which they may not be constant
> nrow(x) / nrow(osm_consolidated_200m)
[1] 0.8423815
Was this intended @mem48 ? seems like a bug to me.
It should be able to return data at the casualty level. Example below:
remotes::install_github("saferactive/trafficalmr")
#> Using github PAT from envvar GITHUB_PAT
#> Skipping install of 'trafficalmr' from a github remote, the SHA1 (bce0785a) has not changed since last install.
#> Use `force = TRUE` to force installation
library(trafficalmr)
nrow(crashes_wf)
#> [1] 3449
nrow(casualties_wf)
#> [1] 4245
crash_summary = tc_join_stats19(crashes_wf, casualties_wf, vehicles_wf)
#> Joining, by = "accident_index"
nrow(crash_summary)
#> [1] 3449
Created on 2020-07-17 by the reprex package (v0.3.0)
Related issue: ropensci/stplanr#362
On local desktop it takes almost a minute to run, although it's 40% faster on a remote server it's still on the slow side:
system.time(devtools::check("~/saferactive/trafficalmr/"))
#> Updating trafficalmr documentation
#> Loading trafficalmr
#> Writing NAMESPACE
#> Writing NAMESPACE
#> ── Building ──────────────────────────────────────────────────────────────── trafficalmr ──
#> Setting env vars:
#> ● CFLAGS : -Wall -pedantic
#> ● CXXFLAGS : -Wall -pedantic
#> ● CXX11FLAGS: -Wall -pedantic
#> ───────────────────────────────────────────────────────────────────────────────────────────
#> checking for file ‘/mnt/57982e2a-2874-4246-a6fe-115c199bc6bd/orgs/saferactive/trafficalmr/DESCRIPTION’ ... ✔ checking for file ‘/mnt/57982e2a-2874-4246-a6fe-115c199bc6bd/orgs/saferactive/trafficalmr/DESCRIPTION’
#> ─ preparing ‘trafficalmr’: (3.4s)
#> checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information
#> ─ installing the package to build vignettes
#> creating vignettes ... ✔ creating vignettes (12.2s)
#> ─ checking for LF line-endings in source and make files and shell scripts
#> ─ checking for empty or unneeded directories
#> ─ building ‘trafficalmr_0.1.0.tar.gz’
#>
#> ── Checking ──────────────────────────────────────────────────────────────── trafficalmr ──
#> Setting env vars:
#> ● _R_CHECK_CRAN_INCOMING_USE_ASPELL_: TRUE
#> ● _R_CHECK_CRAN_INCOMING_REMOTE_ : FALSE
#> ● _R_CHECK_CRAN_INCOMING_ : FALSE
#> ● _R_CHECK_FORCE_SUGGESTS_ : FALSE
#> ● NOT_CRAN : true
#> ── R CMD check ─────────────────────────────────────────────────────────────────
#> * using log directory ‘/tmp/RtmpXDmJzP/trafficalmr.Rcheck’
#> * using R version 4.0.2 (2020-06-22)
#> * using platform: x86_64-pc-linux-gnu (64-bit)
#> * using session charset: UTF-8
#> * using options ‘--no-manual --as-cran’
#> * checking for file ‘trafficalmr/DESCRIPTION’ ... OK
#> * checking extension type ... Package
#> * this is package ‘trafficalmr’ version ‘0.1.0’
#> * package encoding: UTF-8
#> * checking package namespace information ... OK
#> * checking package dependencies ... OK
#> * checking if this is a source package ... OK
#> * checking if there is a namespace ... OK
#> * checking for executable files ... OK
#> * checking for hidden files and directories ... OK
#> * checking for portable file names ... OK
#> * checking for sufficient/correct file permissions ... OK
#> * checking whether package ‘trafficalmr’ can be installed ... OK
#> * checking installed package size ... NOTE
#> installed size is 6.2Mb
#> sub-directories of 1Mb or more:
#> doc 5.6Mb
#> * checking package directory ... OK
#> * checking for future file timestamps ... NOTE
#> unable to verify current time
#> * checking ‘build’ directory ... OK
#> * checking DESCRIPTION meta-information ... OK
#> * checking top-level files ... OK
#> * checking for left-over files ... OK
#> * checking index information ... OK
#> * checking package subdirectories ... OK
#> * checking R files for non-ASCII characters ... OK
#> * checking R files for syntax errors ... OK
#> * checking whether the package can be loaded ... OK
#> * checking whether the package can be loaded with stated dependencies ... OK
#> * checking whether the package can be unloaded cleanly ... OK
#> * checking whether the namespace can be loaded with stated dependencies ... OK
#> * checking whether the namespace can be unloaded cleanly ... OK
#> * checking loading without being on the library search path ... OK
#> * checking dependencies in R code ... OK
#> * checking S3 generic/method consistency ... OK
#> * checking replacement functions ... OK
#> * checking foreign function calls ... OK
#> * checking R code for possible problems ... OK
#> * checking Rd files ... OK
#> * checking Rd metadata ... OK
#> * checking Rd line widths ... OK
#> * checking Rd cross-references ... OK
#> * checking for missing documentation entries ... OK
#> * checking for code/documentation mismatches ... OK
#> * checking Rd \usage sections ... OK
#> * checking Rd contents ... OK
#> * checking for unstated dependencies in examples ... OK
#> * checking contents of ‘data’ directory ... OK
#> * checking data for non-ASCII characters ... OK
#> * checking data for ASCII and uncompressed saves ... OK
#> * checking installed files from ‘inst/doc’ ... OK
#> * checking files in ‘vignettes’ ... OK
#> * checking examples ... OK
#> * checking for unstated dependencies in ‘tests’ ... OK
#> * checking tests ...
#> Running ‘skip-download.R’
#> Running ‘testthat.R’
#> OK
#> * checking for unstated dependencies in vignettes ... OK
#> * checking package vignettes in ‘inst/doc’ ... OK
#> * checking re-building of vignette outputs ... OK
#> * checking for non-standard things in the check directory ... OK
#> * checking for detritus in the temp directory ... OK
#> * DONE
#>
#> Status: 2 NOTEs
#> See
#> ‘/tmp/RtmpXDmJzP/trafficalmr.Rcheck/00check.log’
#> for details.
#> user system elapsed
#> 24.942 4.580 45.943
Created on 2020-09-22 by the reprex package (v0.3.0)
Currently it says:
Line 4 in 8d41d64
I suggest adding a link to your package is a good solution here @PublicHealthDataGeek, you up for giving it a bash?
highway=path + bicycle=designated , highway=path + cycleway=lane , highway=* + cycleway=track , and highway=cycleway
Casualties or vehicles are not being properly assigned to the 'Other' category.
The figure in the function help example has lots of accidents with lone pedestrians or with lone cyclists. This isn't correct. Instead these crashes should probably be 'pedestrian + other' and 'cyclist + other.'
remotes::install_github("saferactive/trafficalmr")
library(trafficalmr)
remotes::install_github("krassowski/complex-upset")
crash_summary = tc_join_stats19(crashes_wf, casualties_wf, vehicles_wf)
# create plot with 'Other' category
casualties_wf2 = dplyr::mutate(
casualties_wf,
casualty_type_simple = dplyr::case_when(
casualty_type == "Car occupant" ~ "Car",
casualty_type == "Pedestrian" ~ "Pedestrian",
casualty_type == "Cyclist" ~ "Cyclist",
TRUE ~ "Other"
)
)
crash_summary = tc_join_stats19(crashes_wf, casualties_wf2, vehicles_wf)
tc_upset(crash_summary, casualty_type = c("Car", "Pedestrian", "Bicycle", "Other"))
Currently maxspeed variables are all over the place. @mem48 we could integrate stuff you did on CyIPT here and make it well documented and future proof. Here's what I get for London:
summary(osm_london_highways_gf_common$maxspeed)
10 10 mph 100 100 mph 105 mph 110 mph 115 mph 12 mph 125 mph 15 15 mph 180 2 mph 20
0 3 0 0 0 0 0 0 0 0 0 0 0 1
20 mph 225 230 25 mph 250 30 30 mph 300 320 35 mph 4 mph 40 40 mph 45 mph
9560 0 0 0 0 20 11220 0 0 0 0 1 924 0
5 5 mph 50 50 mph 55 mph 60 60 mph 64 65 mph 7 70 mph 75 mph 80 80 mph
0 2 0 236 0 0 62 0 0 0 2 0 0 0
85 mph 90 mph 95 mph national none signals variable walk NA's
0 0 0 1 0 6 0 0 5576
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.