I was searching for the shortest distance between a point (point layer with about 22000 points) and the nearest point of a line from another layer (MultiLineString). I tried Distance Matrix, nearest neighbour, distance to nearest hub. None with the expected result. But then I found something interesting on GIS SE, but only displaying the shortest line. (Find nearest line feature from point in QGIS by @babel) It goes:
make_line(
$geometry ,
closest_point(
geometry( get_feature_by_id ('bayern_25832gis_osm_waterways_free_1',
array_to_string( overlay_nearest ( 'bayern_25832gis_osm_waterways_free_1', "osm_id" )
)
)
),
$geometry ) )
It looked perfect, so I tried copying it in the field calculator by exchanging make_line
by 'distance' and voila.
Could it be thus simple?
I am just a biologist and have really no clue about expressions, their functions and so on.
How can I verify my results?
By now I only looked at the data, labeled the distances and measured by hand but cannot do this for 22.000 features.