Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 20 mph roads to speed limit legend #177

Closed
6 tasks
robinlovelace-ate opened this issue May 19, 2023 · 24 comments
Closed
6 tasks

Add 20 mph roads to speed limit legend #177

robinlovelace-ate opened this issue May 19, 2023 · 24 comments
Milestone

Comments

@robinlovelace-ate
Copy link
Contributor

robinlovelace-ate commented May 19, 2023

Legend from video in #169 has speed as binned variable:

image

Given the importance of 20 mph zones, I think this should be a value in the legend. Also speed limits are discrete. So I would suggest the following categories for speed limits:

  • Less than 20 mph
  • 20 mph
  • 30 mph
  • 40 mph
  • 50+ mph
  • Unknown
@dabreegster
Copy link
Contributor

I can run an Overpass query in a moment, but I'd be surprised if there are no roads in the UK in OSM tagged with anything other than those values. Why not bins? 0-20, 20-30, 30-40, 40+?

@robinlovelace-ate
Copy link
Contributor Author

robinlovelace-ate commented May 19, 2023

We need to clean the OSM data into those allowed values. Why not bins? Because speed limits in the UK, like legally sold weights of bread and volumes of beer sold in pubs, can only be a small number of discrete sizes (400g or 800g for bread, fractions of pint for beer)!

@robinlovelace-ate
Copy link
Contributor Author

There is code in the openinfra project that takes the diversity of OSM tags and puts them into these categories. I can dig that out.

@robinlovelace-ate
Copy link
Contributor Author

Also, regarding less than 20, that's a valid point Dustin as there are some (mostly private?) roads with happily 5 mph limits so suggest

  • "Less than 20" or similar

as an additional tag to account for that rare but helpful edge case.

@robinlovelace-ate
Copy link
Contributor Author

OK update here, the code from @hulsiejames is really clear happily. James if you want to jump in to help us at any point feel free, I imagine this will be converted into rock solid Rust code and implemented as a function, that could one day be split out as a stand-alone crate e.g. called osmclean or similar?

      (maxspeed == "national" & highway %in% c("motorway", "motorway_link")) ~ "70 mph",
      
      # maxspeed == national, when NOT on motorway
      (maxspeed == "national" & highway %!in% c("motorway", "motorway_link")) ~ "60 mph",  
      
      # maxspeed == national, when on standard (i.e Non-Residential) dual carriageway
      # Default is 60 mph - if there is physical separation this is 70 mph, but 
      # assume that if there is separation then maxspeed tag = 70 mph. Rather be
      # conservative stating 60 mph if not stated.
      (maxspeed == "national" & highway %in% c("trunk", "trunk_link")) ~ "60 mph",
      
      # Catch maxspeeds of 5, 10, 15 and set to 20 mph
      maxspeed %in% c("5", "10", "15", 
                      "5 mph", "10 mph", "15 mph") ~ "< 20 mph",
      
      # maxspeed == (20|30|40|50|60|70 --> + mph)
      maxspeed == "20" ~ "20 mph",
      maxspeed == "30" ~ "30 mph",
      maxspeed == "40" ~ "40 mph",
      maxspeed == "50" ~ "50 mph",
      maxspeed == "60" ~ "60 mph",
      maxspeed == "70" ~ "70 mph",
      
      # Already cleaned speeds (to stop mutate missing these)
      maxspeed == "20 mph" ~ "20 mph",
      maxspeed == "30 mph" ~ "30 mph",
      maxspeed == "40 mph" ~ "40 mph",
      maxspeed == "50 mph" ~ "50 mph",
      maxspeed == "60 mph" ~ "60 mph",
      maxspeed == "70 mph" ~ "70 mph",

Source: https://github.com/udsleeds/openinfra/blob/3d2666d568a1ee50fb4fd7bf469b00d1f9398802/R/oi_clean_maxspeed_uk.R#L32-L61

@robinlovelace-ate
Copy link
Contributor Author

Government docs on speed limits, may be worth linking to this: https://www.gov.uk/speed-limits

@robinlovelace-ate
Copy link
Contributor Author

I didn't realise that 50 mph roads were legally defined a thing but they are. From previous link:

50 mph (rather than 60 mph) limit on a stretch of road with sharp bends

So maybe 60 mph+ should be 50 mph+?

@robinlovelace-ate
Copy link
Contributor Author

Another reason to change to discrete categories rather than bands: it matches LTN 1/20 guidance:

image

Source: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/951074/cycle-infrastructure-design-ltn-1-20.pdf?#page=33

@dabreegster
Copy link
Contributor

First to answer the question of what's in OSM: try out https://overpass-turbo.eu/s/1v80. You can zoom anywhere and use a query like this: maxspeed=* and railway!=* and maxspeed != "20 mph" and maxspeed != "30 mph" and maxspeed != "40 mph"
I spot some random values < 20 mph, like 5, 12, 10, etc.

I agree that matching categories in guidance like LTN 120 is a good idea. So from the chart and observations about lower values, how about: <= 20, 30, 40, >=50?

@dabreegster
Copy link
Contributor

From my own intuition / experience as a cyclist and pedestrian, if I'm anywhere near 50mph traffic, 60 or 70 or 80 is just as bad. 50 is already way too scary. So the LTN 120 categories match my opinion there.

@robinlovelace-ate
Copy link
Contributor Author

So from the chart and observations about lower values, how about: <= 20, 30, 40, >=50?

Sounds reasonable but, due to the fact that we want to highlight places (often off the road network) that have below 20 mph limits I would suggest a "Less than 20 mph" category as James did for OpenInfra. Labels are important also, some people do not get inequality symbols. So I suggest:

@robinlovelace-ate
Copy link
Contributor Author

  • Less than 20 mph
  • 20 mph
  • 30 mph
  • 40 mph
  • 50+ mph

@robinlovelace-ate
Copy link
Contributor Author

Will update the original post.

@dabreegster
Copy link
Contributor

A quick review of the openinfra code: https://github.com/udsleeds/openinfra/blob/3d2666d568a1ee50fb4fd7bf469b00d1f9398802/R/oi_clean_maxspeed_uk.R#L48 looks concerning. If the input is the raw string maxspeed from OSM, then a string like "30" means 30km, not mph. "30 mph" will be tagged explicitly.

The rules it has about inferring untagged values look like a special case of something like https://github.com/westnordost/osm-legal-default-speeds. If we want to do something about the untagged data in the first cut, we can use a simpler UK-specific heuristic, instead of trying to integrate with this library in the next ~week.

@robinlovelace-ate
Copy link
Contributor Author

Yes simple rules can capture 90%+ of speed limits in most places so +1 to that. We can refine later but getting the majority of roads in a first pass sounds good to me. Any improvements on OpenInfra welcome, sharing in hope it's useful, not suggesting it's in any way complete or the last word on this.

@robinlovelace-ate
Copy link
Contributor Author

a string like "30" means 30km, not mph

It may mean that to people writing OSM wikis but does it mean that to the OSM newcomer who is trying to tag a 30 mph road for the first time?

@dabreegster
Copy link
Contributor

It may mean that to people writing OSM wikis but does it mean that to the OSM newcomer who is trying to tag a 30 mph road for the first time?

It might depend on the country. StreetComplete would show units clearly. Even iD autocomplete makes it pretty clear the " mph" suffix is there:
Screenshot from 2023-05-19 10-44-48
As an OSM data consumer, following the Wiki is generally good. I don't treat 30 as ambiguously mph or kmph; I treat it how the wiki says, because it's a well-established tagging schema. The issue of detecting mistaken edits is independent.

@robinlovelace-ate
Copy link
Contributor Author

OK but from memory there are quite a few erroneous "30" values in OSM for UK. We could set those to NA. Will be country specific for sure and my understanding, based on memories from OpenInfra project and conversations with @hulsiejames, who spent a fair amount of time looking at this, is that the vast majority of 30s should be switched to 30 mph.

Is there a way to do that in bulk? I see three main options and it's worth thinking about pros and cons of each:

  • Assume that 30 in UK means 30 kph
  • Assume that 30 in UK means 30 mph
  • Make no assumption and mark roads as speed limit unknown
  • Fix OSM data upstream (not sure if that is an option near term)

There may well be other options. Thoughts?

@hulsiejames
Copy link

hulsiejames commented May 19, 2023

A quick review of the openinfra code: https://github.com/udsleeds/openinfra/blob/3d2666d568a1ee50fb4fd7bf469b00d1f9398802/R/oi_clean_maxspeed_uk.R#L48 looks concerning. If the input is the raw string maxspeed from OSM, then a string like "30" means 30km, not mph. "30 mph" will be tagged explicitly.

The rules it has about inferring untagged values look like a special case of something like https://github.com/westnordost/osm-legal-default-speeds. If we want to do something about the untagged data in the first cut, we can use a simpler UK-specific heuristic, instead of trying to integrate with this library in the next ~week.

Hi guys, happy to see some Openinfra being potentially useful as a start!

This is an issue I thought whilst working on this. With a focus on UK infrastructure (whilst I was working on this).

Here, I have made the assumption that if a user is trying to contribute OSM data, it's likely to be in the units of that countries speed limit (i.e. I wouldn't enter mph speed limits for European roads if mapping). I was considering adding some sort of spatial check for the infrastructure in question, attempting to locate the country it belongs to and infer units that way, but have been bogged down with TfN stuff.

Though, as mentioned by Dustin, as an OSM data consumer following the wiki is a good idea given it is likely the best established tagging schema for OSM, and if a user has entered a speed tag incorrectly, could other parts of that contribution also be incorrect?


based on memories from OpenInfra project and conversations with @hulsiejames, who spent a fair amount of time looking at this, is that the vast majority of 30s should be switched to 30 mph.

I believe this was the case which lead me to implement the change from 30 --> 30 mph (for UK analysis at least), though I will try and find my old notes.

@robinlovelace-ate
Copy link
Contributor Author

An advantage of setting speed limit to NA for "30": it could encourage people to fix the data upstream. Especially if there is a hyperlink to the relevant way in OSM.

@dabreegster
Copy link
Contributor

Here's a random example of maxspeed=30 found with Overpass that's probably an error: https://www.openstreetmap.org/way/50317728. Directly adjacent, it's correctly tagged 30 mph: https://www.openstreetmap.org/way/106581320

I would vote in the short term to treating anything outside the explicit categories defined as an error. In the ATIP layer, we can just omit it and act like it's missing data.

@robinlovelace-ate
Copy link
Contributor Author

I would vote in the short term to treating anything outside the explicit categories defined as an error. In the ATIP layer, we can just omit it and act like it's missing data.

Fine by me and encourages improvements to OSM.

Easy to add links to OSM ways in osm.org as bikedata does? Would be good to encourage people to look at and improve the raw OSM data. That's another issue though I think, albeit related.

@dabreegster
Copy link
Contributor

Easy to add links to OSM ways in osm.org as bikedata does?

We can, but that's a UX question how, and adding the links would increase user-visible complexity, something I thought we were trying to minimize in #169. Should they be a more persistent tooltip when hovering on a road? Do we need to explain anything to people about how to edit OSM? I think for now, we should leave this alone, and come back to the question of having an ATIP mode specialized for helping people fix upstream OSM data. That's well out-of-scope for v2.

@robinlovelace-ate
Copy link
Contributor Author

Agreed. Will open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants