[postgis-users] Postgres Polygon to Postgis Geometry

Mike Toews mwtoews at gmail.com
Tue Oct 26 20:17:32 PDT 2010


Ah, you are looking for this:

http://postgis.refractions.net/docs/ST_Transform.html

So you need to cast your object as a polygon, set the SRID to your
projected coordinate system (I'm just guessing SRID=29181 for your
example http://spatialreference.org/ref/epsg/29181/ .. look up the
SRID for your original data). Then it can be transformed into long/lat
coords:

SELECT ST_Transform(ST_SetSRID('BOX(743295.3125 7182512.5,744414.75
7183817.5)'::box2d::geometry, 29181), 4326);

-Mike

On 26 October 2010 20:01, Wagner Santos <wagner.desenv at gmail.com> wrote:
> Mike,
> Yes, I mean georeferenced (sorry for my English). I made a cast to text and
> converted to postgis geometry, but I couldn't use ST_SetSRID.
> I would like to tranfer a polygon to correct position. I have a
> Polygon "BOX(743295.3125 7182512.5,744414.75 7183817.5)" and I like to
> transfer it to "BOX(-54.515022277832 -25.4530487060547,-54.5029907226562
> -25.4447135925293)".
> I tried ST_Affine but I don't know the correct parameters, I tried ST_Scale
> but I had the same problem. My idea was transform and set srid.
>
> On Tue, Oct 26, 2010 at 11:44 PM, Mike Toews <mwtoews at gmail.com> wrote:
>>
>> Hi Wagner,
>>
>> I'm not sure what you mean by "geo" and "non-geo" .. you mean
>> georeferenced, like longitude/latitude?
>>
>> For points, you can keep thing binary and just use ST_MakePoint(x,y).
>> And to assign a coordinate system, use it with ST_SetSRID:
>>
>> SELECT ST_SetSRID(ST_MakePoint(p[0], p[1]), 4326)
>> from (
>>  select point '(-123.112793, 49.246293)' as p
>> ) as foo;
>>
>> I'm not sure how to do similar binary conversions for path and
>> polygon, or other types. You might have to cast to text, and wrangle
>> it into some form of WKT, then pass it to ST_SetSRID(text, integer) to
>> make a geometry object for PostGIS.
>>
>> -Mike
>>
>>
>> On 26 October 2010 18:17, Wagner Santos <wagner.desenv at gmail.com> wrote:
>> > I created a Postgis Geometry from Postgres Polygon converting them  from
>> > string and using linefromtext to create a geometry but this information
>> > isn't geo.
>> > I have non geo points and I want to convert to my correct position and
>> > set
>> > SRID, for example P(70 72) to P(-54 -25), how can I do this?
>> > Thanks!
>> >
>> > On Tue, Oct 26, 2010 at 1:18 PM, Wagner Santos <wagner.desenv at gmail.com>
>> > wrote:
>> >>
>> >> Hello,
>> >> I'm new with postgis and I have a legacy database with Postgres
>> >> Polygon, I
>> >> want to convert this to a Postgis Geometry. Is there a way?
>> >> I try to do with replace string and linefromtext with sucess, but I
>> >> think
>> >> doesn't better solution because I can't set a valid SRID.
>> >> Thanks!
>> >
>> > _______________________________________________
>> > postgis-users mailing list
>> > postgis-users at postgis.refractions.net
>> > http://postgis.refractions.net/mailman/listinfo/postgis-users
>> >
>> >
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>



More information about the postgis-users mailing list