The previous queries returned basic information about the raster and returned collections with the data. In PostgreSQL, there are a series of functions that return geometries from queries. This section will cover a few of those functions.
A raster is comprised of a matrix of cells and values. These cells become georeferenced pixels in our raster data. Using PostgreSQL, you can query your raster data for a specific cell and get the polygon representation of that cell back. The following code shows you how:
cursor.execute("select rid, ST_asText(ST_PixelAsPolygon(rast,7,2)) from bigi;")cursor.fetchall()
Using ST_PixelAsPolygons, you can pass the raster column, the column, and the row of a cell and get back polygon ...