# Find out if overlaying polyline matches polygon centerline in qgis

I have a polygon and a polyline and I need to find a scientific way of how close that polyline is to the actual polygon centerline. Is there any way of doing this in qgis? Any extensions, models, algorithms would be helpful!

• Calculate centerline of polygon and then calculate distance of each point to nearest point of the other polyline. Problem: Calculating Voronoi polygons in qgis is crashing on my machine.
• Buffer that polyline, substract from that area the given polygon to calculate the difference area. The smaller, the better. Problem: I have no attributes in that polygon to distinguish between classes and so thin roads will give a different result than broad roads.
• Do a negative buffer so that the area is actually really small and clip it with the polyline. Same problem as above.

• Related posts about centerlines here and here. There are mentions of a "ET GeoWizards" software. Otherwise, seems to be a difficult task... Commented Jan 17, 2016 at 14:38
• thats for arcgis, which I don't own, sadly.
– Revo
Commented Jan 17, 2016 at 19:48

Taking into account your trouble with vector solution I suggest using approximate raster based technique. I’ll use ArcGIS (no QGIS) but most likely there are same tools in QGIS

Dissolve your polygons and convert them to polylines. Calculate Euclidean distance to lines using small cell size. The smaller it is, the more accurate result can be achieved. Clip raster using original polygons:

Calculate slope of above raster and select 'flat' areas. In my example I used <=40 degrees:

From here there are multiple paths to follow. You might want to clip ‘flat’ areas raster using small negative buffer first.

1. Convert result to points
2. Place points at the regular interval on existing centrelines
3. Find distance to nearest flat point for each centreline point
4. Summarise distances per street segment.

Picture below shows regularly placed points labelled by their distance to nearest ‘flat’ point.

Expect trouble at intersection and very narrow streets

• Okay I was able to follow you until the slope calculation part. Seems like my street border has the same slope as the centerline. You can look at my results here, maybe you will see an error I've made: imgur.com/a/Gz5yw
– Revo
Commented Jan 25, 2016 at 8:48
• It's the same with my example. Either clip them out, or proceed with nearest Commented Jan 25, 2016 at 9:06