Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged


The trick is to create a function that access QGIS graphical interface, and that is piped to the query of the virtual layer. 1) Open a function editor (from anywhere, including from field calculator) and create a new function that reads the canvas extent and returns it as a geometry. from qgis.core import * from qgis.gui import * from qgis.utils import ...


Your problem is the data type as String. You are trying to use it like numerical value but in string the "number" order is "alphabetical" meaning that "2" for exemple come after 11 (or that 2 > 11 is evaluated as true...). If you sort your column in the attribute table you will see that all number starting by "1" are on top (like 1, 10, 1125,...) then ...


When comparing strings, the comparison is done character by character, so 2 is "bigger" - or rather "after" 12 (2 vs 1). You would need to change the datatype in your expression int("Benzene") >= 7 You might have to use CInt() instead of int()


Finally I managed to find the solution. The code that retrieves all the distances between every MultiLineString record in a table and a specific point: SELECT ST_Distance(geom, ST_SetSRID(ST_GeogFromText('POINT(25.3622 35.3621)'), 4326), true) FROM my_table And to retrieve the shortest distance between MultiLineString records and a Point: SELECT MIN(...


You are comparing each geometry to itself, and for [ST_]Within/[ST_]Contains, a geometry is a positive match for itself! You need to self-join the table to allow for comparisons between different rows of it: SELECT, COUNT( FROM <table> AS a JOIN <table> AS b ON ST_Within(b.geom, a.geom) AND <> GROUP ...

Only top voted, non community-wiki answers of a minimum length are eligible