I have a PostGIS
workflow that has a line file that has been buffered then subdivided and a vectorized raster called myvector. My intention is to split or separate myvector based on the bounds of the subdivided buffer. This is relatively similar to another question, but their problem seems to be different. The process is easy in QGIS using the vector overlay tool called split with lines. I found a tutorial about doing overlay work in PostGIS
but it is for one polygon with overlap and I have multiple tables.
Below is the code and a picture of an attempt I made using PostGIS
.
CREATE TABLE add_at.u0_low_dn1 AS
SELECT
den.geom AS geom
FROM add_at.u0_den_dumped AS den
WHERE den.dn = 1;
SELECT ST_GeometryType(ug.geom)
FROM add_at.u0_low_dn1 AS ug;
CREATE TABLE pt2.box_ext AS
SELECT
ROW_NUMBER () OVER() AS rid,
ST_ExteriorRing((ST_Dump(boxes.geom)).geom) AS geom
FROM pt2.boxes AS boxes;
--check geometry type of output, expected is ST_LineString
--SELECT ST_GeometryType(ug.geom)
--FROM pt2.box_ext AS ug;
CREATE TABLE pt2333.u0_dn1_split_new7 AS
SELECT
ROW_NUMBER () OVER(),
(ST_Dump(ST_Split(u0dn1.geom, bounds.geom))).geom AS geom
FROM
add_at.u0_low_dn1 AS u0dn1,
pt2.box_ext AS bounds;
SELECT ST_GeometryType(split.geom)
FROM pt2333.u0_dn1_split_new7 AS split;
--for whatever reason it is not actually splitting it...
My approach seems relatively similar to the tutorial from Paul Ramsey about PostGIS
overlays so I cannot tell why it isn't working.
Alternatively the process in QGIS works well using the vector overlay called Split with lines. Note on the image below the little box at the boundary has been split into two separate boxes.