Opened 12 years ago
Last modified 3 years ago
#2192 new enhancement
Add tolerance parameter to ST_Split for splitting lines by points
Reported by: | michischolz | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS Fund Me |
Component: | postgis | Version: | 2.0.x |
Keywords: | st_split, tolerance, gsoc | Cc: |
Description
Heho. ST_Split does not work well when splitting a line by a point. Consider the following example where the line is not split even though the blade is supposed to be a point on the line:
SELECT ST_AsText((ST_Dump(ST_Split(lin.geom, ST_Line_Interpolate_Point(lin.geom, 0.5)))).geom) AS geom FROM (SELECT ST_GeomFromText('LINESTRING(604630.408 5792499.778,604623.849 5792500.886)') AS geom) AS lin
For the case of a line split by a point some kind of tolerance parameter would help. Until now I it is necessary first to ST_Snap your line to that interpolated point before splitting it by the point, which is not straightforward (thanks to strk for this hint). At least you could mention this hint in the documentation.
Attachments (1)
Change History (9)
comment:1 by , 12 years ago
Component: | postgis → documentation |
---|---|
Owner: | changed from | to
comment:2 by , 12 years ago
Component: | documentation → postgis |
---|---|
Milestone: | PostGIS 2.0.3 → PostGIS 2.1.0 |
Owner: | changed from | to
by , 12 years ago
Attachment: | reference_processing.xml.patch added |
---|
Patch of documentation for ST_Split
comment:3 by , 12 years ago
Keywords: | gsoc added |
---|
Okay incorporated the doco patch for 2.0 at r11251 and 2.1 at r11252
adding feature to google summer of code candidate list. http://trac.osgeo.org/postgis/wiki/GoogleSummerCode
comment:4 by , 12 years ago
Milestone: | PostGIS 2.1.0 → PostGIS 2.2.0 |
---|
comment:5 by , 10 years ago
Milestone: | PostGIS 2.2.0 → PostGIS Future |
---|
comment:6 by , 8 years ago
I ran into this problem and this ticket showed up on Google. I was a bit confused trying to use ST_Snap as hinted at above. It took me a while to understand that I needed to snap the line to the point instead of the opposite. I am adding this comment to help others.
Here is my query:
SELECT ST_AsText( ST_LineInterpolatePoint(the_geom, 0.5) ) AS the_point_geom, ST_AsText( (ST_Dump( ST_Split( ST_Snap( the_geom, ST_LineInterpolatePoint(the_geom, 0.5), 0.00000001 ), ST_LineInterpolatePoint(the_geom, 0.5) ) )).geom ) AS the_new_line_geom FROM _rt_geom_streets_base WHERE id = 2085426
comment:8 by , 3 years ago
FYI, a simple implementation of this feature is:
CREATE OR REPLACE FUNCTION ST_Split(geom1 geometry, geom2 geometry, double precision) RETURNS geometry AS 'SELECT ST_Split(ST_Snap($1, $2, $3), $2)' LANGUAGE sql IMMUTABLE STRICT COST 10;
However, it's not ideal:
SELECT ST_AsText(ST_Split('LINESTRING(0 0, 2 0)', 'MULTIPOINT(0 0, 1 0.0001)', 0.001)); -- Returns: GEOMETRYCOLLECTION(LINESTRING(1 0.0001,2 0),LINESTRING(0 0,1 0.0001)) -- Expected: GEOMETRYCOLLECTION(LINESTRING(1 0,2 0),LINESTRING(0 0,1 0))
Ideally the C-level logic would use lwgeom_snap
and lwline_interpolate_points
to handle a third tolerance
parameter.
New parameter requires minor version upgrade. michischolz: a patch for documentation is welcome