Coder Social home page Coder Social logo

cyclestreets / cyclestreets-r Goto Github PK

View Code? Open in Web Editor NEW
27.0 5.0 7.0 3.98 MB

An R interface to cyclestreets.net APIs

Home Page: https://rpackage.cyclestreets.net/

License: GNU General Public License v3.0

R 100.00%
cycling routing r transport transportation-planning

cyclestreets-r's People

Contributors

atumscott avatar joeytalbot avatar mem48 avatar mvl22 avatar robinlovelace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cyclestreets-r's Issues

Issues preventing upload to CRAN

Any help on this gratefully received. Heads-up @EricKrg and @mvl22 (from CRAN pkg team):

    Package Information:
    Package: cyclestreets
    Version: 0.1.1
    Title: Route Planning and Other Services for Cyclists
    Author(s): person("Robin", "Lovelace", email = "[email protected]", role =
       c("aut", "cre"), comment = c(ORCID = "0000-0001-5679-6536")),
       person("Martin", "Lucas-Smith", role = c("aut")),
       person("Eric", "Krueger", role = c("cbt")))


Thanks, please use person() in the Authors@R field. The Author(s) and Maintainer field will be auto-generated from the information in the Authors@R field.



    Maintainer: Robin Lovelace <[email protected]>
    Description: The goal of cyclestreets is to provide a simple R interface
       to the CycleStreets.net routing service.


Please write URL in your description text in the form
<http:...> or <https:...>
with angle brackets for auto-linking and no space after 'http:' and 'https:'.

Please elaborate in your description what functinality CycleStreets.net provides.

Please write package names and software names in single quotes (e.g. 'cyclestreets') in  your description.

Please fix and resubmit.

Short segments

As reported by @natesheehan:

Currently, very short routes do not work with the journey function.

Error:
Error in stats::filter(x, rep(1/n, n), sides = 2) : 'filter' is longer than time series
Example:

# dput(desire_line_town) getting lat long
origin = c(-0.214849749698027,51.5586119006974)
destination = c( -0.214888955159809,51.5564466729046)

a = cyclestreets::journey(
  origin,
  destination 
)
#> Loading required namespace: stplanr
#> Error in stats::filter(x, rep(1/n, n), sides = 2): 'filter' is longer than time series
mapview::mapview(a)
#> Error in eval(quote(list(...)), env): object 'a' not found
Created on 2021-05-19 by the reprex package (v2.0.0)

From the old cyclestreets repo...

Hilliness

Opening this issue as a place to properly document efforts to generate accurate gradient estimates from cyclestreets elvation data.

Try data.table::fread

There have been issues with processing results from batch processing, worth checking if those can be overcome by using a different read function.

Move to cyclestreets github org

  • Update urls in documentation
  • Move across!

I think this is a great idea proposed by @mvl22, should lead to tighter CycleStreets integration and help us fix issues with expertise from the cyclestreets team ; )

Github repo location

Any chance we might have this instead as an official repo at

cyclestreets/cyclestreets-r

instead of

Robinlovelace/cyclestreets

? Would be great to have such officialness, and we are aiming to put other wrapper-type stuff there over time.

Cyclestreets::journey failing for routes of one segment in length

While trying to do routing using the new gradient_smooth approach, I've found that it fails for very short routes. It looks like we need to edit journey.R to avoid this.

> library(stplanr)
> library(parallel)
> library(cyclestreets)
> cl = makeCluster(detectCores())
> clusterExport(cl, c("journey"))
> od_lsoas_short = readRDS("od_lsoas_short.Rds")
> split_grouping_variable = rep(1:331, each = 1000)[1:nrow(od_lsoas_short)]                                 
> od_lsoas_short_list = split(od_lsoas_short, split_grouping_variable)
> system.time({routes_lsoa_1 = route(l = od_lsoas_short_list[[1]], route_fun = cyclestreets::journey, cl = cl, smooth_gradient = TRUE)})
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02m 06s
Most common output is sf
These routes failed: 818
The first of which was:
<simpleError in stats::filter(x, rep(1/n, n), sides = 2): 'filter' is longer than time series>
   user  system elapsed 
  1.945   0.490 125.794 

The geometry below shows that this route only contains one segment.

> od_lsoas_short$geometry[818,]
Geometry set for 1 feature 
geometry type:  LINESTRING
dimension:      XY
bbox:           xmin: 0.1431735 ymin: 51.5433 xmax: 0.1468841 ymax: 51.54429
geographic CRS: WGS 84
LINESTRING (0.1431735 51.54429, 0.1468841 51.5433)

Add new optional columns

Looking at the output I think it would be good to have optional unchanging variables representing journey origin and destination. Working on this...

Batch ids

Based on info from @joeytalbot I suspect that the batch() is returning incorrect ids. Do you have a reproducible example desire line with IDs in Ireland Joey? Great work on identifying the issue.

Missing features from stplanr

The old function stplanr::route_cyclestreet could return grouped data (one row per route) and derived values cum_hill change_elev dif_max_min up_tot down_tot av_incline co2_saving calories busyness

The new function cyclestreets::journey does not group (one row per route segment), and cannot calculate these grouped values.

This seems like a limitation and makes the cyclestreet package less useful.

Interface to batch routing API

It would be good to have an interface to the batch routing API, enabling upload of .csv files and download of .geojson files (or output in other formats).

This issue can track development of this functionality.

# Aim: test batch routing
library(stplanr)
library(cyclestreets)

# input data
?odrust::odr_jitter
library(odrust)
od = readr::read_csv("https://github.com/dabreegster/odjitter/raw/main/data/od.csv")
zones = sf::read_sf("https://github.com/dabreegster/odjitter/raw/main/data/zones.geojson")
road_network = sf::read_sf("https://github.com/dabreegster/odjitter/raw/main/data/road_network.geojson")
set.seed(42)
od_jittered = odr_jitter(
  od,
  zones,
  subpoints = road_network,
  disaggregation_threshold = 50
)

od_geo = od_jittered[1:3, 0]
coord_example = od::od_coordinates(od_geo)
readr::write_csv(as.data.frame(coord_example), "coord_example.csv")
sf::write_sf(od_geo, "coord_example.geojson")
coord_example_sf = sf::st_sf(coord_example, geometry = od_geo$geometry)
coord_example_cs = route(coord_example_sf, route_fun = journey)
sf::write_sf(coord_example_cs, "batch_output_example_route_stplanr.geojson")

Extra column name associated with short routes

As shown in the example below, the provisionName column is duplicated for some routes it seems:

start_coords = c(-8.80639, 52.50692)
  end_coords = c(-8.80565, 52.51329)
  j = cyclestreets::journey(from = start_coords, to = end_coords)
  names(j)
#>  [1] "name"              "distances"         "time"             
#>  [4] "busynance"         "quietness"         "gradient_segment" 
#>  [7] "elevation_change"  "provisionName"     "start_longitude"  
#> [10] "start_latitude"    "finish_longitude"  "finish_latitude"  
#> [13] "crow_fly_distance" "event"             "whence"           
#> [16] "speed"             "itinerary"         "plan"             
#> [19] "note"              "length"            "west"             
#> [22] "south"             "east"              "north"            
#> [25] "leaving"           "arriving"          "grammesCO2saved"  
#> [28] "calories"          "edition"           "provisionName.1"  
#> [31] "geometry"          "gradient_smooth"

Created on 2023-08-05 with reprex v2.0.2

Release cyclestreets 0.4.0

Prepare for release:

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Show full error messages

When a route fails, it would be very helpful to show the error message that explains why the route failed. E.g.

"Too short: journeys must be longer than 4 metres. (Your requested journey was 0 metres)."

This is especially needed for the batch routing, where a single failed route prevents the entire process from completing.

More json errors

With this file. Heads-up @mvl22 I cannot see an error message here, may be the parsing on the R side but if you see anything unusual with this (batch id 383) please let us know, also in email.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.