# How to use ScaleHint and ScaleDenominator

## 1. What is ...?

### 1.1. What is a scale?

Every map has a scale. A scale is written as 1:5000. It describes the ratio of one unit in the map to the number of units in the real world. In this example, one centimetre in the map resembles 5000 centimeters (= 50 meters) in the real world.

### 1.2. What is the ScaleDenominator?

The Scale Denominator is the second part of a scale. In the above example, the Scale Denominator is 5000.

### 1.3. What is the ScaleHint?

The OGC WMS 1.1.1 specification defines ScaleHint like this:

• `Consider a hypothetical map with a given Bounding Box, width and height. The central pixel of that map [...] will have some size, which can be expressed as the ground distance in meters of the southwest to northeast diagonal of that pixel.`

Probably you need to read that again . For now just remember something about the diagonal of a pixel. Hopefully the example below is going to explain better, what is meant here.

## 2. How to calculate ...?

### 2.1. How to calculate ScaleHint?

If you display a map on a computer screen (in a browser or a desktop application), this map can be described in two different ways.

1. the size of the map on the screen (in pixels), usually referd to as mapWidth and mapHeight.
2. the size of the displayed real world area, usually refered to as bounding box, short: bbox (in meters or in degrees or in some other unit, depending on the coordinate system of the map).

Assume the map on the screen has a mapWidth of 700 pixel and a mapHeight of 550 pixel. Assume the displayed real world area has a bbox defined by lower left corner of 300/200 and upper right corner of 1700/1300. Then the bbox height is 1100 and the bbox width is 1400.

Therefore, one pixel on the screen resembles the width and height in the real world:

• pixel height: 1100/550 = 2
pixel width: 1400/700 = 2

Remember pythagoras?
If a2+b2=c2, and if c is the diagonal of a rectangle (here: the diagonal of the pixel), and a and b are its width and height, then the real world diagonal of the pixel is: squareroot( pixelwidth2 + pixelheight2 ). For our example this means squareroot( 22 + 22 )

• ScaleHint = 2,828427125

### 2.2. How to calculate ScaleDenominator?

According to OGC SLD 1.0 specification:

• `The "standardized rendering pixel size" is defined to be 0.28mm × 0.28mm (millimeters).`

To calculate the ScaleDenominator for the map on a computer screen, you need to divide the horizontal or vertical real world pixel size by the display pixel size: ScaleDenominator = 2m / 0.00028m = 7142.8571

Therefore, the scale of the displayed map is 1:7142.8571.

### 2.3. How to calculate a ScaleHint for a given Scale

If you need to define a ScaleHint for a given scale, then the calculation is just the other way round.

Scale = 1:25000
ScaleDenominator = 25000
pixelwidth = 25000 * 0.00028 = 7
ScaleHint = squareroot( pixelwidth2 * 2)

## 3. Where to use ...?

### 3.1. Where to use ScaleHint?

As mentioned above, ScaleHint is used in the OGC specification for WMS 1.1.1. This is why sometimes the ScaleHint is also refered to as WMSScale. But this name is somewhat irritating, because in WMS 1.3.0 there is no ScaleHint anymore!

If you are configuring a WMS 1.1.1, you can use the Scale Hint for your layer definition and data sources.

### 3.2. Where to use ScaleDenominator?

The ScaleDenominator is very common, as it is part of the scale in every decent printed map.

It is used in the OGC specification for SLD 1.0 and in the OGC WMS 1.3.0 specification.

2018-04-20 12:04