[postgis-users] Create Polygon from table columns
Mike Toews
mwtoews at gmail.com
Tue Jul 1 00:18:46 PDT 2014
A few things:
- The correct axis order for coordinates is always: longitude latitude
- Use an ARRAY[] to build a linestring from a sequence of point geometries
- Be sure to use a comma between each argument for ST_MakePoint
UPDATE "sat_l8_mtl"
SET geomz = ST_SetSRID(ST_MakePolygon(ST_MakeLine(ARRAY[
ST_MakePoint("CORNER_UL_LON_PRODUCT", "CORNER_UL_LAT_PRODUCT"),
ST_MakePoint("CORNER_LL_LON_PRODUCT", "CORNER_LL_LAT_PRODUCT"),
ST_MakePoint("CORNER_LR_LON_PRODUCT", "CORNER_LR_LAT_PRODUCT"),
ST_MakePoint("CORNER_UR_LON_PRODUCT", "CORNER_UR_LAT_PRODUCT"),
ST_MakePoint("CORNER_UL_LON_PRODUCT", "CORNER_UL_LAT_PRODUCT")])), 4326)
-Mike
On 1 July 2014 18:40, confugere <aginau at googlemail.com> wrote:
> This post has NOT been accepted by the mailing list yet.
> Dear Community,
> I would like to create a polygon from
> a table containing landsat 8 corner coordinates in wgs84
>
> CORNER_UL_LAT_PRODUCT DOUBLE PRECISION
> CORNER_UL_LON_PRODUCT DOUBLE PRECISION
> CORNER_UR_LAT_PRODUCT DOUBLE PRECISION
> CORNER_UR_LON_PRODUCT DOUBLE PRECISION
> CORNER_LL_LAT_PRODUCT DOUBLE PRECISION
> CORNER_LL_LON_PRODUCT DOUBLE PRECISION
> CORNER_LR_LAT_PRODUCT DOUBLE PRECISION
> CORNER_LR_LON_PRODUCT DOUBLE PRECISION
>
> i tried various things and my last effort looked like the following:
> UPDATE "sat_l8_mtl"
> SET geomz = ST_SetSRID
> (ST_MakePolygon(
> ST_MakeLine(
> ST_MakePoint("CORNER_UL_LAT_PRODUCT" "CORNER_UL_LON_PRODUCT"),
> ST_MakePoint("CORNER_LL_LAT_PRODUCT" "CORNER_LL_LON_PRODUCT"),
> ST_MakePoint("CORNER_LR_LAT_PRODUCT" "CORNER_LR_LON_PRODUCT"),
> ST_MakePoint("CORNER_UR_LAT_PRODUCT" "CORNER_UR_LON_PRODUCT"),
> ST_MakePoint("CORNER_UL_LAT_PRODUCT" "CORNER_UL_LON_PRODUCT")
> )),4326);
> Maybe someone can help me out.
> Greetings
>
>
>
> --
> View this message in context: http://postgis.17.x6.nabble.com/Create-Polygon-from-table-columns-tp5006584.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list