How to create tiles from a raster dataset

This article demonstrates the process of dividing a raster dataset into a set of smaller datasets with specified rows and columns.

Creating tiles from a raster dataset

See the following example code:
static void createTilesFromRasterDataset(IRasterDataset rasterDataset, IWorkspace
    outputWorkspace, int tileWidth, int tileHeight)throws Exception{
    //Creates a set of raster datasets with specified rows and columns from the source dataset
    //rasterDataset: the source raster dataset
    //outputWorkspace: the output file raster workspace
    //tileWidth: the number of columns of each tile
    //tileHeight: the number of rows of each tile

    //Get source raster properties
    IRasterProps rasterProps = new IRasterPropsProxy
    int width = rasterProps.getWidth();
    int height = rasterProps.getHeight();
    double xCell = rasterProps.meanCellSize().getX();
    double yCell = rasterProps.meanCellSize().getY();

    //Calcualte number of tiles and remaining pixels in both x and y dimensions
    int remX = width % tileWidth;
    int remY = height % tileHeight;
    int tileX = (int)(width / tileWidth);
    int tileY = (int)(height / tileHeight);

    IEnvelope dsExtent = rasterProps.getExtent();
    IEnvelope tileExtent = new Envelope();
    ISaveAs saveAs = null;
    int tempX;
    int tempY;

    //Create one raster with specified tile size
    for (int i = 0; i <= tileX; i++){
        if (i == tileX){
            tempX = remX;
            tempX = tileWidth;

        for (int j = 0; j <= tileY; j++){
            if (j == tileY){
                tempY = remY;
                tempY = tileHeight;

            rasterProps = new IRasterPropsProxy(rasterDataset.createDefaultRaster());

            //Recaculate the new extent
            tileExtent.setXMin(dsExtent.getXMin() + i * tileWidth * xCell);
            tileExtent.setXMax(tileExtent.getXMin() + tempX * xCell);
            tileExtent.setYMax(dsExtent.getYMax() - j * tileHeight * yCell);
            tileExtent.setYMin(tileExtent.getYMax() - tempY * yCell);


            //Save the tile to the output workspace as IMG file, can be other writeable formats too
            saveAs = new ISaveAsProxy(rasterProps);
            saveAs.saveAs("tile_" + i + "_" + j + ".img", outputWorkspace, 
                "IMAGINE Image");

See Also:

How to access a raster dataset or raster catalog

Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine