Skip to main content
added 2 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

I think that it might be easiest to do with ST_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well.

Here is an example with Spatialite.

SELECT
    shortestline(a.geometry,b.geometry) AS geometry, 
    a.rowid AS start,
    b.rowid AS end 
FROM
    source_table a,
    source_table b 
WHERE
    a.rowid<browid < b.rowid;

enter image description here

I think that it might be easiest to do with ST_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well.

Here is an example with Spatialite.

SELECT
    shortestline(a.geometry,b.geometry) AS geometry, 
    a.rowid AS start,
    b.rowid AS end 
FROM
    source_table a,
    source_table b 
WHERE
    a.rowid<b.rowid;

enter image description here

I think that it might be easiest to do with ST_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well.

Here is an example with Spatialite.

SELECT
    shortestline(a.geometry,b.geometry) AS geometry, 
    a.rowid AS start,
    b.rowid AS end 
FROM
    source_table a,
    source_table b 
WHERE
    a.rowid < b.rowid;

enter image description here

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

I think that it might be easiest to do with St_ShortestLineST_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLineShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well. Here

Here is an example with Spatialite.

SELECT shortestline(a.geometry,b.geometry) AS geometry, 
a.rowid AS start, b.rowid AS end 
FROM source_table a, source_table b 
WHERE a.rowid<b.rowid;
SELECT
    shortestline(a.geometry,b.geometry) AS geometry, 
    a.rowid AS start,
    b.rowid AS end 
FROM
    source_table a,
    source_table b 
WHERE
    a.rowid<b.rowid;

enter image description here

I think that it might be easiest to do with St_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well. Here is an example with Spatialite.

SELECT shortestline(a.geometry,b.geometry) AS geometry, 
a.rowid AS start, b.rowid AS end 
FROM source_table a, source_table b 
WHERE a.rowid<b.rowid;

enter image description here

I think that it might be easiest to do with ST_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well.

Here is an example with Spatialite.

SELECT
    shortestline(a.geometry,b.geometry) AS geometry, 
    a.rowid AS start,
    b.rowid AS end 
FROM
    source_table a,
    source_table b 
WHERE
    a.rowid<b.rowid;

enter image description here

Source Link
user30184
  • 69k
  • 4
  • 71
  • 125

I think that it might be easiest to do with St_ShortestLine with PostGIS http://postgis.net/docs/ST_ShortestLine.html or with a similar ShortestLine function in Spatialite https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html.

You said you have only points but those functions can be used for other geometries as well. Here is an example with Spatialite.

SELECT shortestline(a.geometry,b.geometry) AS geometry, 
a.rowid AS start, b.rowid AS end 
FROM source_table a, source_table b 
WHERE a.rowid<b.rowid;

enter image description here