Hi Freddie, st_scale can work directly on polygons, there is no reason to convert the polygons to points. So something like st_setsrid(st_scale(geom,180.0/pi(),180.0/pi()),4326) should work on any geometry, see http://postgis.net/docs/ST_Scale.html. I kind of fail to see what you want to achieve with the rapid conversions between text and geometries like st_astext(geom)::geometry.
On Fri, Dec 5, 2014 at 11:46 PM, Burgess, Freddie <[email protected]> wrote: > Will this function work? > > Does this look right > > -- > -- Name: polygon_radiant_to_latLong(geometry); Type: FUNCTION; Schema: > public; Owner: - > -- > > CREATE OR REPLACE FUNCTION polygon_radian_to_latLong(geom geometry) > returns geometry[] as > $$ > select array_agg(latlong) from ( > select path,st_astext(geom) as > "radians",st_setsrid(st_scale(st_astext(geom)::geometry,180.0/pi(),180.0/pi()),4326) > as "latlong" > from ST_DumpPoints($1::geometry) as p) as foo; > $$ LANGUAGE 'sql'; > > ownsdb=# select * from ( > ownsdb(# select path,st_astext(geom) as > "radians",st_astext(st_setsrid(st_scale(st_astext(geom)::geometry,180.0/pi(),180.0/pi()),4326)) > as "latlong" > ownsdb(# from ST_DumpPoints('POLYGON((326454.7 5455793.7,326621.3 > 5455813.7,326455.4 5455796.6,326454.7 5455793.7))'::geometry) as p) as foo; > path | radians | > latlong > > -------+---------------------------+------------------------------------------ > {1,1} | POINT(326454.7 5455793.7) | POINT(18704476.5122094 > 312593952.904064) > {1,2} | POINT(326621.3 5455813.7) | POINT(18714021.9890763 > 312595098.819654) > {1,3} | POINT(326455.4 5455796.6) | POINT(18704516.6192551 > 312594119.061824) > {1,4} | POINT(326454.7 5455793.7) | POINT(18704476.5122094 > 312593952.904064) > (4 rows) > > > select st_astext(unnest(polygon_radiant_to_latLong('POLYGON((326454.7 > 5455793.7,326621.3 5455813.7,326455.4 5455796.6,326454.7 > 5455793.7))'::geometry))); > > thanks > > ------------------------------ > *From:* Burgess, Freddie > *Sent:* Friday, December 05, 2014 5:40 PM > *To:* PostGIS Users Discussion > *Subject:* RE: [postgis-users] PostgreSQL 9.3.4/PostGIS 2.1.1 function > > ------------------------------ > *From:* [email protected] [ > [email protected]] on behalf of Stephen Mather [ > [email protected]] > *Sent:* Friday, December 05, 2014 4:34 PM > > *To:* PostGIS Users Discussion > *Subject:* Re: [postgis-users] PostgreSQL 9.3.4/PostGIS 2.1.1 function > > Sorry typos and such, try this again: > > select st_astext(st_setsrid(st_scale(geom,180.0/pi(),180.0/pi()),4326)) > FROM table_containing_polygons; > > Best, > Steve > > On Fri, Dec 5, 2014 at 4:30 PM, Stephen Mather <[email protected]> > wrote: > >> Hi Freddie, >> >> select st_astext(st_setsrid(st_scale('POINT(1 >> 1)'::geometry,180.0/pi(),180.0/pi()),4326)) FROM >> table_containing_polygon; >> >> Best, >> Steve >> >> >> On Fri, Dec 5, 2014 at 3:33 PM, Burgess, Freddie < >> [email protected]> wrote: >> >>> How would I do this on a polygon? >>> >>> Thanks >>> ________________________________________ >>> From: [email protected] [ >>> [email protected]] on behalf of Paul Ramsey [ >>> [email protected]] >>> Sent: Thursday, December 04, 2014 6:51 PM >>> To: PostGIS Users Discussion >>> Subject: Re: [postgis-users] PostgreSQL 9.3.4/PostGIS 2.1.1 function >>> >>> I would think that scaling by 180/pi should do the trick in general? >>> >>> select st_astext(st_setsrid(st_scale('POINT(1 >>> 1)'::geometry,180.0/pi(),180.0/pi()),4326)); >>> >>> P >>> >>> On Thu, Dec 4, 2014 at 3:24 PM, Burgess, Freddie >>> <[email protected]> wrote: >>> > Given a polygon geometry with no SRID, the vertices actually in >>> radians, but >>> > since the SRID is zero, it looks like Cartesian coordinates, I want >>> the lat >>> > long in degrees and not rads. >>> > >>> > Does anyone provide of a function/custom that will return lat/long in >>> > degrees given the conditions described? >>> > >>> > thanks >>> > >>> > _______________________________________________ >>> > postgis-users mailing list >>> > [email protected] >>> > http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users >>> _______________________________________________ >>> postgis-users mailing list >>> [email protected] >>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users >>> _______________________________________________ >>> postgis-users mailing list >>> [email protected] >>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users >>> >> >> > > _______________________________________________ > postgis-users mailing list > [email protected] > http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users >
_______________________________________________ postgis-users mailing list [email protected] http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
