5

I have two shapefiles in QGIS to which I am trying to find the distances between. I have a shoreline which is a vector line and then I have hundreds of data points in the ocean.

What I am trying to find is measuring the distance of each point to the corresponding place horizontally on the shoreline thus giving me a distance of each point from the shore. I have tried the distance matrix plugin which seems to only deal with point to point distances and have tried the mmqgis hub distance which only measures distances to a central fixed point on the line. Is there a plugin or way to find the distances I am looking for?

3 Answers 3

2

Try this: from the attribute table of your point file add a new field (real number) and use the following formula:

distance( $geometry , geometry ( get_feature( 'line-file','field',name-of-line))))

Were 'line-file' is the file where the line is stored, 'field' is a field in the line-file table, and name-of-line is the values of that field for your line. This formula gives only positive distance.

1

The most convenient way to my mind is to import your layers into a spatial database such as Spatialite or PostGIS and use ST_Distance() SQL-querry.

0

The NNJoin QGIS Plugin is what you are looking for. For each point, it finds the closest line. The resulting point layer will for each point contain the distance to the closest line and all of the attributes of that line.

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.