<div dir="ltr"><div>Thanks Brent, but it keeps returning a error message:</div><div><br></div><div>ERROR: column "id" does not exist
LINE 2: SELECT id,
^
HINT: There is a column named "id" in table "long_lines", but it cannot be referenced from this part of the query.
SQL state: 42703
Character: 31</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 Mon, Oct 22, 2018 at 8:26 PM Brent Wood <<a href="mailto:pcreso@yahoo.com">pcreso@yahoo.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:verdana,helvetica,sans-serif;font-size:16px"><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359938"><span><br></span></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360330"><span>Off the top of my head...<br></span></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360331"><span></span></div><div class="m_1402730463458641628qtdSeparateBR" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359939"><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360332">That returns the longest straight line within a polygon. <br></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360296"><br></div><div dir="ltr" id="m_1402730463458641628yui_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="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360293"><br></div><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360262">eg:</div><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360250"><br></div><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360165"><i id="m_1402730463458641628yui_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="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360167"><br></div><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360168">then run your query...</div><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360189"><br></div><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360169"><i>INSERT INTO long_lines</i></div><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360333"><i id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360358">SELECT id, <br id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360230"> ST_MakeLine(St_LongestLine(<br id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360231"> (SELECT geom FROM floodplainw<br id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360232"> WHERE id = 1),<br id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360233"> (SELECT geom FROM floodplainw<br id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360234"> WHERE id = 1))</i><br id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360235"><i>); </i></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360356"><br></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360357"><br></div><div>Cheers</div><div><br></div><div>Brent Wood<br></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360373"><br></div></div><div class="m_1402730463458641628yahoo_quoted" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359947" style="display:block"> <div style="font-family:verdana,helvetica,sans-serif;font-size:16px" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359946"> <div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size:16px" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359945"> <div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359944"> <font id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359948" size="2" face="Arial"> <hr id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_359953" size="1"> <b><span style="font-weight:bold">From:</span></b> Shane Carey <<a href="mailto:careyshan@gmail.com" target="_blank">careyshan@gmail.com</a>><br> <b><span style="font-weight:bold">To:</span></b> <a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a> <br> <b><span style="font-weight:bold">Sent:</span></b> Tuesday, October 23, 2018 8:07 AM<br> <b><span style="font-weight:bold">Subject:</span></b> [postgis-users] MakeLine into new layer<br> </font> </div> <div class="m_1402730463458641628y_msg_container" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360027"><br><div id="m_1402730463458641628yiv9486371826"><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360031"><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360030"><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360029"><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360028">Hi,</div><div id="m_1402730463458641628yui_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="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360036"><br></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360191">SELECT <br> ST_MakeLine(St_LongestLine(<br> (SELECT geom FROM floodplainw<br> WHERE id = 1),<br> (SELECT geom FROM floodplainw<br> WHERE id = 1))<br>);</div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360192"><br></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360193"><br></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360202"><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360201"><div dir="ltr" class="m_1402730463458641628yiv9486371826gmail_signature" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360200"><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360199"><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360198"><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360197"><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360196"><div dir="ltr" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360195"><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360194">Le gach dea ghui,<br></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360207"><span style="color:rgb(61,133,198)" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360206"><b id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360205"><span style="background-color:rgb(255,255,255)" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360204"><i id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360203">Shane Carey</i></span></b></span></div><div id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360212"><span style="color:rgb(61,133,198)" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360211"><b id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360210"><span style="background-color:rgb(255,255,255)" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360209"><i id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360208">GIS and Data Solutions Consultant</i></span></b></span><br></div></div></div></div></div></div></div></div></div></div></div></div></div>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@lists.osgeo.org" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360213" target="_blank">postgis-users@lists.osgeo.org</a><br><a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" id="m_1402730463458641628yui_3_16_0_ym19_1_1539982788132_360214" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br><br></div> </div> </div> </div></div></div></blockquote></div>