Variable-scale maps in real-time generalisation using a quadtree data structure and space deforming algorithms

ABSTRACT Variable-scale maps have been advocated by several authors in the context of mobile cartography. In the literature on real-time map generalisation, however, corresponding methods that resolve cartographic conflicts by deformation of the underlying map space together with the map foreground, are underrepresented. This paper demonstrates how the concept of a malleable space can be applied as a part of the generalisation process and incorporated into the overall methodology of point generalisation. Two different algorithms are used, a density-equalising cartogram algorithm and Laplacian smoothing. Both methods work in real-time and are datadriven. In addition, they allow for a parameterisation in combi-nation with a quadtree data structure, as well as a combination with 'classic' generalisation operators (e.g. selection, aggregation, displacement) based on the quadtree. The quadtree serves both as a spatial index for fast retrieval and search of points, and as a density estimator to inform generalisation operators. The use of the quadtree as a common spatial index provides a tool to combine variable-scale maps with classic generalisation. A combination of the two allows, at small map scales, the maintenance of detail in dense areas and data reduction in sparse areas. Additionally, it facilitates building a modular workflow for real-time map generalisation.


Introduction
Variable-scale maps have been advocated by several authors in the context of mobile cartography (Edwardes, 2007;Edwardes, Burghardt, & Weibel, 2005;Harrie, Sarjakoski, & Lehto, 2002a, 2002b. In Bereuter and Weibel (2010), we presented a conceptual classification of point generalisation algorithms, distinguishing space-directed generalisation and object-directed generalisation operators. Object-directed operators correspond to 'classic' generalisation operators such as selection, simplification, aggregation or displacement, and manipulate map objects directly. Space-directed operators manipulate and deform the underlying map space to perform generalisation operations and resolve cartographic conflicts. A key advantage of space-directed approaches is that they jointly and concurrently displace both foreground and background objects, thus maintaining topological relations between foreground and background objects.
User acceptance of variable-scale maps goes in hand with maintaining map readability, keeping map distortion minimal, and achieving smooth, continuous transitions in realtime operation (van Dijk & Haunert, 2014). Maintaining distortion properties and hence map readability is important to address the cognitive validity of such maps (Mountjoy, 2001;Pietriga, Bau, & Appert, 2010;Schafer & Bowman, 2003).
We make the following contributions: (1) we show how variable-scale maps and spacedirected generalisation can be implemented using two different algorithms and a hierarchical data structure (a quadtree); (2) we compare the two algorithms regarding key cartographic properties; and (3) we show how, by using the quadtree as a common data structure, space-directed generalisation can be combined with classic object-directed operators to create generalisation workflows adapted to mobile cartography.
Starting off from the conceptual presentation of space-directed approaches to point generalisation in Section 2, we introduce in Section 3 the working principles of the cartogram algorithm, how the quadtree is applied as a density estimator, effects of scale, and finally the combination with the object-directed map generalisation. Section 4 follows the same order of presentation for Laplacian smoothing. Section 5 compares the merits and drawbacks of the two approaches and discusses solutions for the combination with object-directed map generalisation. Section 6 concludes the paper.

Space-directed generalisation of point data
Space-directed generalisation transforms the map background (the base map) together with the foreground features (the point data). The two methods proposed here both rely on a tessellation structure (originally a grid; a quadtree in our case). The deformation of the tessellation allows to map the background tiles onto the deformed structures (same method as used in texturing 3D objects). The new position of the foreground points on the deformed map is calculated based on the known deformation of the background map and projects the foreground features to the correct position. Bereuter and Weibel (2013) proposed a quadtree-based approach for real-time map generalisation, implementing various object-directed generalisation operators. There, the quadtree serves as a spatial index for fast retrieval and search, and as a density estimator to inform the generalisation operators. In space-directed generalisation, the same quadtree data structure can be used as a 'binning' structure to parameterise the space deformation algorithms and thus to control and limit the map deformation. Additionally, the quadtree as a spatial index provides a tool to combine object-and space-directed generalisation. A combination of the two approaches allows, at small map scales, the maintenance of details in dense areas and data reduction in sparse areas. Thus, it facilitates building a modular workflow for real-time map generalisation.
Like the displacement operator, in classic map generalisation, space-directed generalisation operates best only within a limited scale range. To minimise undesired distortion effects, this paper shows that space-directed generalisation is best used in combination with object-directed operators, where the former allows accommodating more points at a given target scale than solely by object-directed generalisation.

Working principle
Cartograms denote a type of map, where the area of geographic regions is drawn in proportion to a variable, for instance, the population of a country. The construction of cartograms thus requires finding a transformation from the original to the target map, such that the areas on the target map are proportional to a given statistical variable; hence, the synonym 'density equalizing maps' for cartograms. As this task is rather challenging, a multitude of algorithms exist, such as the rubber map method by Tobler (1973), Dorling's non-contiguous cartograms (Dorling, 1996) or the diffusion-based method by Gastner and Newman (2004) and others.
The diffusion-based method for producing density-based maps by Gastner and Newman (2004) avoids the drawbacks of previous methods of constructing cartograms. The diffusion cartogram, as they call it, is based on the observation that in a 'true' cartogram, after the transformation, the density of the mapped statistical variable such as the 'population' is uniform. Thus, in regions with high density, the mapped variable should 'flow' to regions of low density until the distribution of the mapped variable is equalised. The method by Gastner and Newman adapts the linear diffusion process of particle physics to model the cartogram transformation. The working principle of the method, however, is only half the story, as the authors observe: "Part of the art of making a good cartogram lies in shrewd decisions about the definition of the population density". (Gastner & Newman, 2004, p. 7502) The method requires the definition of a starting density for the map. That is, the mapped statistical variable needs to be transformed into a 'continuous function', a density field over the map space represented by a fine grid in Gastner and Newman's implementation. There are various ways to estimate the initial density field. Depending on the initial density field, the resulting cartograms may differ quite substantially from each other. Therefore, the initial density surface affects the accurate density equalisation and ultimately the readability of the map. Gastner and Newman (2004) observe that for fine-grained density distributions, cluster centres show considerable distortion. Coarse-grained density distributions cause less distortion, but result in a less accurate density equalisation.
For space-directed point generalisation, the point distribution serves as the basis for estimating the initial density distribution. The transformation of the point data into the starting 'binned' density surface can be achieved by different methods: by creating a regular grid and adding the value of each point to its containing cell; by creating a smooth density surface of the dataset with a kernel density estimation (KDE); or by using the quadtree and adding the value of each point to its containing quadnode (for further details, see Bereuter, 2015).
The cartogram built from the regular grid ( Figure 1(b)) generates quite substantial distortions, as the values between the cells show strong density variations. The strong variations can be mitigated using the smoothing properties of the KDE (Figure 1(c)). Due to its decomposition principle, which adapts to the point density, using the quadtree as a binning structure and density approximation achieves a similar effect (Figure 1(d)). The depth of the depicted quadtree is limited with regard to the current map zoom level (target level of detail, LOD) and symbol size used in the same way as introduced in Bereuter and Weibel (2013). That is, the width of the smallest quadnode shown is just equal to, or greater than, the symbol width.
The data for this experiment (Figure 1(a)) originate from an animal observation dataset from the Val F'tur in the Swiss National Park (SNP). The implementation of the cartogram algorithm by Gastner and Newman (2004) used here is a modified version of the Scape-Toad code by Christian Kaiser, which in turn is a Java adaptation of Mark Newman's C code (source code: https://github.com/christiankaiser/ScapeToad). Figure 2 depicts a series of cartograms with different density initialisation methods. The KDE-based cartogram (Figure 2(a)) results in greater distortion than the two quadtreebased solutions, especially in the dense centre of the valley. Also, the original arrangement of the point pattern is least preserved. The distortion by the quadtree-based solutions is less strong. The different weighting schemes, applying the point density (Figure 2(b)) and the point count (Figure 2(c)), show that a slightly different weighting with same spatial subdivision considerably influences the spatial distortion of the resulting cartogram. Hence, the zoom level that affects the size of quadnodes and the values set for the quadnodes in the distortion grid must be selected such that they maintain the distortionand therefore the readabilityof the map. Figure 3 shows for zoom levels 14-12 the cartogram with an initial quadtree density grid applying the point density method (Figure 2(b)). To highlight the map deformation, the distorted quadtree grid is overlaid on top of the map.

Cartogrameffects of the map zoom level
Considering the descriptive statistics (Figure 3(g)) for the three density grid zoom levels, the overall sum, average and maximum decreases between zoom levels 14 and 13, and slightly increases between zoom level 13 and 12. The standard deviation reduces gradually, while the minimum length of the displacement vector increases. The displacement vectors generated by the regular grid and the KDE overall are significantly larger, especially in the case of the regular grid.
The angular distribution of the mean (Figure 3(d-f)) levels off with decreasing zoom level for the depicted directions of the displacement vectors. Hence, for a lower density grid zoom level (i.e. smaller map scale), the overall deformation is more uniform and smoother across the map space. While a more 'detailed' spatial deformation results for an increased zoom level. This observation is in line with the observations made by Gastner and Newman (2004) regarding the cell size in a regular density grid and the resulting spatial deformation.

Combining the cartogram with object-directed operators
Since the creation of the density grid is based on the quadtree, other quadtree-based generalisation algorithms such as the object-directed algorithms proposed in Bereuter and Weibel (2013) can be combined with the cartogram. Figure 4 shows the so-called centrality-based simplification Bereuter and Weibel (2013) applied to a cartogram, with a quadtree-based density grid for map zoom levels 14, 13 and 12, respectively.
Object-directed operators assume an undistorted map with a uniform map scale. However, as a result of space-directed map generalisation, the area of each quadnode   either increases or decreases, depending on the local distortion, thus leading to a variable local map scale across the map. If the area of the quadnode increases, more points may be retained. The inverse is true if the area of the quadnode decreases, or the shape is strongly elongated. In that case, less points should be shown than retained by an object-directed algorithm alone. Figure 4(c) shows this effect nicely. While in the centre of the map more content could have been retained, the transition area between deformed and undeformed areas retain too many points, creating a circular pattern around the deformed area.
Thus, for distorted quadnodes with an increased area, a higher zoom level must be used as a basis for object-directed generalisation. The inverse holds for quadnodes with a reduced area or strongly elongated shape. In addition to varying the map zoom level locally based on the quadnode shape and area, if full conflict resolution is required (i.e. no partial overlaps are tolerated), quadnode border conflict resolution can be applied as shown in Bereuter (2015, see Chapter 6.6). However, if the shape of the quadnode is strongly deformed and the point symbol size exceeds the width of the transformed quadnode, second degree quadnode neighbours have to be considered for border conflict resolution.

Working principle
Laplacian smoothing was originally used in computer graphics to smooth the representation of surfaces. It was first introduced to map generalisation by Edwardes (2007) with the aim to relax spatial conflicts between overlapping point symbols. Based on the primal-dual scheme by Taubin (2001), the algorithm proved to be sufficiently fast for interactive portrayal on mobile devices of the time. Edwardes (2007) shows in detail the mathematical foundation and the adaptation to map generalisation. The following examples are based on a modified version of Edwardes' implementation.
Laplacian smoothing also relies on a grid to derive the distortion of the map. Like with the cartogram-based deformation method, the grid can be weighted and thus parameterised by values derived from the quadtree. To facilitate comparison of the two methods, the following examples use the same dataset, extent, zoom level and grid as were used with the cartogram-based method. Figure 5(a) shows Laplacian smoothing with a regular grid weighted by the number of points per grid cell, whereas Figure 5(b) is based on a grid weighted by the number of points per quadnode area.
Laplacian smoothing takes three global control parameters, the number of grid cells (and thus the grid cell size), a global weight attributed to each grid cell and a smoothing factor. First, the cell size influences the area that each point in the grid influences. Second, the weight then affects how much the map is distorted. The higher the global weight parameter the stronger the distortion. Third, the smoothing factor is a 3 × 3 kernel that applies spatial averaging to the neighbouring cells of the weighted cell, comparable to low-pass filtering. It expands the area of influence of the chosen weight, from inside a single cell to its neighbouring cells and further emphasises the weighted cells.
The control parameters are set empirically with global weight w = 10 and smoothing factor sf = 2. The weights of each grid cell are derived from the corresponding quadnode and number of points: w c = wp n a g a n n g with w c as weight in grid cell c, w the global weight factor, p n the number of points stored in a quadnode, a n the quadnode area; a the quadtree area and n grid the number of grid cells.
Overall, both results show only slight differences. The average length and the standard deviation of the displacement vectors differ only slightly, in the range of less than a tenth of a screen pixel. Both maps enlarge the cells in regions of high point density and show strong deformation towards the border of the point pattern. The overall area of deformation does not extend significantly beyond the boundary of the point pattern. Thus, for points located in the centre of the point pattern, their grid cells have only limited space to expand. This implies that the overall arrangement of the point pattern is mostly maintained.
The similar results motivate the use of a quadtree-based weighting scheme to control space-directed generalisation, and to use Laplacian smoothing in combination with quadtree-based, object-directed generalisation algorithms. Additionally, cell size, weighting and smoothing factor can be linked to the zoom level. Figure 6 shows Laplacian smoothing based on different quadtree-based weighted density grids for zoom levels 14-12, keeping the grid size, weight and smoothing factor fixed. Reducing the zoom level the deformation of the map space becomes smoother and more uniform across the map space.

Laplacian smoothingeffects of the map zoom level
The descriptive statistics for the length of the displacement vectors ( Figure 6(g)) show for all values decreasing lengths to lower map zoom levels, except for the minimum length. The evolution of the length of displacement vectors confirms, alongside with the reduction in the standard deviation, that the deformation of the map space becomes smoother (Figure 6(g)). The reduction of the mean shows that the overall deformation of the map decreases. A similar, but less distinctive, picture shows up in the directional plots of Figure 6(d-f).
Changing the local weights based on the quadtree-based zoom levels in each grid cell does not change the overall deformation significantly (Figure 6(a-c)). In fact, the overall deformation is more significantly influenced by decreasing the zoom levels ( Figure 8).
The generalisation sequence shown in Figure 7 shows Laplacian smoothing for map zoom levels 14, 13 and 12 in combination with centrality-based simplification (also used in Figure 4). The grid size used for Laplacian smoothing is equal to the smallest quadnode size of the target map zoom level. Thus, the number of grid cells is equal to the maximum possible number of quadnodes per zoom level.
The generalisation sequence, based on the quadtree, keeps the size of the grid cells constant at all three zoom levels. Thus, in Figure 7(a), the number of cells is 32 × 32, for map (b) 16 × 16 and 8 × 8 in map (c). Equally, the value of the weight is kept constant (w = 10) for the three zoom levels.
As in the cartogram-based space deformation shown in the preceding section, the combination with object-directed generalisation creates the problem of retaining too many points in areas that have been locally reduced, and too few points in areas that have been enlarged (compare Figure 4 and Figure 7).
For map zoom level 14 (Figure 7(a)), the overall map deformation is moderate compared to map zoom levels 13 or 12. It is not solely the moderate deformation at map zoom level 14 that supports this impression, but also the fact that Laplacian smoothing largely maintains the shape of the weighted grid cells. Most affected are those cells that lie just outside of the point distribution (e.g. in the southwest corner of Figure 7(a)). Neighbouring weighted cells seem to even out the distortion, such that overall the shape is better maintained.
The reduction in the number of grid cells at map zoom levels 13 and 12 (Figure 7(b,c)) goes in hand with a smoother but stronger deformation of the map space. Compared to those maps with constant number of grid cells, Figure 7(b,c) show that the reduction in the number of grid cells increases the deformation of the map.
Regarding the interplay of space-directed and object-directed generalisation operations, similar observations can be made as in the case of the cartogram algorithm above: towards the border of the point distribution, more points than desired are retained, while in the deformed centre less points are kept than would be possible. However, at lower map zoom levels (i.e. smaller scales), the circular accumulation pattern of points is less pronounced (compare Figure 4(c) to Figure 7(c)).

Comparing the space deformation algorithms
Due to the different working principles of the two space deformation methods, the quadtree-based parameterisation affects the deformation in different ways.
While in the case of the cartogram, the quadtree serves as a binning structure with attributed weights, in Laplacian smoothing, it serves as a means of applying weights to the grid structure used by the method.
The two maps at the top of Figure 8 compare the cartogram algorithm (a) and Laplacian smoothing (b) side-by-side based on the same quadtree shown in Figure 8(c). The dataset, restaurants in the city of Zurich, originating from OpenStreetMap, features a different point pattern with distinct clusters (KDE in Figure 8(d)).

Deformation
The cartogram by Gastner and Newman (2004) requires an appropriate, smooth initial estimation of the density surface to prevent substantial distortions in areas of high densities. Unlike in Laplacian smoothing, the bin size, the density of the bins and bins with strong density variation can lead to substantial distortion of the map. Density estimation based on the quadtree principle enables to better maintain the readability of the map. Laplacian smoothing, then, is less prone to strong undesired distortions, as the magnitude of the distortion depends on the bin size and global weight settings. In comparison to the cartogram, Laplacian smoothing provides two additional global parameters, a weighting and a smoothing factor, to control the spatial deformation.

Directionality
The cartogram algorithm, due to the underlying density equalisation principle, preferably displaces points towards the empty areas of the map (Figure 3), whereas in the case of Laplacian smoothing, points are displaced towards directions where locally fewer points are present on the map. The differences of the displacement vectors highlight the different working principles between the two methods, clearly manifested in the animal observation dataset with a single-point cluster, while less pronounced in the Zurich dataset.

Shape preservation
Qualitatively, Laplacian smoothing generally preserves the shape of the point pattern better than the cartogram algorithm, especially in dense areas of the point distribution. This is due to the different working principle of the algorithms and the resulting overall different degree of deformation, which was higher for the cartogram-based maps. That is, Laplacian smoothing does not equalise regions of high densities and keeps the deformation local, which leads to better shape preservation.

Singularity
However, a downside of the 'local' nature of Laplacian smoothing is that, in contrast to the cartogram algorithm, stronger shrinking of cells may occur, creating 'singularities'. This becomes visible in Figure 8(b) along the northern lakefront, where some grid cells are nearly collapsed to a point. Such 'singularities' may occur in Laplacian smoothing for cells between strongly weighted areas, if the global weights are set to high values.

Combination with quadtree-based generalisation
Sections 3.2 and 4.2 presented the combination of a data-driven, malleable space with object-directed generalisation, applying the quadtree-based methods presented in Bereuter and Weibel (2013). These methods derive the degree of generalisation from the current global map zoom level. In space-directed generalisation, however, the zoom level is not uniform throughout a map.
Consequently, if the local zoom level on the distorted map increases, the represented area is enlarged and therefore more space is available and spatial conflicts are reduced. This means that the object-directed generalisation algorithms retain less points than would be possible after combination with space-directed methods, reducing the perceived density of the point pattern. The opposite is true for locally reduced zoom levels and especially for highly distorted regions, creating further clutter and overlap and therefore an increase in the perceived density.
Thus, to combine better object-and space-directed approaches, the object-directed generalisation algorithms would need to consider the local distortion of the map scale. That is, with quadtree-based, object-directed algorithms, the local distortion should be investigated per quadnode. Hence, for each quadnode at a given zoom level, the algorithm should implement shape measures of the quadnode area such as the ratio of the diagonals. A ratio strongly deviating from 1.0 hints towards a substantial distortion of a quadnode. Distorted quadnodes should reflect the local map scale. That is, quadnodes with strong distortions or reduced area should display content generalised to a lower zoom level, while in the case of an increased quadnode area the displayed map content should be less generalised and more content displayed. Additionally, border conflicts may be removed in a similar way as in the undistorted case (Bereuter, 2015) also considering the distorted area of the quadnode and its neigbours.

Conclusion and outlook
This paper illustrated how variable-scale maps can be generated based on two different algorithms, the density-equalising cartogram algorithm (Gastner & Newman, 2004) and Laplacian smoothing (Edwardes, 2007). It thus demonstrated the concept of a malleable space as a method of space-directed generalisation and how it can be integrated into an overall methodology of point generalisation. Both methods are data-driven, parameterisable and executable in real-time. In addition, they enable parameterisation in combination with the quadtree, as well as combination with object-directed generalisation algorithms.
Possible extensions include the use of higher resolution background maps for strongly enlarged map regions, and the inclusion of attribute weighted densities to enlarge regions based on attribute values, rather than merely based on the number of points. In addition, as introduced by Edwardes (2007), Laplacian smoothing allows the definition of spatial constraints, for instance, to safeguard certain areas or features (e.g. linear features), such that they are not affected by distortions.
Finding a satisfactory parameterisation of malleable space algorithms is, even with the help of an auxiliary, data-driven index structure (the quadtree), not straightforward, and difficult to balance over a range of scales. Thus, this requires further empirical investigation and fine-tuning. Also, the perceptual and cognitive validity of space-directed deformation remains to be evaluated (Mountjoy, 2001;Pietriga et al., 2010;Schafer & Bowman, 2003), in particular, in interactive web or mobile environments. Intuitively, however, it seems adequate to restrict space-directed generalisation operators to rather narrow scale bands, and use them in combination with classical, object-directed generalisation operators. In that respect, space-directed generalisation operators take a similar position to the role of the displacement operator among the object-directed operators, which is also rather used for the 'finishing touches' in map generalisation.