[postgis-users] Query to select dangling line segments
kneufeld.ca at gmail.com
Mon Nov 29 13:36:33 PST 2010
On 11/29/2010 11:54 AM, Brian Stempin wrote:
> I want to select rows who's geometry's start/end point does not
> intersect *anything*
Is your dataset fully noded (where the only intersection between
geometries occur at the endpoints)?
If so, you could perform a very quick GROUP BY query to find degree-1
nodes in your network.
SELECT min(osm_id), pt
SELECT osm_id, ST_StartPoint(way) AS pt
SELECT osm_id, ST_EndPoint(way) AS pt
) AS grouped
GROUP BY pt
HAVING count(*) = 1;
Note though, that this GROUP BY approach uses the bounding boxes of the
endpoints, *not* the geometries themselves. So for this to work, the
precision of your dataset must be less than what can be represented in
the float4 representation of the bounding box.
FROM ( VALUES
) AS foo
GROUP BY column1;
MULTIPOINT(0 0,0 1e-07)
See how the first and last points have the same bounding box though
As long as your data is fully noded and the precision is less than what
can be represented as a float4, then this approach works very fast (no
expensive spatial predicate operations)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the postgis-users