# Automatically adding vertices to lines every x meters using QGIS?

I've made a vector grid using lines; the grid coverage is 100 km x 100 km and the lines are at vertical and horizontal intervals of 1000 metres. Each line in the grid is defined by two vertices, one at each end, and each line has an ordinate attribute for labelling.

My wish is to to add vertices to the lines, so that each line will have vertices at intervals of (say) 500 metres. Does anyone know how to do this?

The background to this is that the grid will be displayed on OpenLayers and given the strangeness of Google Mercator the lines need to be pegged to the ground with vertices at frequent intervals. One other obvious use for the ability to add vertices to grid lines would also be to make nicely curved lat/lon graticules for projected maps.

• Hmmm. I see you've marked an accepted answer below, but it doesn't answer the question of adding 'vertices ... every x metres'. Densify adds n vertices per line. If you had a grid of equal-length lines you could do a one-off calculation and run densify to add (length / x) vertices, but what of a layer with variable length lines? Sep 30, 2012 at 11:35
• Well yes, but the answer made my problems go away. I understand your confusion, the original title of the question was simply 'Add vertices to lines'. N. Sep 30, 2012 at 12:19
• Reviewing the edit I see it's changed the meaning of the title! Apologies ... looking for a similar solution, may add a separate question. Sep 30, 2012 at 12:25

in Qgis 1.8.0 there is a densify function but i don't know if it has distance parameter like in Arcgis

A great plugin to achieve this is "Geodesic Densifier". It allows you to set the spacing (in metres) of the newly-created vertices. Tested with QGIS 3.26.3

If I understand you correctly, you want to add midpoints (as your example). I would:

• copy the grid layer
• move it by (500, 500)
• calculate the intersections
• find out how to split the original grid with them (a simple union?)

For any other fraction, the process would have to be repeated multiple times, so it is far from efficient. I would probably fallback to scripting PostGIS and its ST_Split functionality.

• Thanks for this. In the end I used 'densify' which worked very nicely. Nick. Jul 15, 2012 at 17:39
• Great, glad there is a simpler way. :) Jul 15, 2012 at 20:09