1

All the answers were for one point and one line, But I'm talking about one point and multiple lines, and for older versions of QGIS.

I have two shapefiles including one point layer and multiple lines layer about 5000 lines shapefile.

Does anybody know a solution to this?

I'm not familiar with PyQGIS and Python and I have "QGIS 3.0.1 Girona".

  • have a look at hub and spokes tool in processing toolbox – csk Jul 13 '18 at 19:51
0

If your target point has a unique id field, and the id of the said point is 1 (for example), it can be referenced by get_feature('point', 'id', '1') from the other layer.

So, open the attribute table of your line layer, start the Field Calculator, and create a new numeric field by:

distance($geometry, geometry(get_feature('point', 'id', '1'))) 

Then it will return distance from the point (id=1) to each line.

  • I have done what you said exactly. A new field that I named it dist, has been added but no distance were calculated. Though I pushed update all botton but an error occured: "An error occured while evaluating the calculation string : No root node! Parsing faild? – Nima Dolatabadi Jul 14 '18 at 13:54
  • @NimaDolatabadi Can you see Field calculator button? Pushing update all button doesn't sound like you are doing it as I have described... – Kazuhito Jul 14 '18 at 14:46
  • I have done exactly what you said. I did use the update all on my own to check if it would make amy difference at all. Without it. Just new field is made but no distances are calculated – Nima Dolatabadi Jul 14 '18 at 14:56
  • @NimaDolatabadi Ccould you add the layer name of point layer, id field name and the id you used for the calculation, along with the expression you gave? – Kazuhito Jul 14 '18 at 15:38
  • I went through a mistake. All you said was true. Distances are calculated properly. Best Regards. – Nima Dolatabadi Jul 14 '18 at 15:57

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.