Richard Vidalo
Richard Vidalo

Reputation: 135

PostGIS, Is possible to create a Polygon from some Points

Well,

I used to create Points or Polygons from latitude and longitud. Using something like that:

ST_Transform(ST_GeomFromText('POINT("+longitud+" "+latitud+")' ,4326),23030)

But on that moment my source are geometry values of thousands of points, and I would like to create a geometry Polygon value from them. But I don´t know if it is possible.

Also I have UTM coordinates(mine is 30 S), but I think that starting from geometry would be easier.

If someone could help me, I would be so gratefull.

Thanks

Upvotes: 1

Views: 3301

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 325051

You can collect an array of point, cast to geometry[], and use ST_MakeLine.

SELECT ST_MakePolygon(ST_MakeLine( ARRAY[ point(1,2), point(3,4), point(5,6) ]::geometry[] ));

Upvotes: 2

Related Questions