I am using QGIS 3.18. I have two shapefiles. A point layer representing tree positions ("tree_pt") and a building layer representing a building ("building") containing multiple lines. I wish to compute the minimum distance between the trees and the building.
I can do this in other packages, e.g. Manifold GIS, but cannot get the SQL working in QGIS.
My SQL statement is as follows (for simplicity this is not yet aggregated to the minimum distance, so I know I will get multiple results per tree point) :
SELECT "tree_pt"."num", ST_Distance("tree_pt"."geometry", "building"."geometry")
FROM "tree_pt", "building"
GROUP BY "tree_pt"."num"
The error I am receiving is
Query preparation error on SELECT "ST_Distance("tree_pt"."geometry", "building"."geometry")" FROM _tview LIMIT 1: near ""."": syntax error
Although the input files are shapefiles, I believe that I should still be able to use the ST_Distance() function.
How can I correct my SQL?
"
when prepared as the meta data query. I would assume this is an internal string literal conversion/escaping issue - a bug - but it should help to avoid SQL identifier escaping, i.e. omit all the"
- this particular query doesn't require them). It does need an aggregation expression, though, to satisfy theGROUP BY
.