1

I am using QGIS and I need to calculate the minimum distance from points to line. I have the points in .txt format and this is ok, but I have to extract the line from the raster file showed the following figure: enter image description here So I made "raster to vector" and I have this situation

enter image description here

The vector file contains, of course, a lot of id values. My purpose is to have only 1 id value, that is having only a line shapefile.

I tried also to convert the vector file in lines, but the output was the following: enter image description here

I would like to have only 1 line (like a "mean" line) which has only 1 attribute so that I can calculate the minimum distance from points.

Of course, if you know a different procedure to calculate the minimum distance between points and a raster, it is welcome.

1 Answer 1

1

I believe the GRASS GIS tool r.thin, available from the QGIS processing toolbox applies to your problem. Citing the GRASS manual it 'thins non-NULL cells that denote linear features into linear features having a single cell width.' After applying r.thin to your raster you can use r.to.vect specifying line as the feature type.

Both tools are available in the processing toolbox. Here are the GRASS manual pages: https://grass.osgeo.org/grass78/manuals/r.thin.html https://grass.osgeo.org/grass78/manuals/r.to.vect.html

If you end up with multiple line segments you can use v.clean with the snap option to snap lines to vertices within a specified threshold. This, and various other options for combining multiple lines are discussed here: How to merge lines with slightly different endpoints in QGIS?

Distance from points to the final vector line can then be found by use of v.distance, for example. This and some other options are given in answers to this question: Measuring the distance between lines and points in QGIS

1
  • Thanks for your help!
    – Serena
    Nov 15, 2019 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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