4

I have two types of objects (i) polygons representing postcode areas, and (ii) points representing telephone exchanges.

I want to find the part of the polygon that is closest to the exchange and place a point there (see the red X in the image below). The green lines in the below image are fanning out from the exchange location.

So far I have followed this example and converted the polygons to lines, and then tried to join the attributes of the point and line layers by closest distance]3. However, using the MMQGIS Distance to Nearest Hub tool it calculated the distance to the polygon centroid.

And using NNJoin, it correctly calculated the distance between the red X and the exchange, but it did not insert a point in that location. Please see the below image for more context

How do I put a point or some kind of feature at the red X as an estimate of broadband cabinet location?

enter image description here

2

First convert the polygon to points:

Vector > Geometry Tools > Extract Nodes

Add this as a new layer, then calculate a distance matrix between your exchange point and the new polygon-points layer you just created:

Vector -> Analysis Tools -> Distance Matrix

Be sure to choose Use only the nearest (k) target points as 1

The output will be a csv file - take the points from your shortest distance and then use MMGIS > Create > Hub lines to join the two points

  • 1
    This won't necessarily give you the closest point. Imagine a rectangle centred a little above the point - the closest point in this case isn't a node from the rectangle. – ndawson Jan 4 '17 at 11:40
  • True but we're not dealing with a rectangle here – the_darkside Jan 4 '17 at 13:49
  • ndawson's comment is valid, and the rectangle is just an example that illustrates his point. His comment applies to any line segment that is a part of the polygon boundary, as long as the (exchange) point is closer to the line segment than to any of the line segment's two end points (and the line segment is a part of the polygon's convex hull). – Håvard Tveite Jun 26 '17 at 21:55

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.