[postgis-devel] [PostGIS] #342: [raster] Implement ST_AsPNG function for raster

PostGIS trac at osgeo.org
Wed Apr 20 10:51:44 PDT 2011


#342: [raster] Implement ST_AsPNG function for raster
----------------------------+-----------------------------------------------
 Reporter:  mloskot         |       Owner:  mloskot              
     Type:  task            |      Status:  new                  
 Priority:  medium          |   Milestone:  PostGIS Raster Future
Component:  postgis raster  |     Version:  trunk                
 Keywords:                  |  
----------------------------+-----------------------------------------------

Comment(by dustymugs):

 Like the JPEG raster format, the PNG format has limitations:

 1. PNG only allows 1 (greyscale) or 3 (RGB) bands of data

 2. PNG only supports 8BUI and 16BUI pixeltypes.  Any other pixeltype will
 be written as 8BUI, though the results are probably useless

 3. PNG cannot embed spatial reference information within the file but can
 have an associated world file

 Like JPEG, the limitations can be resolved:

 1. Use ST_Band to specify which band(s) should be passed to the ST_AsPNG
 function.  If a raster whose number of specified bands does not equal 1 or
 3 is provided, a warning is raised and the first or the first three bands
 are used.

 2. Throw an exception if any of the specified bands is not 8BUI or 16BUI.
 The user should use ST_Reclass to convert any non-8BUI or 16BUI bands to
 8BUI or 16BUI.

 3. Nothing can be done within this function.  ST_Georeference() can be
 used to the contents of the associated world file

 A proposed set of variations of the ST_AsPNG function:

 1. ST_AsPNG(rast raster, options text[])

   rast: the raster with one or three bands in 8BUI or 16BUI pixel type to
 generate a PNG image from

   options: array of creation options to pass to the GDAL JPEG driver

 {{{
 ST_AsPNG(rast, ARRAY['ZLEVEL=9'])
 }}}

 2. ST_AsPNG(rast raster)

   Like !#1 above but use the driver's default creation options

 3. ST_AsPNG(rast raster, nbands int[], options text[])

   nbands: an integer array specifying the band indices of the raster to
 include in the PNG file

 {{{
 ST_AsPNG(rast, ARRAY[3,1,2], ARRAY['ZLEVEL=9'])
 }}}

 4. ST_AsPNG(rast raster, nbands int[])

   Like !#3, but use the default creation options

 {{{
 ST_AsPNG(rast, ARRAY[3])
 }}}

 5. ST_AsPNG(rast raster, nbands int[], compression int)

   compression: number between 1 and 9 indicating the amount of time to
 spend on compression.  1 is fastest with least compression.  9 is slowest
 with best compression

 {{{
 ST_AsPNG(rast, ARRAY[2,1,3], 3)
 }}}

 6. ST_AsPNG(rast raster, nband int, options text[])

   nband: index of the band to include

 {{{
 ST_AsPNG(rast, 2, ARRAY['ZLEVEL=5'])
 }}}

 7. ST_AsPNG(rast raster, nband int, compression int)

 {{{
 ST_AsPNG(rast, 1, 8)
 }}}

 8. ST_AsPNG(rast raster, nband int)

 {{{
 ST_AsPNG(rast, 1)
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/342#comment:7>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list