You are on page 1of 2

HOW TO GET THE EXTENT OF YOUR GIS DATA USING POSTGRESQL WITH POSTGIS

This tutorial will explain how to get the extent of your GIS data from a PostgreSQL database query. You must have the SELECT privilege to a PostgreSQL database with PostGIS functions as well as a table containing your geometry or GIS data. The extents of your data can be visualized as a Minimum Bounding Rectangle (MBR), meaning the smallest possible rectangle that contains your data. Below is an image that illustrates the concept of the MBR.

The following query uses the xMin(), xMax(), yMin(), and yMax() PostGIS functions. xMin() is the western extent, xMax is the eastern extent, yMin is the southern extent, and yMax is the northern extent. The query structure is as follows: SELECT xMin(geometrycolumn) as west, xMax(geometrycolumn) as east, yMax(geometrycolumn) as north, yMin(geometrycolumn) as south FROM geometrytable You can optionally add a WHERE clause to your query to specify a selection of your geometry. For example:

WHERE selectioncolumn = selectionvalue; The user should now be able to define the extents of the Minimum Bounding Rectangle of their GIS data.

You might also like