Saturday 25 February 2017

openstreetmap - Merging multiple bus stops with same name using QGIS?


My question is similar to Merging points (bus stops) in QGIS manually or programmatically?, but it's not answered sufficiently


I have OSM-transit data with bus stops. Some stops have two or more bays for different directions. In this example, the stop 'Steinerstraße' has two points: Steinerstraße has two points



I want to merge all points belonging to one stop to one point. I assume that they can be identified by an identical name in the 'name'-column of the attribute table.


Best case would be to create a new point in the middle of the points, however, I'd be satisfied with a simple deletion of the 2nd feature as well.


Can anyone give me a hint how to do it?


I've never used either python nor SQL in a GIS-environment and would prefer a GUI-based solution. However, I'm open for everything (some xp in python and SQL in other contexts).



Answer



Not an easy task, but this way it works for me:



  1. Load the point layer into QGIS (supposed to be in EPSG:900913, else reproject it to any projected CRS)

  2. make a copy of the layer

  3. Install the MMQGIS plugin


  4. From the Plugins menu, choose Create Hublines. Select your two layers, and the name attribute for both as ID.


After executing, all busstops with the same name are connected with lines. Unfortunately, the points are also connected to themselves, leading to lines of zero length. So:



  1. Select the hub layer and use Vector -> Geoprocessing -> Dissolve with the name field as Dissolve field, to a new file

  2. Use Vector -> Geoprocessing -> Buffer to create a buffer of 5 (meters) in a new layer

  3. Use Vector -> Geometry Tools -> Polygon centroids to create single points from the buffer polygons


As you can see, it works for single and multiple bus stops: enter image description here




  1. remove all previous layers


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...