# Style: Symbol Sizes and Pixels

Sometimes when styling vector layers (drawings) some symbols may appear to be sharper than other symbols, which might have a slightly blurry appearance.  The effect tends to be visible when we use shapes that are have precisely vertical and horizontal lines, like square symbols, and is not something we would notice with other shapes, such as round symbols.

In all cases, the symbols for all objects are equally sharp and will print out equally sharp when a layout using that layer is printed.  But, depending on the pixel resolution of our display monitor and the settings we use for symbology widths and sizes, our monitor might not be able to show each symbol with equal sharpness.

## Points and Pixels

GIS applications are used both to prepare printed materials and also to prepare visualizations on display screens.  Size measurements in typographic points are the standard in printed work while for visualizations that appear on display screens size measures in pixels can have a big impact on the apparent sharpness or fuzziness of what is displayed.  Points are always a standard size, 72 points per inch, while the number of pixels per inch, and thus the number of pixels per point, can vary depending on the resolution of the display screen in use.

Most display screens have a resolution of 96 pixels per inch, which is universally described as 96 DPI for "dots per inch" instead of "pixels per inch," using the word dot as a synonym for pixel.  96 DPI resolution is so widespread we can use it as a rule of thumb for choosing sizes in points for symbols that result in sharp symbols instead of fuzzy symbols when viewed on most display screens.  This topic is written around the use of a 96 DPI display screen.

Since a point is 1/72 of an inch and a pixel at 96 DPI is 1/96 of an inch, one point is (1/72) / (1/96) pixels, that is 96/72 pixels, or 1.33... pixels.  We use 1.33 as the number of pixels in a point.

Conversely, one pixel at 96 DPI is 72/96 points, or exactly 0.75 points.

The above relationships, one point is 1.33 pixels, and one pixel is 0.75 points, drive our choices of symbol size and Stroke width for things like point symbols, line sizes, halos, padding values, and other sizes used in creating symbology with style dialogs.

## Sharp or Fuzzy

Consider the map at left below, using data taken from the Example: Format the Size of City Points by Population topic.  Looking closely, we can see that some of the square symbols used for points are sharp, while others appear slightly blurry.

In contrast, in the map at right above all of the squares are very sharp.   The data used in both cases is exactly the same, but the styling for sizes of symbols is different.  In both cases the screenshots were made on a monitor with 96 DPI (dots per inch) pixel matrix resolution.

The map at left uses a stroke width of 0.5 points for the square symbols, and the sizes of the squares are thematically formatted using interpolation to Fill the thematic intervals based on population, so that each square is likely to be a slightly different size from the other squares, with the sizes in general not being whole number multiples of pixels.  That means the lines that form the symbol can in different symbols align differently to the display's pixel matrix when the symbol is rendered.

A width of 0.5 is less than the width of a single pixel, so depending on the exact size of a symbol the desired geometric location of the line border for each square may fall entirely within a pixel or partially in one pixel and partially in an adjacent pixel.  Different sizes of symbols guarantee that the number of pixels, one or two, used to render the width of a line will vary by individual symbol.

The result of such variations is that some symbols look fuzzier as color values of pixels are interpolated to display horizontal and vertical symbol border lines that do not align with the pixel matrix, with some symbols drawing lines that are an interpolation two pixels wide and others drawing lines that are only one pixel wide.  Other symbols, which have the luck to be drawn in just the right size, will seem sharp, such as the big red square symbol in the center of the display.

The map at right uses a stroke width of 0.75 points for the square symbols, and the thematic format uses closest higher value to Fill the thematic intervals so that each square is precisely the size given for one of the intervals.  The point sizes for the thematic intervals have been chosen so that each size is exactly an even whole number of pixels.  A stroke width of 0.75 points is exactly one pixel, so the horizontal and vertical lines always are exactly one pixel wide, with the size used guaranteeing that they always fall on the center of pixels, using a line of only one pixel to render the line.

The result is that border lines will be formed from single pixels, strongly differentiating them from adjacent pixels to give a sharper effect.

With three factors being varied, Stroke width, whole or non-whole number multiples of pixels for sizes in values for thematic intervals, and different Fill method, all three factors contribute to the perception of sharpness or fuzziness.  However, using whole, even number multiples of pixels for sizes together with the choice of closest higher value instead of interpolate is the biggest contributor to sharp rendering of symbols.

## How Pixels Display Lines

The following illustrations show how such effects can arise, with the illustrations showing typical relationships that might arise with a 96 DPI display.   The illustrations show a greatly magnified view of two small shapes, with enough magnification that we can see individual pixels.

We start with two shapes that show a small square.   The square on the left is 4.5 points in height and width, which works out to exactly 6 pixels in height and width.   The shape on the right is approximately 3.94 points in height and width, which works out to 5.25 pixels in height and width.    The square on the left, at six pixels in size, is an even whole number of pixels.  The shape on the right is not a whole number of pixels in size.

Both squares are drawn using a Stroke width of 0.5 points, which is approximately 0.67 pixels in size.

We can illustrate how the two shapes are displayed on a 96 DPI monitor by adding a gray grid of squares to represent the pixel matrix of the monitor, with each gray square being one pixel.

In Manifold, the precise location of a vector shape depends on the coordinates of the geom that defines that shape, with very high precision allowing shapes to be drawn with much greater precision than the height and width of individual pixels.  To provide a more consistent look, Manifold calculates the center of each vector shape and snaps the location of the vector shape to the center of the nearest pixel to that center location.   In the illustration above , the center pixel picked out for the square shapes is shown in light red color.

Because the size of the shape on the left is exactly a whole, even number of pixels, when the shape on the left is snapped into position to be centered on the exact center of the central pixel, the horizontal and vertical lines that make up the square are centered on single pixels.    In contrast, because the size of the shape on the right is not a whole, even number of pixels, when that shape is snapped into position onto the center of the central pixel, the horizontal and vertical lines overlap the boundaries of more than one pixel.

To render the shapes on the pixel matrix, pixels which include some part of the shape to be rendered will light up with a color value proportionate to the amount of the shape that is included within that pixel.  That generates an interpolation which renders the position and shape of the square.

Consider the vertical lines of the shape on the left.  Each vertical line is 0.67 pixels wide, but because the vertical lines are centered exactly within the boundaries of single pixels, the width of each vertical line is entirely within a single pixel, which gets a proportionately high color value while adjacent pixels have zero coloring.

The vertical lines in the shape of the right are positioned so they cover more than one pixel in width, with pixels on the inner side of the overlap covered by about 0.22 pixels of the width of the line and those pixels on the outside of the overlap covered by about 0.45 pixels of the width of the line.

If color intensity is proportionate to the coverage of each pixel by the line, each vertical line is rendered by two columns of pixels, with the inner column lighter than the outer column.

If we remove the illustration's grid of pixels which are transparent and show only those pixels that are colored by intensity proportional to the amount of each shape's line within each pixel we can see how the shapes will be rendered in the grid of pixels.

The shape at left uses single pixels in a row or column perpendicular to each vertical or horizontal line.  The central pixel has a strong color intensity compared to adjacent pixels, which are not on at all.  The result is high contrast between the square shape made up of single, strong pixels in a row or column and the adjacent, much lighter pixels. The visual effect is that of a sharp square.

The shape to the right ends up being drawn using two pixels in a row or column perpendicular to each vertical or horizontal line. The two pixels vary in intensity, with the lighter, inner pixels having a proportional intensity about half that of the darker, outer pixels. The visual effect is a fatter shape that when zoomed will appear fuzzier.

The difference between sharper and fuzzier is what we see in the illustration above.   Square symbols that are sized so they are whole, even numbers of pixels in size will appear sharp, while those pixels which are sized so they do not use whole, even numbers of pixels will look less sharp.

The screenshot below uses pixels sizes that ensure sharp shapes.

The symbols in the screenshot above use sizes that are all whole, even multiples of a full pixel in size.  They also use a Stroke value of 0.75 points, which is exactly the width of a single pixel.  Despite using a thicker Stroke width, the illustration looks much sharper than the previous illustration using a Stroke value of  0.5 points.

We can repeat the illustrations of two squares using that value to see what happens.

Above we see two square shapes.  The square on the left is 4.5 points in height and width, which works out to exactly 6 pixels in height and width.   The shape on the right is 6 points in height and width, which works out to exactly 8 pixels in height and width.  The square on the left, at six pixels in size, is an even whole number of pixels.  The shape on the right at eight pixels in size is also an even whole number of pixels in size.

Both squares are drawn using a Stroke width of 0.75 points, which is exactly 1 pixel in size.

Overlaid on the pixel matrix of a monitor, we can see how the shapes fit into the pixel matrix of the display when snapped to the center of the light red pixels in the middle.

Because the size of the shape on the left is exactly a whole, even number of pixels, when the shape on the left is snapped into position to be centered on the exact center of the central pixel, the horizontal and vertical lines that make up the square are centered on single pixels.  The shape on the right is also exactly a whole, even number of pixels, so the horizontal and vertical lines that make up the shape on the right are also centered on single pixels.

A single line of pixels that is completely filled by the line to be rendered will render the shape at left with a full on value of 1.  The shape at right also completely fills the pixel matrix intersected by each horizontal or vertical line, so the pixels for each line will also have full on values of 1.  In neither case are pixels powered at lesser color intensities.

The result when zoomed out will be a very crisp, razor sharp rendering of a square both for the shape at left and for the shape at right.

In thematic formatting of the size of symbols we maximize sharpness by choosing sizes for the squares which always align to an even whole number of pixels.   That is how the sharpest image shown earlier was constructed:

The screenshot above uses 0.75 points as the Stroke width for the square symbols.    0.75 points is the size of a single pixel in a 96 DPI screen.

But in addition to using a Stroke width that is a single pixel, the thematic formatting based on population specifies sizes for each thematic interval that are whole number multiples of 1.5 so each size is an even whole number multiple of pixels.  For example, 4.5 points are six pixels and 6 points are eight pixels.  When symbols are exactly an even whole number multiple of pixels, they are snapped to central pixels so that horizontal and vertical lines fall exactly within single columns or rows of pixels.

The Fill strategy uses closest higher value so that each symbol will be exactly one of the listed interval sizes and not a value in between, as would happen with interpolate as a Fill choice.  That guarantees that each square symbol will center on all sides exactly the same way with the pixel grid.

## Even vs. Odd Whole Numbers of Pixels

This topic emphasizes the need to use point sizes for symbols that are even whole numbers of pixels.  What happens if we use whole numbers of pixels for sizes, but which are odd whole numbers?  We can see what happens by redoing the sequence of illustrations for how shapes are rendered on a pixel matrix.

Above are two squares.  The square at left is 6 pixels in size (4.5 points), an even whole number of pixels in size.   The square at the right is 7 pixels in size (5.25 points), an odd whole number of pixels in size.

When the two shapes are snapped to the center of the central pixel, the even whole number of pixels used for the size of the shape on the left aligns the vertical and horizontal lines exactly in the middle of columns and rows of pixels in the display matrix.   However, the odd whole number of pixels used for the size of the shape on the right snaps the shape so that the vertical and horizontal lines fall on the boundaries between columns and rows of pixels in the display matrix.

The shape on the left is rendered using columns and rows of single pixels, while the shape on the right is rendered by columns and rows of two pixels, since the vertical and horizontal lines of the shape fall onto two pixels in width.

The resulting rendering is razor sharp for the square on the left, rendered as it is by single columns and rows of full color intensity pixels, while the square on the right is rendered with two, less intense pixels.

We can see the effect in the two maps shown above.  The map at left uses sizes for squares that are even whole numbers of pixels.  The map at right uses sizes for squares that are odd whole numbers of pixels.   The map at right is obviously fuzzier, even though both maps use a Stroke width of 0.75, for horizontal and vertical lines that are one pixel wide.

We see the thematic formats above in the Style dialog for each map.  The map at left uses size values for the intervals that are all multiples of 1.5 points, which all work out to even whole numbers of pixels.   The size values in the intervals at right have all had 0.75 points, the width of one pixel, subtracted so all of the values work out to odd whole numbers of pixels.

When squares are rendered in the thematic format at left, each square will be an even whole number of pixels in size and thus will be rendered using columns and rows of single, full color intensity pixels for a razor sharp effect.   When squares are rendered in the thematic format at right, each square will be an odd whole number of pixels and thus will be rendered using columns and rows of two, interpolated color intensity pixels for a fuzzier effect.

## Choosing Sizes and Widths for Symbols

Based on the above discussion we can choose widths and sizes for symbols based on the following advice:

### Vertical and Horizontal Lines

The first advice is not to worry about widths and sizes for shapes that are not made up of precisely vertical and horizontal lines.

Both illustrations above use a Stroke width of 0.5 and a thematic format using a sequence of symbol sizes (4, 6, 8, 10, and 12 points) that are not whole numbers of pixels.  The only difference is that the map at left uses circle symbols and the map at right uses square symbols.

Everything about the rendering of a circle symbol is interpolated with frequent use of more than one pixel in the rendered width of a line, so each of the circle symbols in the map at left are evenly interpolated with no dramatic difference in sharpness between circles. Because the map at right uses squares with precisely vertical horizontal and vertical lines, those lines can align or not align with the pixel matrix in a way that generates a more fuzzy look.

We can see how the effect shows up in precisely horizontal and vertical lines by taking the map at right and rotating the squares 7 degrees.  Immediately, the visual distinction between sharp and fuzzy squares goes away, since all of the squares are now interpolated to render small diagonal lines within the available pixel matrix.

A corollary of only vertical and horizontal lines mattering is that the effects in this topic primarily arise when styling points.  Areas and lines in GIS work are usually so irregular that their rendering, as with circle symbols, is interpolated so the effects in this topic usually are not visible when styling areas and lines.

### Thick and Thin

The greater the Stroke width of a line, the less it will matter how it overlays the pixel matrix, since more pixels will be fully on whether the size of the symbol results in good alignment to the pixel matrix or not.

The map at left above uses a Stroke width of 1 point, while the map at right uses a Stroke width of 0.5 points, with all other settings the same, not using whole pixel numbers for the size of symbols.   The thicker lines provide a greater likelihood that the average of how pixels are used to render lines will be similar visually.

### Even Whole Numbers of Pixels for Symbol Sizes

Choosing symbol sizes that are even whole number multiples of pixels aligns all border lines of a square symbol to fall precisely within pixel centers in the display's pixel matrix.  That prevents interpolation using multiple pixel widths to render lines that fall within multiple pixels in the display matrix.

To make that work, we must also use closest higher value (or closest lower value) as the setting for Fill option in thematic formats, and not interpolate.  Using closest higher value ensures that the specified even whole number multiples are indeed used.  If we used interpolate, many of the sizes used would fall between whatever are the values for intervals, and would not be even whole number multiples of pixels.

Seen above are maps that use 0.5 points for Stroke width, with both using closest higher value as the Fill strategy.  The map at left above has uniformly sharper symbols because the interval values for size are even whole number multiples of pixels.   The map at right above has many fuzzy symbols because those use sizes that are not an even whole number multiple of pixels.

We can see the size settings used in the thematic formats shown below in the two different Style pane settings:

In both cases there are 5 thematic intervals (Breaks), tallied using equal count.  In both cases the Fill strategy is closest higher value.   However, the map on the left uses size values that are whole number multiples of 1.5 so each size is an even whole number multiple of pixels.  For example, 4.5 points are six pixels and 6 points are eight pixels.  When symbols are exactly an even whole number multiple of pixels, the border lines of a square will fall exactly into the middle of pixels in the display matrix.

The intervals for the map at right use point values that, except for the second and last intervals, work out to non-whole number multiples pixels, so the size in pixels for many symbols is not an even whole number multiple.

### Closest Higher / Lower Value

Using interpolate as a Fill strategy in a thematic format for symbol size usually will result in greater sharp or fuzzy variation than using a fixed set of sizes using closest higher value (or closest lower value), because the interpolation of sizes results in symbol sizes that are not even whole number multiples of pixels.

Both maps above use a Stroke width of 0.75 and a thematic format using a sequence of symbol sizes (4.5, 6, 7.5, 9, and 12 points) that are even whole numbers of pixels.  The map at left uses closest higher value as a Fill strategy while the map at right uses interpolate as a Fill strategy.   Because the thematic format for the map at left always results in symbols sizes that are even whole numbers of pixels, each symbol is razor sharp.  The interpolation of sizes for symbols in the map at right, in contrast, more often results in symbol sizes that are not even whole numbers of symbols, resulting in many fuzzy symbols.

## Guidelines

We can summarize the above discussion with the following advice:

1. This topic is about point symbols that have precisely vertical and horizontal lines. Other symbols are not an issue.
2. Choose sizes for symbols in points that are whole number multiples of 1.5 points, that is, even whole numbers of pixels:  1.5, 3, 4.5, 6, 7.5 and so on.
3. When thematically formatting size of symbols, use a Fill strategy of closest higher value or closest lower value, and not interpolate.
4. When setting Stroke width for borders within point styles, use 0.75 points or even whole number multiples of 0.75, as that is the size of a single pixel in points.

The above advice applies to styling point symbols, but it also will apply to sizes (widths) of vertical or horizontal lines when styling lines, and also to most other sizes used together with horizontal and vertical lines, such as halos and padding.

See the Example: Format the Size of City Points by Population topic for an example using the above guidelines.

## Notes

Snapping to the Center - To provide more uniform rendering, Manifold calculates the center of each vector shape used and snaps the position of the shape to the center of whatever pixel the center of the shape is in.  Snapping the shape to be centered on the center of the central pixel means that the position of the shape could be as much as one half a pixel width off the precise geographic location of the shape.  Since that snapping is done only for rendering, it is perfectly acceptable since nobody can measure geographic positions by placing a ruler against a display screen with accuracy greater than one half pixel, 1/192 of an inch or about 1/10th of a millimeter.

Style Pane

Style: Drawings

Style: Areas

Style: Lines

Style: Points

Style: Thematic Formatting

Example: Style Pane Quickstart - A tutorial introduction to using the Style pane to apply color, symbology, size and rotation to areas, lines and points in drawings.

Example: Change Point Style - Using new Style pane controls to change point style, either very rapidly one property at a time, or using the total Style button to compose a new style with changes to several properties at once.

Example: Format a Drawing using the Style Pane - In this example we provide a first, step by step look at how to format areas in a drawing using the Style pane.  We can specify the same formatting for all areas or use a field to automatically set formatting, a process usually known as thematic formatting.

Example: Format the Size of City Points by Population - A common GIS task is to format the size of points in a drawing based on some value.  For example, the size of points that represent cities might be formatted based on the value of the city's population, with cities that have larger populations being marked by larger point icons.  This is an example of thematic formatting and is easy to do using the Style dialog.