# Blogs

## Using Statistics for Map Rendering and Labeling

The recently introduced TatukGIS Developer Kernel statistics class provides for computing statistics from data contained by any type of geospatial layer. The DK statistics class is described in an earlier blog and in the class documentation.

In addition to performing statistical computations, an important feature of the layer statistics implementation is the means to sometimes significantly speed up or extend other processes, e.g., map rendering, labeling, layer classification, raster mathematics. (Using statistics for layer classification and raster mathematics will be discussed in a later blog.)

Use of statistics for rendering and labeling is available in the Developer Kernel and in the desktop GIS Editor (via its visual layer property control).

### Section rendering

A section can be defined using a rendering query represented by formulas. Virtual fields and complex queries are permitted.

*Examples:*

- Show all objects with a population greater than the average of all observations.

`POPULATION > AVG(POPULATION)`

- Show objects with
- an area less than or equal to 25% of the range of the data, and
- a population greater than the median of all observations.

`(GIS_AREA <= (MIN(GIS_AREA) + 0.25* RANGE(GIS_AREA))) AND (POPULATION > MEDIAN(POPULATION))`

### Labeling

Label formatting, described here, can be extended using layer statistics with formulas.

*Examples:*

- Present the percentage of total population, rounded to two decimal places.

`{{(POPULATION / SUM(POPULATION)) * 100}:#.00} %`

- Present population and a value representing the difference between the population and the minimum population in the dataset, referenced to the range of all values, where 0 indicates the minimum population and 1 indicates the maximum population.

`{{POPULATION/1000000}:#.00}M [{{(POPULATION - MIN(POPULATION)) / RANGE(POPULATION)}:#.00}]`

### Statistical functions

Query formulas can use these statistical methods:

- COUNT,
- COUNTNULL,
- MIN,
- MAX,
- RANGE,
- SUM,
- AVG,
- STDEV,
- VARIANCE,
- MEDIAN,
- MAJORITY,
- MINORITY,
- VARIETY.