OGC 07-147r2
118
Copyright © 2007, 2008 Open Geospatial Consortium, Inc. All Rights Reserved.
11.6 kml:ImagePyramid
11.6.1 Structure
kml:ImagePyramid id=ID [0..1]
targetId=NCName [0..1] kml:ObjectSimpleExtensionGroup ... kml:ObjectSimpleExtensionGroup [0..]
kml:tileSize ... kml:tileSize [0..1] kml:maxWidth ... kml:maxWidth [0..1]
kml:maxHeight ... kml:maxHeight [0..1] kml:gridOrigin ... kml:gridOrigin [0..1]
kml:ImagePyramidSimpleExtensionGroup ... kml:ImagePyramidSimpleExtensionGroup [0..]
kml:ImagePyramidObjectExtensionGroup ... kml:ImagePyramidObjectExtensionGroup [0..]
kml:ImagePyramid
11.6.2 Description
This element can be used wherever the following element is referenced:
• kml:AbstractObjectGroup
Specifies a hierarchical set of images, each of which is an increasingly lower resolution towards the top of the pyramid. Each image in the pyramid is subdivided into tiles so only
the portions in view are loaded.
The pixel size of the original image is specified in the
kml:maxWidth
and
kml:maxHeight
elements. The width and height can be any size and do not need to be a power of 2. You can fill out the remaining pixels with blank pixels, as described in.
Tiles must be square, and the
kml:tileSize
must be a power of 2. A tile size of 256 the default or 512 is recommended.
A
kml:ImagePyramid
element should have the
kml:maxWidth
and
kml:maxHeight
child elements present, and, if supplied, the
kml:tileSize
should be a power of 2. See also 11.4.3 Handling large images.
11.6.3 Creating an Image Pyramid
An image pyramid should be constructed as follows, assuming the image pixel measurement is a power of 2.
1. Starting with the original, full-size image, divide it into tile-sized pieces—for
example, into blocks of 256 256 pixels each. 2.
Shrink the image by a factor of 2.
OGC 07-147r2
Copyright © 2007, 2008 Open Geospatial Consortium, Inc. All Rights Reserved.
119 3.
Divide this new image into tile-sized squares. 4.
Repeat steps 2 and 3 until the resulting image fits inside the tile size for example, 256 256 pixels.
If the image pixel measurement is not a power of 2, transparent fill pixels shall be added to make the tile square. Place the image so that the 0,0 tile is at the origin. For example, if the
origin is at the lower left, the image should be located in the lower left of the tile grid. The row and columns that might need fill would then be at the right and top of the image. For best
filtering, replicate the last row or column at the edge of the image. Then add fill for example, black to the remaining pixels in the tiles of the row or column.
For example, consider an image whose dimensions are 3600 2700 pixels roughly 10 megapixels. An image pyramid for this image should be created as follows:
1. Using a tile size of 256 pixels, you can subdivide the original image into a grid of
16 16 pixels. This image ends up as level 4 in the final pyramid. 2.
Fill in the pixels to square up the partially filled tiles in the last column to the right and the last row at the top, assuming
kml:gridOrigin
is lowerLeft.
3. Scale down the image by a factor of 2.
4. Subdivide this image into 256-pixel tiles. The image at this level consists of a
grid of 8 8 tiles level 3. 5.
Scale the level 3 image down by a factor of 2. 6.
Subdivide into tiles. The image at this level consists of a grid of 4 4 tiles level 2.
7. Scale the level 2 image down by a factor of 2.
8. Subdivide into tiles. The image at this level consists of a grid of 2 2 tiles level
1. 9.
Scale the level 1 image down by a factor of 2. 10.
The resulting image is 256 256 pixels, so this is the last level of the image pyramid level 0.
The image pyramid for a 4096 4096 image has 5 levels, as shown in Table 3.
Table 3: Example of Image Pyramid Levels Level
Number of Tiles Size of Image pixels
OGC 07-147r2
120
Copyright © 2007, 2008 Open Geospatial Consortium, Inc. All Rights Reserved.
1 256 256
1
4 2 2 grid 512 512
2 16 4 4 grid
1024 1024
3 64 8 8 grid
2048 2048
4 256 16 16 grid
4096 4096
Level n thus has 2
n
tiles in each direction.
11.6.4 Transparency