# Methods of Compacting Raster Data: Chain Code, Run-Length Code, Block Code, & Quadtrees (Especially for GATE-Geospatial 2022)

Doorsteptutor material for IMO-Level-2 is prepared by world's top subject experts: get questions, notes, tests, video lectures and more- for all subjects of IMO-Level-2.

Examrace Books on Mapping, GIS, and Remote Sensing prepares you throughly for a wide range of practical applications.

When each cell has a unique value, it takes a total of n rows X m columns X3 values (X, Y coordinates and attribute value) to encode each overlay. A raster model is stored as a matrix. There are four main ways in which compact storage can be achieved.

## 1. Chain Code

Represent the boundary of a region by using a series of cardinal directions and cells.

- N1 means moving north by 1 cell,
- S4 means moving south by 4 cells.

Chain code provides a very compact way of storing a region representation.

In this figure, starting at the lower left cell of the region, the chain codes method records the region՚s boundary by using the principal direction and the number of cells. In this example, the recoding follows a clockwise direction.

## 2. Run-Length Code

Records are the cell by row and by group. Each group includes a cell value and the number of cells with that value. If all cells in a row contain the same value, only one group is recorded, hence save computer memory. Run-length codes allows the point in each mapping unit to be stripped per row in terms, from left to right, of a begin cell and an end cell. These are useful in reducing the volume of the data that need to be input to a simple raster database.

## 3. Block Code

Uses square blocks to represent the region.

- A unit square represents 1 cell.
- 4-square block represents cells
- 9-square block represents cells, and so on.

Each square block is coded only with the location of a cell and the side length of the block.

# 4. Quadtrees

Uses recursive decomposition to divide a grid into a hierarchy of quadrants. A quadrant having cells with the same value will not be sub-divided, and it is stored as a leaf node. Leaf nodes are coded with the value homogeneous quadrant. A quadrant having different cell values will be subdivided until quadrant at the finer level contains only one value.