Comments (4)
This would slow down line2route
. It already fails well and indicates so in the data. I suggest creating a function that can re-route straight lines generated by line2route
using a snap to route algorithm. Note that I tested CycleStreets.net's 'snap to route' algorithm and found it is already used internally so instead we should use another one, e.g. Google's or OSRM's, both of which are documented in stplanr I believe.
from stplanr.
I would suggest a wrapper script around line2route that runs the process you suggest. You would then get a function that does:
- Call line2route normally
- Select a subset of the SpatialLinesDataFrame that contains only the routes that failed in the initial call.
- Snap each of the coordinates to the nearest point on the route network using another algorithm
- Run line2route with the subset with updated coordinates
- Replace the failed routes with the new ones.
from stplanr.
Sounds like a good suggestion @richardellison I'm up for giving it a bash. We need it anyway for our work. (Context: @nikolai-b is working on the development of the Propensity to Cycle Tool for which line2route
was originally written.)
from stplanr.
First I wanted to check if this has been fixed upstream
Here is a csv file (github wanted me to rename it as a text file...) with the points that were failing and now Cyclestreets seems able to route them.
Looks like it has been fixed upstream!
Ruby code used to check the newer nearest point api:
require 'httparty'
require 'rgeo/geo_json'
class CycleStreetNearest
include HTTParty
base_uri 'https://api.cyclestreets.net/'
attr_reader :token, :dir
def initialize(token = ENV['CYCLESTREET'], dir = 'data-sources')
@token, @dir = token, dir
end
def query
file = File.read(File.join(dir, "failing-points.geojson"))
unsnappable = RGeo::GeoJSON.decode(file, json_parser: :json)
nearestpoints = unsnappable.map do |feature|
lng = feature.geometry.x
lat = feature.geometry.y
[feature.properties['geo_code'], lng, lat] + api_call(lng, lat)
end
CSV.open(File.join(dir, "snapped.csv"), "wb") do |csv|
nearestpoints.each { |point| csv << point }
end
end
private
def api_call(lng, lat)
self.class.get('/v2/nearestpoint', query: {
key: token,
lonlat: "#{lng},#{lat}"
})['features'][0]['geometry']['coordinates']
end
end
from stplanr.
Related Issues (20)
- Comparing the results between angle_diff with calculate_angle/get_vector HOT 1
- Error message in bind_sf
- CRAN issues
- bug in the rnet_merge function when defining the funs HOT 3
- Use different buffer options in `rnet_merge()`
- Convert large GeoJSON file to PMTiles HOT 1
- bug in geo_buffer HOT 7
- Possible speed enhancement to `mats2line()` HOT 3
- Invalid LineStrings in routes_fast_sf HOT 1
- Use `od::odc_to_sfc()` do the legwork in `mats2line()` HOT 3
- Bug in `line_segment()` when using certain values on projected data with `rsgeo` implementation HOT 8
- `rnet_merge()` fails when inputs are projected HOT 4
- `line_bearing()` is slow HOT 3
- Argument of segment_length in line_segment fun causes issue HOT 14
- Tried creating a route from desirelines using osrm function HOT 9
- rnet merge function can't not handle attributes containing strings HOT 1
- Add links to more papers in DESCRIPTION
- Re-add n_segments argument to line_segment() HOT 1
- `line_segment()` fails when n_segments has multiple values HOT 1
- od2line() throws an error if only one origin-destination relation is selected HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stplanr.