I would like to automatically create a vector of points.

The vector should be composed of one point per each line of a line vector (approx 3000 features). Those points should be placed near each line but not along them. The best result would happen if points were created in a direction perpendicular to each line, 1 meter far from each line.

In order to have an example, the following image shows the desired result: Example: points with green signs are okay, the point with red cross is not okay.


QGIS 3.0/3.2 - Geometry by expression tool in Processing Toolbox | Vector geometry

Select your line layer as input, point as output geometry type, and apply:

centroid(offset_curve($geometry, 1))
  • Thx, I cannot find the tool using QGIS 2.18...Do I have to install 3.0/3.2? – Giacomo Jul 11 '18 at 13:33
  • @Giacomo Please see added QGIS 2.18 part. – Kazuhito Jul 11 '18 at 13:38
  • Ok, copying the expression centroid(offset_curve($geometry, 1)) gives me the "expression is invalid" error due to the offset_curve function.. – Giacomo Jul 11 '18 at 14:57
  • @Giacomo I give up QGIS 2.18 case. Sorry. As QGIS 3.0/3.2 and QGIS 2.18 can run concurrently, your output from QGIS 3 can be brought back to QGIS 2.18 project. – Kazuhito Jul 11 '18 at 15:39

The method provided by Kazuhito is far more elegant, but in case you don't have access to QGIS 3.0/3.2, here are two methods for 2.18:

Create a 2 meter single-sided buffer with OGR > Single sided buffers (and offset lines) for lines tool (Processing Toolbox)

Use Polygon Centroids tool (Processing Toolbox) to create centroids of buffers.

Create a point on line layer using one of these tools from the Processing Toolbox:

  • QGIS > Random points along line
  • OGR > Create points along lines
  • GRASS > V.to.points

Select all features in point layer, use Move Feature(s) tool (editing toolbar) to move them.

Check the results of either method by using Spatial Query to select features of the points layer that intersect features in the lines layer.

Use the Move Feature(s) tool to move them away from the lines they intersect.

  • Great, thanks @csk This issue has been bothering my head all day today. – Kazuhito Jul 12 '18 at 10:35

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.