<div dir="ltr"><div>Thanks Marcin,</div><div><br></div><div>How do I actually put that into a GIS layer in order to review it?</div><div><br></div><div>Thanks<br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Le gach dea ghui,<br></div><div><span style="color:rgb(61,133,198)"><b><span style="background-color:rgb(255,255,255)"><i>Shane Carey</i></span></b></span></div><div><span style="color:rgb(61,133,198)"><b><span style="background-color:rgb(255,255,255)"><i>GIS and Data Solutions Consultant</i></span></b></span><br></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Oct 5, 2018 at 10:28 AM Marcin Mionskowski <<a href="mailto:mionskowskimarcin@gmail.com">mionskowskimarcin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In your original mail the image didn't attach as Darafei wrote. Because of that i think that you should tell us how you need the split to be done.<br>
Can it be done in "custom" direction, or you need it to be "perpendicular to the river"?<br>
1) If 1st - I would suggest to simply intersect your polygons with generated lines (see code below).<br>
2) If 2nd, then how you want this perpendicularity to be defined?<br>
Is it supposed to be perpendicular to the river axis/side? How the right axis/side should be determined? Can you draw a line "by hand" or does it have to be calculated? Do you realize that lines generated this way, can and probably will intersect?<br>
<br>
Take a look at SQL below. It's little long, but also clear (in my opinion), and it shows my approach step by step.<br>
<br>
WITH<br>
floodplain AS (<br>
        SELECT ST_SetSRID(ST_MakePolygon(<br>
                ST_GeomFromText('LINESTRING(100000 100000,100004 100000,100004 100004,100000 100004,100000 100000)'),<br>
                        ARRAY[ST_GeomFromText('LINESTRING(100002 100002,100002 100003,100003 100003,100003 100002,100002 100002)')]<br>
                        ),3035) geom<br>
        )<br>
, river AS (<br>
        SELECT ST_SetSRID(ST_MakePolygon(<br>
                ST_GeomFromText('LINESTRING(100001 100000,100003 100000,100000 100003,100000 100002,100001 100000)')<br>
                ),3035) geom<br>
        )<br>
, min_max AS ( --I assume that floodplain polygon covers river polygon (<a href="https://postgis.net/docs/ST_Covers.html" rel="noreferrer" target="_blank">https://postgis.net/docs/ST_Covers.html</a>).<br>
        SELECT ST_XMin(geom) xmin<br>
                , ST_XMax(geom) xmax<br>
                , ST_YMin(geom) ymin<br>
                , ST_YMax(geom) ymax<br>
        FROM floodplain<br>
        )<br>
, gs AS (<br>
        SELECT generate_series(ymin::INT,ymax::INT,1) gs --last parameter is not required, change 1 to 0.5 for "better looking" numeric results in my example<br>
        FROM min_max<br>
        )<br>
, splitlines AS (<br>
        SELECT ST_SetSRID(ST_MakeLine(ST_MakePoint(xmin, gs), ST_MakePoint(xmax, gs)),3035) geom<br>
        FROM gs<br>
                , min_max<br>
        )<br>
SELECT ST_Length(ST_Intersection(r.geom,s.geom)) river_width<br>
        ,ST_Length(ST_Intersection(f.geom,s.geom)) floodplain_width<br>
        ,ST_Length(ST_Intersection(r.geom,s.geom))/ST_Length(ST_Intersection(f.geom,s.geom)) river_floodplain_ratio<br>
 FROM floodplain f<br>
        , river r<br>
        , splitlines s<br>
<br>
Greetings,<br>
Marcin<br>
<br>
On Wed, 03 Oct 2018 15:18:19 +0200, Shane Carey <<a href="mailto:careyshan@gmail.com" target="_blank">careyshan@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> Just wondering  did anyone have a chance to look at my issue with regards<br>
> the river and polygon dataset that I was trying to split up?<br>
><br>
> Thanks<br>
><br>
> Le gach dea ghui,<br>
> *Shane Carey*</blockquote></div>