Thursday 19 November 2015

qgis - Selecting the interior of line type data in PostGIS


I have asked about exporting geometry as a table (Link) and I got a very nice answer about how to do it with an SQL instruction.


Is there a way to select only the inerior of line type data? i.e. only the vertex that are not the ends. enter image description here


The following instruction will produce all vertex


SELECT sub.name AS "Pipe",

ST_X(sub.geom) AS "X-Coord",
ST_Y(sub.geom) AS "Y-Coord"
FROM (
SELECT name,
(ST_DumpPoints(geom)).geom AS geom
FROM conduits
) AS sub

Here is the output:


'1570','4978.95','2421.05'

'1570','2494.74','2421.05'
'1600','2494.74','2421.05'
'1600','2494.74','7536.84'
'1602','4957.89','7536.84'
'1602','2494.74','7536.84'
'8040','8115.79','3450.84'
'8040','9107.73','4350.80'
'8040','7463.16','7536.84'

I would like to get only:



'8040','9107.73','4350.80'

Answer



Dimensionally Extended 9 Intersection Model (DE-9IM)


So far, it works for the example.


SELECT subpoints.name AS "Pipe",
ST_X(subpoints.geom) AS "X-Coord",
ST_Y(subpoints.geom) AS "Y-Coord"
FROM (SELECT name,
(ST_DumpPoints(geom)).geom AS geom
FROM conduits

) AS subpoints,
(SELECT name,
geom AS geom
FROM conduits
) AS sublines
WHERE subpoints.name=sublines.name
AND ST_Relate(subpoints.geom, sublines.geom, '0FF******')

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...