[postgis-users] PostgreSQL 9.3.4/PostGIS 2.1.1 function

Burgess, Freddie FBurgess at Radiantblue.com
Fri Dec 5 14:46:59 PST 2014


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: postgis-users-bounces at lists.osgeo.org [postgis-users-bounces at lists.osgeo.org] on behalf of Stephen Mather [stephen at smathermather.com]
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 <stephen at smathermather.com<mailto:stephen at smathermather.com>> 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 <FBurgess at radiantblue.com<mailto:FBurgess at radiantblue.com>> wrote:
How would I do this on a polygon?

Thanks
________________________________________
From: postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org> [postgis-users-bounces at lists.osgeo.org<mailto:postgis-users-bounces at lists.osgeo.org>] on behalf of Paul Ramsey [pramsey at cleverelephant.ca<mailto:pramsey at cleverelephant.ca>]
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
<FBurgess at radiantblue.com<mailto:FBurgess at radiantblue.com>> 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
> postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org<mailto:postgis-users at lists.osgeo.org>
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20141205/c578c5ad/attachment.html>


More information about the postgis-users mailing list