I have about 350k of vector points that represent parking spaces, I need these points to be converted to lines and connected to the nearest point available.

I've tried the point2one plugin, but connects parking points that aren't relevant to each other, and I've tried doing a nearest neighbor analysis in GRASS, but the data is to large and just crashes the program.

any suggestions?

  • 1
    Can you add a diagram of what you mean by "points to be converted to lines and connected to the nearest point available"? Nov 17, 2015 at 19:30
  • This sounds less like 'converting' points to lines and more like just connecting two sets of points with lines. Actually, this sounds like a spider diagram. You might start by looking at gis.stackexchange.com/questions/2823 and its Related questions on the right side of the page.
    – Chris W
    Nov 17, 2015 at 20:31
  • My apologies, yes essentially I'm basically connecting two sets of points, but when I tried with the point2one it created lines connecting to just random points, I need the lines to connect to the next corresponding parking points on it's path if that makes sense? -Again my apologies, don't use this much. Nov 19, 2015 at 16:57
  • A graphic or screenshot edited into your question may help here. I thought you were talking about something like tying parking points to an assigned central pay station point or something. From your comment it looks more like you're trying to create some sort of route to go from one parking point to the next like someone doing meter inspections or something, which is a completely different problem. In one case you need common attributes to establish a relationship between the two point sets. In the other you need some kind of ordering attribute to establish sequence.
    – Chris W
    Nov 20, 2015 at 18:00

1 Answer 1


To find the nearest neighbour use PostGIS <#>/<-> operator. Upload your point data to PostGIS. Create spatial index for points. Use the following sql query (I used data from OSGeoLive 9 osm_local database)

SELECT a.osm_id, ( SELECT b.osm_id FROM planet_osm_point b ORDER BY a.way <#> b.way LIMIT 1) FROM planet_osm_point a;

I tested it on a table of 10k points, running 1.3 sec. Replace osm_id to the primary key of your table and planet_osm_point to your point table.

  • nice this is something that ive been looking for, the only issue is i have 2 layer that have no attributes associated with each other, so is there like a way it will still just grab the nearest object (being the road will take on the points), also how the heck do i add a picture in here so i may show you. Dec 3, 2015 at 1:34
  • There is no need for attribute join. The <#> operator calculates the distance. If you have two layers simply substitute one for planet_osm_point a and the other for planet_osm_point b.
    – Zoltan
    Dec 4, 2015 at 0:08

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