Code Monkey home page Code Monkey logo

carriageways-creator's Introduction

Carriageways Creator (CC)

Jupyter notebooks that create carriageways using areal dataset and OSM

Requirements

  • geopandas
  • osmnx
  • jupyter

Installation

Use a virtual environment (Optional)

virtualenv venv
. venv/bin/activate

Install dependencies

pip install -r requirements.txt

Usage

The jupyter notebooks

  • Run jupyter-notebook and open processing.ipynb
  • Change the areal dataset path to your dataset
  • Run

Fix dead ends

  • Some dead ends are broken. You can fix them with fix_deadends.ipynb.

Stats

  • You can extract stats using road_stats.ipynb

If you use CC in a scientific context, please cite this article:

Stelios Vitalis, Anna Labetski, Hugo Ledoux & Jantien Stoter (2022) From road centrelines to carriageways-A reconstruction algorithm, PLoS ONE, DOI: 10.1371/journal.pone.0262801

Article available here.

@article{Vitalis2022,
	Author = {Vitalis, Stelios and Labetski, Anna and Ledoux, Hugo and Stoter, Jantien},
	Title = {From road centrelines to carriageways-{A} reconstruction algorithm},
	Journal = {PLoS ONE},
	Year = {2022},
	Volume = {17(2): e0262801},
	Doi = {https://doi.org/10.1371/journal.pone.0262801}

carriageways-creator's People

Contributors

athelena avatar liberostelios avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

carriageways-creator's Issues

Funny intersections

Based on the fix for bus lanes (Breda), sometimes you get funny intersections (Toronto)

image

Make snapping rely on shapely's snapping function?

Now we have our own code for snapping the geometry which might sometimes freak out as it makes a few assumptions. It might be worth trying to replace the whole thing using the shapely.ops.snap function which should be reliable. Maybe worth a try.

Multiple branches created

This is a special case that breaks during trim and extend. During trim, line 0x33b638... follows the last part of 0xb36d95fd..., but it doesn't detect that it intersects 0x2bf785b1... as well. Then, in extend it tries to reach the end of the other side of 0x2bf785b1..., which makes a new branch.

Screenshot 2020-09-25 at 11 13 51

When is a road network truly 3D?

Again more for when we look at how to store in CityJSON, how can we model ramps and overpasses as truly 3D? OSM doesn't store z coords.

Some stuff in Toronto

Bookmark - Uh Oh

image

Bookmark - Oops

image

Bookmark - Pour Discussion

image

Bookmark - Niet

image

Bookmark - I like

image

Four-way duals not always fixed

Screenshot 2020-10-06 at 11 44 54

We don't fix all four-way duals as they should. This occurs a few times in Poznan and remains unresolved. It might be possible to ignore.

Add error/warning codes

We could have a column where we add error/warning codes during the construction process, so we can better track down the minor issues that were dealt as degenerate cases.

Road width tolerance?

There are traffic island holes here which is why the width comes out so small... Maybe we should be more tolerant... or dissolve holes...

image

Flyovers

  • We need to preserve flyover information for the final pass where we create nodes
  • Match them with the BGT for the road width calculation
  • Check for them when snapping or extending

Didn't trim

Screenshot 2020-10-06 at 11 34 54

Weird case where trim should work. Needs investigation.

Things to do at the last day (of the rest of our lives)

  • Fix UUIDs (we could compute bigger ones and convert to string)
  • Fix SQL script (add an argument to support other EPSGs)
  • Remove CityJSON stuff
  • Refactoring (for instance, make EPSG declared once at the beginning)
  • Rename stuff away from BGT
  • Rename road_width_final_final ๐Ÿค“
  • Export all output as .gpkg instead of .geojson
  • Clean-up
    • One pass to remove overlapping parts of roads at an intersection
    • One pass to gather overlapping parts of roads at an intersection in one global array
    • One pass to join the overlapping parts with both attributes and add them to the dataframe
  • Brew some nice stats
  • Merge the two notebooks
  • Four-way duals triangles (as in #13)
  • Check the number of edges per connected component
  • All the small cleaning mentioned in #10

Lanes generation potential is far more limiting than carriageways

There are far more limits to procedural lanes generation than in carriageways. This is because lane have a much more local variability nature than carriageways. For example:

Screenshot 2020-11-03 at 16 29 35

In other words, lanes vary across the same road much more than carriageways. Creating really useful lanes (especially merging lanes etc) requires more detailed width calculation (e.g. a width per segment of the same road) which are also more prone to errors.

Real roads vs. just network ones

There are probably lines that are there for the network and don't correspond to real roads, and those we should force to be single carriageways.

image

Ugly case

Screenshot 2020-09-28 at 16 25 15

This line is getting this ugly shape after trim. The reason is that we don't build a straight segment between the intersection of the two lines and the end point, but we try to maintain the original curvature of the line.

We can fix that by checking if something peculiar happens (e.g., in this case the length gets almost twice as long as the original) in which case we fall back to constructing a straight segment.

Stats to save

Already calculated in script:

  • Number of road edges in filtered network and final network
  • Number of connected components (and the count per component) in filtered network and final network
  • Number of road edges in the filtered network that are classified as dual carriageway

Potentially easy to calculate:

  • Average length and SD of road edge in filtered network and final network
  • Number of nodes in filtered network and final network
  • Number of polygons in aerial representation (to use in ratio later)
  • Average area of polygons
  • Average width and SD

Indicators:

  • Number of polygons / number of edges
  • Average area of polygons / average length of edges

Sometimes, a line shouldn't be connected to the other side

Screenshot 2020-10-13 at 14 43 29

When a road intersects with a dual carriageway, sometimes it might not be possible to turn both ways because of some physical barrier. I think we should discuss about it as something that is dealt "automatically" since in those cases the dual carriageways will be modelled as two individual single ways in OSM, therefore this is taken care already.

Minor issue: we didn't check if there are cases that are still modelled as a dual carriageway with a single line and there are semantics to denote turning restrictions.

Crossing lines not identified by trim

Screenshot 2020-09-28 at 16 04 34

This is really a degenerate case: a line starts at the center of a dual carriageway and normally would have identified as a crossing road and would have been trimmed there. But, in this case, the actual neighbour of 0x63c2d9... is really short, so 0x63c2d9... crosses the next segment, which is not taken into account during the trim processing step.

We now have a solution similar solution for this: we take into consideration the neighbours of the next segment if the current segment length is below 3m. We'll have to do the same here for neighbours, but with a bigger tolerance.

Final run

  • #3
  • make nodes
  • new uuids
  • recalculate length
  • check network connectivity

Identify existing dual carriageways?

Maybe this is extreme, but some roads are already modelled as dual carriageways, not sure if we can identify them? For example in this figure the dual carriageways could be linked? Also in the figure in #5

image

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.