[postgis-users] Mapping from x max, ymax, xmin, ymin
Nicolas Ribot
nicolas.ribot at gmail.com
Mon Jun 6 03:26:37 PDT 2011
> Hi,
>
> I have a table with 4 columns, x max, ymax, xmin, ymin coordinates for
> the corner points of rectangles.
>
> Is there a way / function to convert these into a rectangle / polygon?
>
> Thanks,
>
> R.
>
Hi Franck,
Sure:
select st_makeBox2d(
st_makepoint(xmin, ymin),
st_makepoint(xmax, ymax))
will give you a BOX2D, ie a rectangle
the same query, cast as a geometry, will convert it to a POLYGON (5
coordinates):
select astext(st_makeBox2d(
st_makepoint(0, 1),
st_makepoint(2, 3))::geometry)
Nicolas
More information about the postgis-users
mailing list