3

In QGIS 2.16.3, I have a series of bus routes (with different attributes), all in the same shapefile. For simplicity, they all run every 30 minutes. They often share sections of route - for example, bus #1 and #2 use the same road out of the city centre. On this section, therefore, buses run every 15 minutes.

I want to select these roads where two or more buses run (i.e. where lines in the same shapefile intersect). Along roads with two or more buses, the lines overlap perfectly.

The best I've got so far is to reduce transparency, so that roads with more than one bus appear darker than those without - but it isn't what I'm looking for.

  • 1
    What are you going to do when you've selected them? First you might have to break your features up since QGIS can only select whole features, so if you have each bus route as one feature and one starts on its own, uses the same location as another route, then heads off, you'll have to make that into three features at those locations. Have you tried the overlay functions? Can you supply a simple example dataset that's like your data to play with? – Spacedman Jan 12 '17 at 19:17
  • @Spacedman I've got two shapefiles - one with 15 minute services, one with 30 minute services. I'm planning on creating a new shapefile for roads with 2+ 30 minute services, and joining this onto the shapefile with 15 minute services. I'll then buffer each shapefile (15 mins and 30 mins), to estimate the population living within 250m of each type of service. I've thought about splitting, but there are too many buses that intersect too many times to make it worthwhile. Here's a link to my data: dropbox.com/s/v2bszy10m1zmzro/ManchesterBusRoutes.zip?dl=0. – russsmith Jan 12 '17 at 20:42
5

Had a shot at this using your data set.

  • as SpacedMan suggested, you need to split your layers into segments. I used GRASS's v.split.vert from Processing, with a max vertices value of 2. That breaks each portion of the bus route into a series of single segments between each pair of vertices

  • run a Intersection on the two split-apart line layers. (This can take a while)

  • the bold white lines have two or more routes going along each road segment.

enter image description here

Looking more closely, I can see some shared route segments are not showing up, so it needs a bit of work :/

I suspect some points may not be in exactly the same place in both layers. It could be rounding errors between node positions. They might look like they align perfectly by eye, even zoomed in, but that's not enough if they only agree to the first 10 decimal places :)

You might be able to fix that by saving your layers to GeoJSON using a lower precision (the default of 15 is way too high) and reimporting them. Not tried this, though.

  • Brilliant, cheers, got it working nicely now! The original dataset had inbound and outbound routes - I chose just inbound for all, so I imagine some directions were the wrong way around. Went and manually selected the direction for each service so all lines matched perfectly. – russsmith Jan 13 '17 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.