Home    |    Concepts   |   API   |   Samples
Concepts > Rasters > Raster API Entities
Raster Tiles

Tiles are used to divide raster data into small, manageable areas that are stored in many BLOBs in the database.

Tiling allows the large raster datasets to be broken-up into manageable pieces. The tile-based approach is fundamental in defining and implementing a higher level raster I/O interface because, in either raster data loading or querying, the basic data I/O unit for transferring raster data over the network is still raster tiles. This approach is mostly chosen for efficiently handling very large raster datasets with limited memory and space. Thus, the API communicates directly with the ArcSDE server in terms of tiles, irrespective of what the higher level raster I/O interface is.

One benefit of subdividing rasters into tiles is the improvement in performance. For instance, if a user zooms in to a small two tile area in a single band image in the figure, ArcSDE needs to fetch only two rows from the raster block table in the DBMS, instead of the entire raster dataset. When a raster is stored in the database, the tile size controls the number of pixels stored in each BLOB field and is specified in x and y pixels when loading the data. The default value of 128 x 128 pixels should be satisfactory for most applications. The optimal tile size setting depends on factors such as data type (bit depth), database settings, and network settings.

A smaller tile size, such as 100 x 100, will result in smaller BLOBs and more records in the raster block table, which will slow down queries. A larger tile size, such as 300 x 300, will result in larger BLOBs that require more memory to process, although fewer records will be created in the block table. It is recommended that the API user should experiment with tile size before changing the default setting.

Data compression on tiles is optional but recommended. It is performed on tiles as they are stored in the database. Three compression methods are available upon import of the data: LZ77, JPEG, and JPEG 2000 (JP2). For more information on compression, click here.

In the API, raster data is retrieved from the server in tile form by a query operation. After the Raster Attr object is retrieved by the Row object, tiles can be retrieved by using the same Row object (SeRow.getRasterTile(), and SE_stream_get_raster_tile() gives a raster tile.

However, prior to calling the above method/function, some constraints need to be specified for querying the raster data. These can be set by calling the SeQuery.queryRasterTile() method or SE_stream_query_raster_tile() function, which queries the database for raster data based on the number of bands, envelope, and the interleaving method specified in the constraints parameter.

The following is an example of using raster with the Java API:

//Insert SeRasterAttr into table using query operations
 .......
 .......
int num_tiles_in_row = 0;
int num_tiles_in_col = 0;
int level = 0;
try
{
    num_tiles_in_row = attr.getTilesPerRowByLevel(level);
    num_tiles_in_col = attr.getTilesPerColByLevel(level);
}
catch(SeException sEx)
{
   System.out.println(" NumTiles exception: " + sEx.getMessage());
}

//Set the constraint
SeRasterConstraint constraint = new SeRasterConstraint();

//following code is optional
/*int[] bands = {1, 2, 3};
constraint.setBands(bands);
constraint.setEnvelope(2, 2, 3, 3);//from tile 2,2/8,8 to tile 3,3/8,8
constraint.setInterleave(SeRaster.SE_RASTER_INTERLEAVE_BSQ); */
//end of optional code

query.queryRasterTile(constraint);
SeRasterTile tile = row.getRasterTile();

byte[] pixel_data = null;

//Retrieving tile info
while(tile != null)
{
    pixel_data = tile.getPixelData();
    System.out.println("\nTile Info:\n" +
                       "Band id: " + tile.getBandId().longValue() +
                       "\nTile: [col][row]: [" + tile.getColumnIndex() + "][" +
                       "tile.getRowIndex() + "]" +
                       "\nLevel: " + tile.getLevel() +
                       "\nNo of Pixels: " +pixel_data.length +
                       "\nPixel Type: " + tile.getPixelType());

    tile = row.getRasterTile();
}
query.close();

feedback | privacy | legal