I have a set of points with datatype as geometry(MultiPoint, 32643), I want each point to be converted in short line segments. The purpose of doing this is to use "split by lines" tool in QGIS which splits a line layer with another line layer.

The suggestion in one of the answer is as below, but I could not find the geometry by expression tool. Also, I tried to implement the below command in PostgreSQL but it didn't work.

Convert your points into short line segments with the geometry by expression tool.
Use an expression like this:

make_line($geometry, translate($geometry, 1, 1))
  • Better try with st_makeline, st_translate ... – snaileater Jun 6 '19 at 10:32
  • Yes, that worked – Swapnil Jun 6 '19 at 10:34

Tested on QGIS 2.18 and QGIS 3.4

I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume we have 10 features in "points" accordingly, see image below.


With the following Query, it is possible to convert each point into a short line segment. Mind the CRS.

SELECT p.id, make_line(p.geometry, translate(p.geometry,1,50))
FROM points AS p

The output Virtual Layer will generate short line segments including point's "id" where the initial point feature is the starting point of a line segment.



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.