GithubHelp home page GithubHelp logo

datasciencecampus / proper Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 1.0 28.55 MB

A repository for the R tool propeR, which analyses travel time and cost using an OTP graph (see datasciencecampus/graphite)

Home Page: https://datasciencecampus.github.io/proper/

License: Other

Makefile 0.07% R 14.95% Dockerfile 0.02% HTML 84.96%
r transport travel docker otp opentripplanner dsc-projects

proper's Introduction

p r o p e R

prope [latin] verb Definitions:

  1. near, nearby;
  2. almost;
  3. close by

Contents

Introduction

This R package (propeR) was created to analyse multimodal transport for a number of research projects at the Data Science Campus, Office for National Statistics. This repository is for the installation and use of propeR only, for all OTP graph related guidance, please see graphite.

Software Prerequisites

Installing propeR

R installation

The easiest method is to install direct from this GitHub repository using:

library(devtools)
install_github("datasciencecampus/propeR/propeR")

Failing this, you can pull this repository and install locally using:

install("path/to/propeR/dir")

R building

If neither method above works. Or you wish to make changes to the package. Then you will need to build the package. Building propeR requires devtools and roxygen2:

# R
install.packages("devtools")
install.packages("roxygen2")

Then:

build("path/to/propeR/dir")
install("path/to/propeR/dir")

Once you have installed propeR using RStudio you can now start using it in RStudio.

Docker installation

For those who want to run propeR through Docker, we have created a Docker image. The propeR R package can be built from the parent directory as follows:

cd path/to/propeR/dir
docker build . --tag=dsc_proper

Or you can build from the online docker image, using:

docker run datasciencecampus/dsc_proper:1.0

See Dockerfile for more information and dependencies. Once you have installed propeR using Docker you can now start using it in Docker.

Running propeR

Function examples are available in this example.md file.

Data prerequisites

All location data (origin and destination) must be in comma separated (CSV) format and contain the following columns:

  • A unique ID column
  • A latitude column, where data is in decimal degrees (or a postcode column)
  • A longitude column, where data is in decimal degrees (or a postcode column)

The CSV file must contain headers, the header names can be specified in importLocationData().

Using RStudio

As with any R package, it can be loaded in an R session using:

#R
library(propeR)

Then you can use the functions, such as:

#R
pointToPoint(
output.dir="path/to/output/dir", 
originPoints=originPointsdf, 
destinationPoints=destinationPointsdf, 
startDateAndTime="2019-08-02 12:00:00"
)

Outputs will be saved to path/to/output/dir.

Using Docker

Alternatively. If you have installed propeR using Docker you can use Docker to run propeR. Put source and destination .csv data in a directory, e.g., /tmp/data/. Example data files origin.csv and destination.csv can be found in propeR/inst/extdata/, then:

docker run -v path/to/output/dir:/mnt datasciencecampus/dsc_proper:1.0 'otp.host="XXX.XXX.X.X", fun="pointToPoint", src_file="/mnt/origin.csv", dst_file="/mnt/destination.csv", output.dir="/mnt", startDateAndTime="2019-08-02 12:00:00"'

where otp.host is your inet address, which can be found using:

/sbin/ifconfig |grep inet |awk '{print $2}'

Output data will be in path/to/output/dir.

FAQ

Q: How accurate is the cost calculation in the point to point functions?

A: The tool currently cannot ingest fare information. Therefore costEstimate can be used in the point to point functions. This provides an estimate based on the values given in the parameters busTicketPrice, busTicketPriceMax, trainTicketPriceKm and trainTicketPriceMin.

Q: How to I stop propeR printing to the R console:

A: All functions have a parameter called infoPrint. This by default is set to T, please set to F if you want to prevent console printing.

Q: I found a bug!

A: Please use the GitHub issues form to provide us with the information.

Common errors

Q: Why am I receiving the following error when running propeR?

Error in curl::curl_fetch_memory(url, handle = handle) :
  Failed to connect to localhost port 8080: Connection refused
Called from: curl::curl_fetch_memory(url, handle = handle)

A: The OTP server has not been initiated. Please see graphite of this guide.

Q: Why am I receiving the following error when running propeR?

Error in paste0(otpcon, "/plan") : object 'otpcon' not found

A: The OTP connection has not been established. Please see graphite of this guide.

Acknowledgments

Authors / Contributors

Data Science Campus - Office for National Statistics

Contributions and Bug Reports

We welcome contributions and bug reports. Please do this on this repo and we will endeavour to review pull requests and fix bugs in a prompt manner.

Built and tested on OS and Windows using R version 3.5.2.

Licence

The Open Government Licence (OGL) Version 3

Copyright (c) 2018 Office of National Statistics

This source code is licensed under the Open Government Licence v3.0. To view this licence, visit www.nationalarchives.gov.uk/doc/open-government-licence/version/3 or write to the Information Policy Team, The National Archives, Kew, Richmond, Surrey, TW9 4DU.

proper's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

uk-gov-mirror

proper's Issues

[QUERY] I'm getting Error in parse_url(url) : length(url) == 1 is not TRUE when trying to use propeR functions

I am trying to use propeR to find the walking distance between a set of postcodes and a list of bus stops. I have the OTP server installed (using OpenTripPlanner) and it correctly gives walking routes between two points in the browser interface.

However, when I try to use any of the properR functions I get the following:

pointToPointNearest(output.dir = "D:\Data Science Stuff\TRACC replacement with PropeR\GreaterLondonOutput",
otpcon = otpcon,
originPoints = postcodes_2018_London,
destinationPoints = railstops_London,
journeyReturn = F,
modes = 'WALK',
nearestNum = 1,)
Now running the propeR pointToPointNearest tool.
Parameters chosen:
KNN nearest number: 1 (2584 calls)
Return Journey: FALSE
Date and Time: 2020-04-15 14:45:44
Creating 2584 point to point connections, please wait...
Error in parse_url(url) : length(url) == 1 is not TRUE

Unfortunately I can find nothing about this error anywhere, so I turn to you for help!

I am running R version 3.6.3, R Studio version 1.2.5042, and am doing this on a Windows 10 machine with 8GB RAM.

isochrone issue

Hi,

Thanks for creating this!

When I run the isochrone tool with the test origin and destinations dataset, I get the following error:
"Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
Cannot open data source"

Specifically, the command I'm running is:
"isochrone(userdir, otpcon = otpcon, originPoints = originPoints, originPointsRow= 2, destinationPoints = destinationPoints, destinationPointsRow = 2, startDateAndTime = '2019-06-05 17:00:00', modes = 'WALK, TRANSIT', mapOutput = T, isochroneCutOffMax = 90, isochroneCutOffMin = 30, isochroneCutOffStep = 30)"

The graph is working, since I can run the pointToPoint function with the same arguments.

Sorry if I'm missing something obvious.

Also, on a separate topic (but it's so minor that it wasn't worth opening a new issue): in the destination.csv dataset provided, I think the column "Name" should be called "name", otherwise it gives the following error when importing: "Error in order(data_points$name) : argument 1 is not a vector".

Thanks,
Stef

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.