Thanks Brent, but it keeps returning a error message: 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
Thanks Le gach dea ghui, *Shane Carey* *GIS and Data Solutions Consultant* On Mon, Oct 22, 2018 at 8:26 PM Brent Wood <[email protected]> wrote: > > Off the top of my head... > That returns the longest straight line within a polygon. > > 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). > > eg: > > *create table long_lines (id integer primary key), geom > geometry(LINESTRING, <SRID>);* > > then run your query... > > *INSERT INTO long_lines* > > > > > > *SELECT id, ST_MakeLine(St_LongestLine( (SELECT geom FROM > floodplainw WHERE id = 1), (SELECT geom FROM floodplainw WHERE id > = 1))* > *); * > > > Cheers > > Brent Wood > > ------------------------------ > *From:* Shane Carey <[email protected]> > *To:* [email protected] > *Sent:* Tuesday, October 23, 2018 8:07 AM > *Subject:* [postgis-users] MakeLine into new layer > > Hi, > 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 > > SELECT > ST_MakeLine(St_LongestLine( > (SELECT geom FROM floodplainw > WHERE id = 1), > (SELECT geom FROM floodplainw > WHERE id = 1)) > ); > > > Le gach dea ghui, > *Shane Carey* > *GIS and Data Solutions Consultant* > _______________________________________________ > postgis-users mailing list > [email protected] > https://lists.osgeo.org/mailman/listinfo/postgis-users > >
_______________________________________________ postgis-users mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/postgis-users
