4

I'd like to create an image based on raster output I'm building from a PostgreSQL spatial database.

I have a query:

SELECT (
    ST_AsPNG(
        ST_AsRaster(
           geom, 1.5::double precision, 2::double precision, 11, 11, '8BUI', 100, 0, 0, 0, false
        )
    )
) AS "png" FROM "geom" AS "g" LIMIT 1

When I dump the returned result, I get:

resource(83) of type (stream)

I've tried many combinations of using PHP's built-in functions of working with images, but can't seem to get anywhere in actually drawing the polygon. I always get an issue with 'invalid resource type supplied' or similar.

There seems to be no helpful documentation available - could anyone guide me in the right direction?

Technologies in use:

  1. Postgis 2

  2. Postgres 9

Zachary Schuessler
  • 3,644
  • 2
  • 28
  • 43

1 Answers1

2

PostGIS documentation have a chapter (5.3.1) with a

"PHP Example Outputting using ST_AsPNG in concert with other raster functions":

http://postgis.net/docs/using_raster_dataman.html#RT_PHP_Output

Peter Krauss
  • 13,174
  • 24
  • 167
  • 304