concept pixel in category geoprocessing

appears as: pixels, pixels, The pixels, pixel, pixel
Geoprocessing with Python

This is an excerpt from Manning's book Geoprocessing with Python.

You’ll learn how to work with the two main types of spatial data, vector and raster. Vector data is made up of points, lines, and polygons, while raster data is a two- or three-dimensional array of data values such as the pixels in a photograph. A dataset containing country boundaries is an example of vector data. In this case, each country is generally represented as a polygon. Datasets that use lines to represent roads or rivers, or points to show the location of weather stations, are other examples. Early primitive maps, such as those drawn on cave walls, only showed the features themselves. Later maps contained labels for features of interest such as cities or seaports; for example, the Portolan map of northwest Africa shown in figure 1.1.

You’ll learn several techniques for manipulating raster data in this chapter. For example, you’ll learn how to apply calculations on a pixel-by-pixel basis to two or more rasters. You’ll also see how to use a small set of neighboring pixels to come up with new values. This is what happens when you smooth or sharpen a digital photo. Other calculations use all pixels in a raster, or divide them up based on some common value. Each of these has different uses, and you’ll see examples of all of them.

Focal analyses use the pixels that surround the target pixel in order to calculate a value. For a given cell in the output, the value is calculated based on the corresponding cell and its neighbors in the input dataset. This is also called a moving window analysis because you can think of it as “window” of cells centered on each pixel in turn. Once the value for the target pixel is calculated, the window moves to the next pixel. Figure 11.3 shows how a 3 x 3 window would “move” across an image. The output values of the dark pixels are calculated using the nine surrounding lightly-shaded input pixels. These types of operations are common for smoothing data and removing random noise. In fact, you’ve probably used similar filters to touch up your own digital photos. Focal analyses can also be used for anything else that requires input from surrounding pixels, such as computing slope and aspect for an elevation dataset.

Figure 11.5. The slices that are used in a 3 x 3 moving window. Each example shows the same input data, but the lightly shaded cells are the slices defined by the text below the example. The dark outline defines the window around pixel [2, 2]. The darker shaded cells are all at index [1, 1] inside the corresponding slice.
Figure 11.6. The individual slices created in figure 11.5, along with their sum and average. The shaded cells at index [1, 1] in each slice are the same cells as those in the outlined window in figure 11.5, so averaging the slices is equivalent to averaging the cells in the window.

Figure 11.6 shows these same slices with the cell at index [1, 1] highlighted. Compare the values of these highlighted pixels to the values of the pixels inside the dark outline in figure 11.5. They’re the same, so if you take the average of the slices, the value at index [1, 1] will be the average of the nine pixels outlined in figure 11.5. In fact, the output contains the average of all complete 3 x 3 windows in the original dataset. Again, this leaves the edge rows and columns out of the resulting data, for the sake of simplicity. You’d need to cut off more rows and columns from the edges for larger moving windows. For example, a 5 x 5 window would cut off two on each side instead of one.