[postgis-devel] [raster] Tweaking overviews in raster2pgsql.py

Mateusz Loskot mateusz at loskot.net
Thu Dec 2 10:06:04 PST 2010


Hi,

I'd like to propose a small simplification to the overviews management
in the raster loader script. Currently, raster2pgsql.py takes explicit
overview factor (called level, incorrectly in my opinion).
This follows gdaladdo appraoch where it accepts list of overview 
reduction factors used to generate overview levels.

I'd like to get rid of this explicit factors and simplify things a bit,
I'd like to follow the techniques users already know from slippy maps, 
Google Maps, Oracle etc.

The command would change from

raster2pgsql.py -t mydata  ... (base level)
raster2pgsql.py -t mydata -l 2 ...
raster2pgsql.py -t mydata -l 4 ...
raster2pgsql.py -t mydata -l 8 ...
...

The command would change to simple:

raster2pgsql.py -t mydata -l 8 ...

where the N=8 means that user requests 8 overview levels in total,
including base raster.
The levels are numbered as follows: 0, 1, 2, ..., N-1
The overview reduction factor is calculated based on level number:

2 ^ Ni

where Ni is the actual level number:

level=0 => overview factor=1 (base raster)
level=1 => overview factor=2 (reduction by 2)
level=2 => overview factor=4 (reduction by 4)
... etc.

This would generate overview tables named after overview level
but not overview factor. The latter is already stored in metadata.

mydata (base raster)
mydata_o_1 (overview factor=2)
mydata_o_2 (overview factor=4)
mydata_o_3 (overview factor=8)
...

This calculation is reversible making it possible to calculate overview 
level from given reduction factor:

level = log(overview_factor) / log(2)
factor = pow(2, level)

The simplification is that there is only *one* variable information 
carried around, it is total number of overview levels.
All the rest values are easily calculated based on that.


What you say?

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org



More information about the postgis-devel mailing list