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

Mateusz Loskot mateusz at loskot.net
Thu Dec 9 12:50:08 PST 2010


On 09/12/10 12:19, Jorge Arévalo wrote:
> On Mon, Dec 6, 2010 at 7:06 PM, Mateusz Loskot <mateusz at loskot.net> wrote:
>> *bump*
>>
>> On 02/12/10 18:06, Mateusz Loskot wrote:
>>>
>>> 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?
>
> 
> Hello,
> 
> +1 for that.


> Is there any situation where you just want a specific
> overview level, without the rest?

Mostly on client side, there are some where only total number of
levels is known. e.g. count records in raster_overviews table
and derive all the other properties without any need for more
detailed queries. It also simplifies generating levels with very simple
constraints on max number of overviews.
Such levels numbering is linear and simpler to manipulate, iterate, etc.

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