<html><head></head><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1539982788132_373967"><span></span></div><div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1539982788132_373971" style="display: block;"> <div style="font-family: verdana, helvetica, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1539982788132_373970"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1539982788132_373969"> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1539982788132_374063"> <font id="yui_3_16_0_ym19_1_1539982788132_373972" size="2" face="Arial"> </font><br><div id="yiv6963858828"><div id="yui_3_16_0_ym19_1_1539982788132_374062"><div style="color:#000;background-color:#fff;font-family:verdana, helvetica, sans-serif;font-size:16px;" id="yui_3_16_0_ym19_1_1539982788132_374061"><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360330"><span>Off the top of my head...<br clear="none"></span></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360331"><span></span></div><div class="yiv6963858828qtdSeparateBR" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_359939"><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360332">That returns the longest straight line within a polygon. <br clear="none"></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360296"><br clear="none"></div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360294">I suggest your workflow is to create a target table first (with a column for the id of the polygon it came from), so you have somewhere to put the linestrings (not necessary, but I find it tidier).</div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360293"><br clear="none"></div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360262">eg:</div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360250"><br clear="none"></div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360165"><i id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360247">create table long_lines (id integer primary key), geom geometry(LINESTRING, <SRID>);</i></div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360167"><br clear="none"></div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360168">then run your query...</div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360189"><br clear="none"></div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360169"><i>INSERT INTO long_lines</i></div><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360333"><i id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360358">SELECT id, <br id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360230" clear="none"> ST_MakeLine(St_LongestLine(<br id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360231" clear="none"> (SELECT geom FROM floodplainw<br id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360232" clear="none"> WHERE id = 1),<br id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360233" clear="none"> (SELECT geom FROM floodplainw<br id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360234" clear="none"> WHERE id = 1))</i><br id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360235" clear="none"><i>); </i></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360356"><br clear="none"></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360357"><br clear="none"></div><div>Cheers</div><div><br clear="none"></div><div>Brent Wood<br clear="none"></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360373"><br clear="none"></div></div><div class="yiv6963858828yahoo_quoted" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_359947" style="display:block;"> <div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_359946" style="font-family:verdana, helvetica, sans-serif;font-size:16px;"> <div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_359945" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"> <div class="yiv6963858828yqt0683070843" id="yiv6963858828yqt06986"><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_359944"> <font id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_359948" size="2" face="Arial"> </font><hr id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_359953" size="1"> <b><span style="font-weight:bold;">From:</span></b> Shane Carey <careyshan@gmail.com><br clear="none"> <b><span style="font-weight:bold;">To:</span></b> postgis-users@lists.osgeo.org <br clear="none"> <b><span style="font-weight:bold;">Sent:</span></b> Tuesday, October 23, 2018 8:07 AM<br clear="none"> <b><span style="font-weight:bold;">Subject:</span></b> [postgis-users] MakeLine into new layer<br clear="none"> </div> <div class="yiv6963858828y_msg_container" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360027"><br clear="none"><div id="yiv6963858828"><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360031"><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360030"><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360029"><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360028">Hi,</div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360032">I am trying to find the longest line of a polygon and insert it into a new line. I can create the makeline as in the code below but cannot create a new layer out of it using the INTO keyword. Any help would be appreciated. Thanks</div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360036"><br clear="none"></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360191">SELECT <br clear="none"> ST_MakeLine(St_LongestLine(<br clear="none"> (SELECT geom FROM floodplainw<br clear="none"> WHERE id = 1),<br clear="none"> (SELECT geom FROM floodplainw<br clear="none"> WHERE id = 1))<br clear="none">);</div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360192"><br clear="none"></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360193"><br clear="none"></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360202"><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360201"><div class="yiv6963858828gmail_signature" dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360200"><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360199"><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360198"><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360197"><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360196"><div dir="ltr" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360195"><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360194">Le gach dea ghui,<br clear="none"></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360207"><span id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360206" style="color:rgb(61,133,198);"><b id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360205"><span id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360204" style="background-color:rgb(255,255,255);"><i id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360203">Shane Carey</i></span></b></span></div><div id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360212"><span id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360211" style="color:rgb(61,133,198);"><b id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360210"><span id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360209" style="background-color:rgb(255,255,255);"><i id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360208">GIS and Data Solutions Consultant</i></span></b></span><br clear="none"></div></div></div></div></div></div></div></div></div></div></div></div></div>_______________________________________________<br clear="none">postgis-users mailing list<br clear="none"><a rel="nofollow" shape="rect" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360213" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br clear="none"><a rel="nofollow" shape="rect" id="yiv6963858828yui_3_16_0_ym19_1_1539982788132_360214" target="_blank" href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br clear="none"><br clear="none"></div></div> </div> </div> </div></div></div></div><br><br></div> </div> </div> </div></div></body></html>