Skip to main content
added 1 character in body
Source Link
jpinilla
  • 3.2k
  • 1
  • 15
  • 27

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named "cluster_id".

You can create a "Virtual layer" through Layer > AddCreate Layer > Add/EditCreate Virtual Layer with the following code:

SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware the CRS of both layers, which should be the same and with projected coordinates, so the rendered results are in meters.

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named "cluster_id".

You can create a "Virtual layer" through Layer > Add Layer > Add/Edit Virtual Layer with the following code:

SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware the CRS of both layers, which should be the same and with projected coordinates, so the rendered results are in meters.

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named "cluster_id".

You can create a "Virtual layer" through Layer > Create Layer > Create Virtual Layer with the following code:

SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware the CRS of both layers, which should be the same and with projected coordinates, so the rendered results are in meters.

deleted 3 characters in body
Source Link
jpinilla
  • 3.2k
  • 1
  • 15
  • 27

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named "cluster_id".

You can create a "Virtual layer" through Layer > Add Layer > Add/Edit Virtual Layer with the following code:

SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware of the CRS of both layers, which should be the same and with projected coordinates, so the rendered results are in meters.

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named "cluster_id".

You can create a "Virtual layer" through Layer > Add Layer > Add/Edit Virtual Layer with the following code:

SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware of the CRS of both layers, which should be the same and with projected coordinates, so the rendered results are in meters.

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named "cluster_id".

You can create a "Virtual layer" through Layer > Add Layer > Add/Edit Virtual Layer with the following code:

SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware the CRS of both layers, which should be the same and with projected coordinates, so the rendered results are in meters.

added 216 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named cluster_id"cluster_id".

You can create a virtual layer"Virtual layer" through Layer > Add Layer > Add/Edit Virtual Layer with the following code:

SELECT p.cluster_id, avg(st_distance(c.geometry, p.geometry))
FROM Center_points p, Clusters c
WHERE p.cluster_id = c.cluster_id
GROUP BY p.cluster_id;
SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware of the CRS of both layers, thatwhich should be the same and with projected coordinates, so the rendered results are in meters.

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named cluster_id.

You can create a virtual layer with the following code:

SELECT p.cluster_id, avg(st_distance(c.geometry, p.geometry))
FROM Center_points p, Clusters c
WHERE p.cluster_id = c.cluster_id
GROUP BY p.cluster_id;

Anyway, beware of the CRS of both layers, that should be the same and with projected coordinates, so the rendered results are in meters.

Assuming that you've got two layers:

  1. Clusters, that holds all your points, each one identified as belonging to a specific cluster by means of an attribute named cluster_id;
  2. Center_points with as many points as clusters you've created, and each of them representing the mean coordinates of the cluster, again identified by means of an attribute named "cluster_id".

You can create a "Virtual layer" through Layer > Add Layer > Add/Edit Virtual Layer with the following code:

SELECT
    p.cluster_id,
    avg(st_distance(c.geometry, p.geometry))
FROM
    Center_points p,
    Clusters c
WHERE
    p.cluster_id = c.cluster_id
GROUP BY
    p.cluster_id;

Anyway, beware of the CRS of both layers, which should be the same and with projected coordinates, so the rendered results are in meters.

added 140 characters in body
Source Link
jpinilla
  • 3.2k
  • 1
  • 15
  • 27
Loading
added 6 characters in body
Source Link
jpinilla
  • 3.2k
  • 1
  • 15
  • 27
Loading
Source Link
jpinilla
  • 3.2k
  • 1
  • 15
  • 27
Loading