I'm trying to create double-sided buffers along road segments by making a buffer and then cutting the buffer with the road segment with ST_Split()
Almost there, but for some reason not all polygons get cut: (The red lines are the original road network.)
All of the ones that don't work seem to have those little 'artifacts' from the buffer (lower corner of the polygon), where the buffer intersects itself.
My queries:
CREATE TABLE vaxholm AS
SELECT vl.gid, vl.rlid, ak.kommunnamn, ak.lansnamn, vl.geom
FROM vagnet AS vl, ak_riks AS ak
WHERE ST_within(vl.geom, ak.geom) AND ak.kommunnamn = 'Vaxholm';
CREATE TABLE buffer AS
SELECT gid, rlid, kommunnamn, lansnamn, ST_buffer(geom, 15, 'endcap=flat join=mitre quad_segs=2') AS geom
FROM vaxholm;
CREATE TABLE split AS
SELECT vl.gid as gid,
vl.rlid as rlid,
vl.kommunnamn as kommunnamn,
vl.lansnamn as lansnamn,
ST_split(buffer.geom, ST_linemerge(vl.geom)) as geom_collection
FROM vaxholm as vl, buffer
WHERE vl.gid = buffer.gid;
SELECT (ST_dump(geom_collection)).geom as geom, gid, rlid
FROM split;
My system:
OS: Windows 10
PostgreSQL: 9.6.2
PostGIS: 2.3.2