I need to select points that have attributes that are within a relative number range of each other. For instance; given the following numbers: 95,705,139,65,537,266,525 and 188; I need to find all of those numbers that are within a range of 50, 100 and 150 of each other. I then need to find those that are within a distance of each other. I am using QGIS. Any ideas gratfully accepted. Thanks.
I might add to Nicklas' well detailed answer: If you're looking to find points with the same table that are either a given distance from each other or have an attribute within a given value, then you can use the form:
Just work with the table twice using different aliases.
Since you have tagged the question "sql" I guess that sql is an option to solve this.
If I understand your question right, you want to find the 50 range case, 100 range case 150 range case in different queries?
There are other options for that but to look at the simplest first we do those assumptions:
In your table you have a geometry column for your points, we call it the_geom , an id column to identify the resulting records, we call id gid and a value column with the values you presented above, we call it the_value.
THen to make the 50 range query, with a fixed maximum distance of 100 (units of the projection you use) you can write query like this:
I wouldn't write any client code to get this. If it isn't huge tables it should be no problem to just create a view and use that in QGIS:
Another approach here could be to create a table that can keep ranges and distances. Then you can easily put range classes in your resulting view, and you can put different distances for different ranges for instance. This table is also the right place to put information about how to style the result in QGIS like size of markers.
First create the table:
Then you can create the view like this (here we make a two-point multipoint as result):
To get this running smooth you should put a gist-index on the point (the_geom) column and a btree index on the_value column.