# How can I get the set of points (cloud) that are a given distance in SpatiaLite?

I have a set of points and need to get the groups of points that are within a distance x. Ie, determining the point clouds that are up to the distance x from each other.

Any help would be appreciated. Thanks.

Example of a table with coordinates (in EPSG:4674)

The extension of the data is variable. Will be implemented in several counties, separately.

I need anything like this:

And I need make this in SQL from SpatiaLite. I can make this using buffer and union but I get just one polygon because I don´t have a "group by" attribute, and I need polygons separately for each group.

I´ve been trying this:

``````CREATE TABLE "T_bufEndR" AS
SELECT "PK_UID" as "ID_end",
ST_BUFFER(geom_ce, 0.00025) AS "geom_bu"
FROM "T_CoordEnd"
WHERE "situacao" IN (4, 5, 6, 7, 8)
``````

and

``````CREATE TABLE "T_unbufEndR" AS
SELECT ST_UNION(b.geom_bu, a.geom_bu) AS "geom_bu"
FROM "T_bufEndR" AS "b", "T_bufEndR" AS "a"
WHERE ST_OVERLAPS(b.geom_bu, a.geom_bu) = 1 AND
"b"."ROWID" IN (SELECT rowid from SpatialIndex
WHERE f_table_name = "t_bufendr" and
search_frame = "a"."geom_bu")
``````

Is that!

• Can you show the table schema and a little bit of your data (e.g. `SELECT * FROM <table_name> LIMIT 5`). Also please tell us the coordinate reference system you are using, and the extent (coverage area) of your data. Those can all affect the answer. – BradHards Apr 26 '14 at 0:33
• Hi @BradHards, I was edit the question for include information. Thanks! – Sassá Apr 28 '14 at 15:04
• A question on what you want - do you want to identify sets of points where any of the points are within X distance of each other, or where all of the points are within X distance of each other. So given 4 points (A, B, C and D) evenly spaced on a line, say at distance 2 from each other, what is the expected results if you ask for the cloud of size 3? Also, is it enough to only have the PK_UID in the result? – BradHards Apr 28 '14 at 22:30