2

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... 

picture of myvector not split from PostGIS work

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.

enter image description here

4
  • 2
    Can you turn box_ext into a multilinestring (collect all lines) and try again? Commented Apr 27, 2022 at 6:26
  • 1
    Why is it more complicated than an intersection between a polygonal buffers table and a vectorized table (myvector)? Commented Apr 27, 2022 at 12:33
  • 1
    You are doing a cross join between the two layers, so it is expected to get multiple copies of the polygons, with 2 of them being actually split (1 for each intersecting polygon). One option is as Timothy suggests, i.e. to aggregate all blades into a single one.
    – JGH
    Commented Apr 27, 2022 at 13:30
  • presumably your two EPSG are the same? In PGAdmin, with the table selected go to SQL and see the value on the geom column.
    – BJW
    Commented Apr 30, 2022 at 10:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.