Print

发布时间: 2019-05-16
摘要点击次数:
全文下载次数:
DOI: 10.11834/jig.180378
2019 | Volume 24 | Number 5




    计算机图形学    




  <<上一篇 




  下一篇>> 





MAP-Vis:基于MAP模型的时空点状大数据可视化方案
expand article info 谢冲, 关雪峰, 周炜轩, 吴华意
武汉大学测绘遥感信息工程国家重点实验室, 武汉 430079

摘要

目的 对于大数据挖掘,可视分析是一种非常重要的研究手段,有助于快速、直观地理解分析大数据蕴含的价值信息。但因其海量、时空、高维等特征,大数据可视化存在内存消耗大、渲染延迟高、可视效果差等问题。针对上述问题,以海量时空点数据为例,采用预处理可视化方案,设计并实现了一套高可扩展的分布式可视分析框架。方法 借鉴瓦片金字塔模型提出一种多维度聚合金字塔模型(MAP),将瓦片金字塔的2D空间层级聚合扩展到时间/空间/属性多维度,同时支持时间、空间、属性的多维层级聚合。进而以Spark集群作为并行预处理工具,以HBase分布式数据库持久化存储MAP模型数据,实现了一套开源的分布式可视化框架(MAP-Vis)。结果 以纽约出租车数据集为例,本研究实验证明能够支持时间/空间/属性多尺度、多维度联动的交互式可视化,同时具有高可扩展的预处理能力和存储能力。结论 在分布式处理能力支持下,系统能实现亚秒级的查询响应,达到良好的交互式可视化效果,证明MAP-Vis是一种有效的大数据交互式可视化方案。

关键词

大数据; 多维; 层级聚合; 分布式数据库; 可视分析

MAP-Vis: a spatio-temporal big data visualization method based on multi-dimensional aggregation
expand article info Xie Chong, Guan Xuefeng, Zhou Weixuan, Wu Huayi
State Key Laboratory of Information Engineering in Surveying Mapping and Remote Sensing, Wuhan University, Wuhan 430079, China
Supported by: National Key Research and Development Program of China (2016YFB0502302)

Abstract

Objective As data collection methods mature and diversify, data sources such as personal smart devices, floating car GPS, internet of things, and social media are becoming increasingly abundant, and the amount of data have been accumulating in an explosive manner. Big data hold spatio-temporal information and high-dimensional features. Spatial and temporal features refer to attribute fields with spatial position and time tags. High dimensional features mean that the target data often contain other valuable attributes. Visual analysis is a highly important method for big data research as it can quickly and intuitively help researchers analyze and understand intrinsic values. However, because of its massive volume, spatio-temporal correlation, and high dimensions, big data visualization poses many challenges to current implementations, including large memory consumption, high rendering delay, and poor visual effects. Method In this study, we propose a generic multi-dimension aggregation pyramid (MAP) model on the basis of the well-known 2D tile pyramid model. This MAP model can support the hierarchical aggregation of time, space, and attributes simultaneously and transform the aggregated results into discrete key-value pairs for scalable storage and efficient retrieval. Then, we use the high-performance Spark cluster as a parallel preprocessing platform and the distributed HBase as final storage to store the generated MAP data. Finally, with the generated MAP datasets, we design and implement an open-source distributed visualization framework (MAP-Vis). Result The experiments use the open New York taxi data, which cover 30 months from January 2014 to June 2016. A single record contains trip-related information, including the location and time of the taxi origin/destination, trip duration, and distance. The visualization interface is implemented on the MAP-Vis framework, which uses HTML, CSS, and JavaScript. Leaflet and OpenStreetMap are used for road network display; the timeline and attribute histogram sections use the d3 library to support user interaction. Three efficiency metrics are collected to evaluate the performance of the MAP model and MAP-Vis system in terms of model validation, storage scalability, and system scalability. In the experiment of model validation, as the size of the raw data increases, the response time curve remains flat and does not show a significant linear increase; the values slightly fluctuate between 0.7 s and 1 s. This result indicates that the MAP model can scale well with the size of spatio-temporal data sets, guarantee a sub-second response, and achieve a smooth interactive visualization experience. In the experiment of storage scalability, as the number of clusters increases, the overall response time decreases dramatically from 3.2 s to 0.9 s, and the parallel efficiency is improved by approximately 2.4 times. This finding can be attributed to distributed storage. More storage nodes are used and the possibility of access to only one region and the access queue time are reduced. Therefore, by increasing the number of HBase storage regions, the proposed framework enhances query efficiency, fully exploits the parallelism of distributed clusters, and significantly improves the visual interactive experience. In the experiment of system scalability, the number of worker nodes in the Spark cluster is changed to measure how the pre-processing time changes (excluding the time of importing the HBase database). An increase in the number of nodes leads to the reduction of pre-processing time from 360 min to 160 min, and the efficiency is improved by approximately 1.3 times. Therefore, with computation nodes, the Spark cluster uses worker nodes and executor processes to share pre-processing tasks, thereby significantly improving the pre-processing efficiency. Conclusion Given its large size, space-time properties, high dimension, and other characteristics, spatial-temporal big data face various challenges such as large memory consumption, high rendering delay, and poor visual effect. To solve this problem, we first propose a spatio-temporal big data organization model, namely, the MAP, which integrates the tile pyramid model and the key-value matching method. The MAP model can consider the time and space dimensions, attribute information, and the three aggregate aggregations step by step, thereby adapting to the rapid and high visualization of time and space big data. On the basis of the MAP model, an open-source visualization framework, MAP-Vis, is implemented on a Linux cluster. The MAP-Vis system uses Spark as a pre-processing tool and HBase as a distributed storage platform. Experiments validate the efficiency of the proposed MAP model, and the undrerlying distributed platforms provide high scalability for visualization and processing. With the cluster, the MAP-Vis realizes sub-second data query and achieves good interactive visualization. Future work can be conducted in the following aspects. 1) This framework has strong support for point type data, but visual elements, including line type elements, polygon type elements, images, etc. should be considered compatible with other data types as much as possible. 2) A simple visual display cannot fully explore the law and value of big data. Hence, joining data analysis modules could be taken into consideration to make the MAP-Vis framework function complete.

Key words

big data; multi-dimensional; hierarchical aggregation; distributed database; visual analysis

0 引言

随着个人智能设备、浮动车GPS、物联网、社交媒体等数据采集手段的成熟与多样化,数据源日益丰富,采集的数据量呈爆炸式增长。这些体量巨大、流式生成、类型众多、价值蕴含的大数据兼具时空和高维特征[1-2]。时空特征是指数据带有空间位置和时间标签或能体现时空位置的属性字段;高维特征指数据包含除时空外的其他特征属性,这些属性反映出的信息规律往往更具研究价值。可视化是分析挖掘时空大数据的重要步骤和手段,能够直接反映数据中蕴含的模式和规律。Godfrey等人[3]提出,按可视化查询返回的数据类型划分,大数据交互式可视化类型可以分为基于原始数据的可视化和基于预处理数据的可视化两类。

1) 原始数据直接可视化。为了提高查询/可视化效率,这一类型可视化方案多采用高性能分布式计算平台。例如,Google’s Big Query[4]是一个基于云平台的大数据分析网络服务,通过融合分布式计算、列存储和数据压缩等技术,支持亿级记录数据的在线查询分析,并实现交互式可视化。Root等人[5]开发的大规模并行数据库MapD利用图形处理单元(GPU)在处理复杂、实时的时空数据时对数据库进行加速,使其能以毫秒级的响应来分析处理数十亿行的数据。在单节点的情况下,MapD比集群的CPU数据库快至少2个数量级。这类方法可以支持精确的单条数据查询,但缺点是所需硬件资源庞大,成本较高,且无法解决可视化出现覆盖、叠加现象,无法清晰地表达分布信息。

2) 将预处理结果作为可视化数据源。可视分析最常用的概念是数据立方体(data cube)[6],现有的很多方法都是通过对其扩展来建立的。数据立方体是多维数据结构的层级聚合形式,包含上卷、下钻、切片、切块、旋转等操作,能够提供数据的多维视图,并允许用户预计算,从而快速访问汇总数据。然而对于海量的多维数据集,立方体大部分单元为空,导致存储冗余非常多,内外存消耗过大。为解决存储冗余问题,许多学者采用多种扩展结构减少数据立方体的内存。Dwarf[7]通过前缀、后缀冗余来压缩数据立方体,减少内存消耗。imMens[8]将高维数据立方体划分为多个子立方体达到降维的目的,从而减少总内存消耗,并通过GPU并行处理渲染, 减少查询时间延迟,缺点是能够支持的最大维度是4维,且无法自由扩展到更高属性维度。Nanocubes[9]扩展了Dwarf思想,提出一种基于内存的树结构,添加了不同层级的空间维度、时间维度和属性维度,能够支持多维度以及时空的交互式查询。尽管Nanocubes的效率在数据立方体压缩后有所提升,能够在单机上对一定数据量的大数据进行交互式可视化,但由于Nanocubes是基于内存的紧耦合结构,难以水平扩展到分布式架构。以上实现都是在单机上对数据进行聚合,从而实现内存消耗减少。目前,基于分布式平台的聚合方法日益增多。VisReduce通过分布式NoSQL数据库进行扩展,在线聚合后再返回查询结果,聚合过程采用了MapReduce算法和数据压缩方法[10],但随着数据量增大,对原始数据的在线聚合会消耗更多的时间,难以支持交互性可视化。TBVA[11]通过Spark集群[12]对大数据进行离线预处理,提前生成不同空间层级的瓦片数据,并计算各个瓦片的属性维度的统计值,达到交互式可视化效果。然而TBVA不支持空间/时间范围查询,不支持时空特征分析。GeoMesa[13]使用Cassandra/HBase等数据库对时空数据进行分布式存储,在处理数据过程中可以使用MapReduce或Spark处理。当对大数据进行可视化时,通过时空索引快速获取原始数据并在线进行处理,最终返回聚合结果。但是该方法也存在随着数据量的增大在线交互式性能显著降低的问题。

综上所述,面对时空高维大数据,基于数据预处理的可视化仍是主流实现方式。在已有的单机解决方案中,数据量仍有很大的限制,很难具备数据容量的水平扩展性;在已有的分布式解决方案中,在线聚合的实现较难做到流畅的交互式可视化。针对上述问题,本研究以出租车点位数据、签到数据等时空点类型数据为可视化对象,提出了一种多维度聚合金字塔数据组织模型,兼顾时空和多维度属性以及地图显示的层级尺度,设计实现了一套面向此类时空大数据的开源可视化框架,解决了大数据可视化时扩展性不佳、查询性能低和时空高维支撑不足的难题,实现了快速查询可视化的效果。

1 多维度聚合金字塔模型(MAP)

1.1 2D金字塔模型

地理信息系统(GIS)中,瓦片地图金字塔模型常用于2D地图显示,是一种多分辨率的层次模型,从底层到顶层,金字塔的分辨率越来越低。金字塔包含多个图层,每个图层由多个正方形瓦片( ${\rm{tile}} $ )拼接而成,每个瓦片由像素(${\rm{pixel}}$)组成(默认分辨率一般为256×256像素)。为了更准确描述2D金字塔模型构建的过程,本文定义如下概念:

1) 像素($ {\rm{pixel}}$)。像素是金字塔模型的最小数据单位,即瓦片金字塔层级中瓦片中的单个像素。表示为

$ \mathit{\boldsymbol{pixel}}{\rm{ = \{ }}\mathit{l}{\rm{, }}\mathit{x}{\rm{, }}\mathit{y}{\rm{, }}\mathit{p}{\rm{\} }} $ (1)

式中,$ l$是金字塔的层级,$ x$$y $是像素包含的空间范围,$ p$代表该像素对应的空间范围内的特征采样值,如聚合统计值、如均值、总和等。

2) 瓦片($ {\rm{tile}}$)。瓦片金字塔模型中的瓦片是空间邻近的像素组合,默认分辨率为256×256像素。表示为

$ \mathit{\boldsymbol{tile}} = \left\{ {l, X, Y, \bigcup\limits_{i = 1}^{w \times w} \mathit{\boldsymbol{p}} \mathit{\boldsymbol{ixel}}} \right\} $ (2)

式中,$l $是金字塔的层级,$ X$$Y $为瓦片的行列号,$w $为瓦片的分辨率,最后的并集表示该瓦片空间范围内的像素集合。

3) 金字塔(${\rm{pyramid}} $)。金字塔是各个层级瓦片共同组合成一个空间多尺度的模型。表示为

$ \begin{array}{l} \mathit{\boldsymbol{pyramid}} = \\ \sum\limits_{i = 1}^n {\sum\limits_{j = 1}^M {\sum\limits_{k = 1}^N {{\rm{ }}\mathit{\boldsymbol{tile}}{\rm{ }}} } } \left\{ {{l_i}, {X_j}, {Y_k}, \bigcup\limits_{i = 1}^{n \times x} \mathit{\boldsymbol{p}} \mathit{\boldsymbol{ixel}}} \right\} \end{array} $ (3)

基于上述概念,金字塔模型的构建还需对应操作,以共同完成对空间维度的层级聚合。定义的4个基本操作如下:

1)$ {\rm{Extract}}$>操作。负责将每一条原始记录映射到像素单位上,一个像素可能对应一条或多条原始记录,$ {\rm{Extract}}$操作为

${\rm{Extract}}\left( {{l_n}, \{ {{Lon}}, {{ Lat }}\} , w} \right) = \mathit{\boldsymbol{pixel}}\left\{ {{l_n}, x, y, p} \right\}, \\ \left\{\begin{aligned} x &=\frac{L o n+180}{360} \cdot 2^{l_{n}+r} \\ y &=\left(1-\frac{\ln ({\rm{tan}}\left(L a t \cdot \frac{\pi}{180}\right)+\frac{1}{\cos \left(L a t \cdot \frac{\pi}{180}\right)} )}{\pi}\right) \cdot 2^{l_{n}+r-1} \\ r &=\log _{2} w \end{aligned}\right. $ (4)

式中,$ l_{n} $是金字塔的最大层级,$L o n $$L a t $代表原始记录数据的地理位置,$w$为定义的瓦片的分辨率。

2) $ {\rm{Group}}$操作。主要是建立像素与瓦片之间对应的映射关系,即求得像素应隶属的具体瓦片,操作公式为

$ \begin{array}{l} {\rm{Group}}\left( {\mathit{\boldsymbol{pixel}}\left\{ {{l_n}, x, y, p} \right\}} \right) = \\ \mathit{\boldsymbol{tile}}\left\{ {{l_n}, X, Y, \bigcup\limits_{i = 1}^{n \times w} \mathit{\boldsymbol{p}} \mathit{\boldsymbol{ixel}}} \right\}\\ \;\;\;\;\;\;\;\;\;\;\;\left\{ {\begin{array}{*{20}{l}} {X = (x/w)}\\ {Y = (y/w)} \end{array}} \right. \end{array} $ (5)

3) Key-value操作。经过$ {\rm{Group}}$\操作得到最大层级的瓦片及其聚合数据,可令Key为瓦片的四叉树/空间填充曲线编码,Value为该瓦片的像素的集合,将其键值化将瓦片以键值对的形式存储,为后续分布式存储建立基础。

4) Aggregate操作。不同于$ {\rm{Group}}$操作对单一瓦片内的像素进行组合,Aggregate是层级间瓦片的聚合。$ {\rm{Extract}}$$ {\rm{Group}}$和Key-value 3个操作获取了金字塔最大层级的瓦片集合,接下来需逐级向上聚合,得到各层级的瓦片,最终得到金字塔模型。Aggregate操作公式为

$ \begin{array}{l} {\mathop{\rm Agg}\nolimits} \left( {\mathit{\boldsymbol{tile}}\left\{ {{l_n}, {X_{2i}}, {Y_{2i}}, \bigcup\limits_{i = 1}^{w \times w} {\mathit{\boldsymbol{ pixel}}{\rm{ }}} } \right\}} \right.,\\ \mathit{\boldsymbol{tile}}\left\{ {{l_n}, {X_{2i}}, {Y_{2i + 1}}, \bigcup\limits_{i = 1}^{n \times w} {{\rm{ }}\mathit{\boldsymbol{pixel}}{\rm{ }}} } \right\},\\ \mathit{\boldsymbol{tile}}\left\{ {{l_n}, {X_{2i + 1}}, {Y_{2i}}, \bigcup\limits_{i = 1}^{n \times w} {{\rm{ }}\mathit{\boldsymbol{pixel}}{\rm{ }}} } \right\},\\ \mathit{\boldsymbol{tile}}\left\{ {{l_n}, {X_{2i + 1}}, {Y_{2i + 1}}, \bigcup\limits_{i = 1}^{n \times w} {{\rm{ }}\mathit{\boldsymbol{pixel}}{\rm{ }}} } \right\} = \\ \mathit{\boldsymbol{tile}}\left\{ {{l_{n - 1}}, {X_i}, {Y_i}, \bigcup\limits_{i = 1}^{n \times xw} {{\rm{ }}\mathit{\boldsymbol{pixel}}{\rm{ }}} } \right\} \end{array} $ (6)

1.2 多维度聚合金字塔模型

多维度聚合金字塔(MAP)模型是在传统的瓦片金字塔模型基础上提出的时空多维层级聚合模型。在空间维以瓦片金字塔的方式进行逐级聚合,在时间维通过预先设定的时间粒度对数据进行划分重组,在属性维通过扁平化的属性聚合树进行各维度属性值的聚合。其中,时间维和空间维属于定位特征,二者构成的整体标识一个时空单元,并作为时空单元的Key,离散的属性维聚合树为Value,两者以键值对(Key-Value-Pair)的方式对应。这样在实现时空聚合的同时,属性维也随之聚合,得到一个包含空间、时间和属性维度的多维时空聚合金字塔模型,模型如图 1所示。

图 1 多维聚合金字塔模型
Fig. 1 Multidimensional aggregation pyramid model

对应第1.1节介绍的2D金字塔模型,同样可定义类似的概念和操作。

1) 聚合树(${\rm{faa\_tree}}$)。属性聚合树是对时空对象的属性各维度单元进行逐维度聚合形成的树形结构,以广度优先遍历的结果简化实际的存储空间。以图 1下方表格为例,表中有4条出租车的记录,每条记录包括“载客与否”、“车辆颜色”和“司机性别”3个属性,图中的4条记录通过统计聚合,得到右侧的属性聚合树结构,再对其做序列化,得到可结构化存储的定长1维数组,公式为

$ \mathit{\boldsymbol{fa}}{\mathit{\boldsymbol{a}}_ - }\mathit{\boldsymbol{tree}} = \left\{ {\mathit{\boldsymbol{a}}_{{\rm{ all }}}}, {\mathit{\boldsymbol{a}}_1}, {\mathit{\boldsymbol{a}}_2}, \cdots, {\mathit{\boldsymbol{a}}_n} \right\} $ (7)

式中,${\mathit{\boldsymbol{a}}_{{\rm{ all }}}}, {\mathit{\boldsymbol{a}}_1}, {\mathit{\boldsymbol{a}}_2}, \cdots, {\mathit{\boldsymbol{a}}_n}$为属性聚合树按照层次遍历得到的节点数组序列。相较于树形结构,定长数组结构为后续的储存以及处理提供了极大的便利。

2) 时空像素($ {\rm{ST - pixel}}$ )。有别于2D地图瓦片的像素零维特征,时空像素是1维结构,是容纳属性维信息的容器,也是MAP模型的最小数据单位。时空像素延伸了瓦片金字塔像素概念的内涵,除具有空间坐标范围,还添加了时间刻度坐标,公式为

$ \mathit{\boldsymbol{ST - pixel}} = \left\{ {l, x, y, t, {\rm{ }}\mathit{\boldsymbol{faa \_ tree}}{\rm{ }}} \right\} $ (8)

式中,$t$代表预设时间粒度的刻度坐标,${\mathit{\boldsymbol{faa \_ tree}}}$为属性聚合树,是可视化内容的真正来源。

3) 时空瓦片(${\rm{ST - tile}}$)。时空瓦片的概念类似于2D模型的瓦片,由时空像素组合而成。时空瓦片包含时空像素,时空像素挂载了属性维聚合树,就形成了一个可实现层级聚合的时空立方体。时空瓦片是MAP模型显示基础单位,是一个5元组,定义为

$ \mathit{\boldsymbol{ST - titl}} = \{ L, X, Y, T, {\rm{ }}\mathit{\boldsymbol{Tile\_faa}}{\rm{ }}\} $ (9)

式中,$L$是金字塔的层级,$X$$Y$是瓦片的行列号,$T$代表预设了时间粒度的刻度坐标,$\mathit{\boldsymbol{Tile\_faa}}$公式为

$ \mathit{\boldsymbol{Tile\_faa}} = \left\{ {{\mathit{\boldsymbol{A}}_{{\rm{ all }}}}, {\mathit{\boldsymbol{A}}_1}, {\mathit{\boldsymbol{A}}_2}, \cdots , {\mathit{\boldsymbol{A}}_n}} \right\} $ (10)

式中,${{\mathit{\boldsymbol{A}}_{{\rm{ all }}}}, {\mathit{\boldsymbol{A}}_1}, {\mathit{\boldsymbol{A}}_2}, \cdots, {\mathit{\boldsymbol{A}}_n}}$为瓦片中各像素的属性聚合树数组序列$\mathit{\boldsymbol{faa}}\_\mathit{\boldsymbol{tree}}$对应下标累加得到的瓦片层面的属性聚合树。

图 1和式(9)可以看出,定义的时空瓦片从概念上已经不再是2维的平面,因此需要对2维中的基本操作进一步的扩展。

1)$ {\rm{Extract}}$操作。除了提取地理位置信息,还需提取时间信息和属性维度,生成属性聚合树并序列化,操作为

$ \begin{array}{*{20}{c}} {{\rm{ Extract }}(l, \mathit{Lon}, \mathit{Lat}, w) = }\\ {{\rm{ }}\mathit{\boldsymbol{ST - pixel}}\left\{ {l, x, y, t{\rm{ , }}\mathit{\boldsymbol{faa}}{\rm{\_}}\mathit{\boldsymbol{tree}}} \right.\} } \end{array} $ (11)

2)$ {\rm{Group}}$操作。分为2步。第1步主要是建立时空像素与时空瓦片之间对应的映射关系,即求得像素应隶属的具体瓦片,从而不止在空间上定位,在时间上也进行定位操作,公式为

$ \begin{array}{l} Group\left( {\mathit{\boldsymbol{ST - pixel}}\left\{ {l, x, y, t{\rm{ , }}\mathit{\boldsymbol{faa}}{\rm{\_}}\mathit{\boldsymbol{tree}}} \right.\} } \right) = \\ \;\;\;\;\mathit{\boldsymbol{ST - titl}} = \left( {\left[ {{\mathit{l}_\mathit{n}}, X, Y, T, {\rm{ }}\mathit{\boldsymbol{Tile\_faa}}} \right.} \right) \end{array} $ (12)

式中,$t$, $T$表示$ {\rm{Group}}$操作需要的时间限定。因此通过式(12)可找出每一个像素所属的时空单元,将时空像素映射到具体的时空瓦片上。

$ {\rm{Group}}$操作的第2步是对所有映射相同时空瓦片的时空像素进行归约,聚合同一时间粒度下、同一地理范围的瓦片内的所有像素。与此同时,时空瓦片$\mathit{\boldsymbol{ST - tile}}$的聚合树$\mathit{\boldsymbol{Tile\_faa}}$是其中所有时空像素$\mathit{\boldsymbol{ST - pixel}}$的1维定长数组$\mathit{\boldsymbol{faa}}\_\mathit{\boldsymbol{tree}}$对应位置累加,公式为

$ \begin{array}{l} \mathit{\boldsymbol{ST - tile}}\mathit{\boldsymbol{.Tile\_faa}} = \\ \sum\limits_{i = 1}^{N = n} {\mathit{\boldsymbol{ST - pixel}}.} \mathit{\boldsymbol{faa}}{\rm{\_}}\mathit{\boldsymbol{tree}} \end{array} $ (13)

3) Key-value操作。拆分$\mathit{\boldsymbol{Tile\_faa}}$里的每一个节点,并分别将节点与瓦片的四叉树和时间$t$联合编码,生成Key。然后将每个节点对应的像素集合作为Value,生成键值对。Key-Value操作的真实意义即在时间段$t$内,该瓦片空间范围内发生的某一属性节点的事件统计结果。

4) Aggregate操作。需限定在同一时间$T$内,即对键值化之后的瓦片进行聚合,最终获得多维金字塔模型,公式为

$ \begin{array}{l} {\rm{Agg}}\left( {\mathit{\boldsymbol{ST - tile}}\left( {{l_n}, {X_{2i}}, {Y_{2i}}, T} \right., \mathit{\boldsymbol{Tile\_faa}}} \right), \\ \mathit{\boldsymbol{ST - tile}}\left( {{l_n}, {X_{2i}}, {Y_{2i + 1}}, T, \mathit{\boldsymbol{Tile\_faa}}} \right), \\ \mathit{\boldsymbol{ST - tile}}\left( {{l_n}, {X_{2i + 1}}, {Y_{2i}}, T, \mathit{\boldsymbol{Tile\_faa}}} \right), \\ \mathit{\boldsymbol{ST - tile}}\left( {{l_n}, {X_{2i + 1}}, {Y_{2i + 1}}, T, \mathit{\boldsymbol{Tile\_faa}}} \right))= \\ \mathit{\boldsymbol{ST - tile}}\left( {{l_{n - 1}}, {X_i}, {Y_i}, T, \mathit{\boldsymbol{Tile\_faa}}} \right), \end{array} $ (14)

2 时空大数据可视化框架

2.1 框架总体架构

为验证本文提出的MAP模型和可视化框架的有效性及性能,本文实现了一套时空数据可视化原型系统MAP-Vis,如图 2所示。

图 2 MAP-Vis系统架构
Fig. 2 The system architecture of MAP-Vis

MAP-Vis系统采用B/S架构,由客户端、中间件和后台集群3部分组成。其中,预处理及存储模块建构于Linux高性能集群之上,主要负责建立原始数据的多维金字塔模型和预处理数据的分布式存储。中间件包含数据访问接口,主要解析用户的查询请求,并从数据库端抽取相应数据作简单的统计操作。客户端主要负责对从后台获取的热图数据、时序数据和属性数据进行可视化。

2.2 时空数据预处理

在MAP数据模型构建中,数据自下而上不断聚合抽象,首先需完成最精细一层,即最大层级的时空瓦片,再不断往上层聚合迭代生成上面层级。迭代聚合过程的伪代码如下:

算法1:MAP模型预处理

输入:原始数据(包含经纬度、时间属性、其他维度属性),$R m(\operatorname{lng}, \text { lat, time, attributes }), m=1$, 2, …, $N$;空间最大层级$l_{n}$;时间粒度$t B i n$

输出:MAP模型

1:for each record Ri in Original Records do

2:  $\mathit{\boldsymbol{faa}}\_\mathit{\boldsymbol{tree}}$ = flatten(attributes)

3:  tj= tBin(time)

4:  $\mathit{\boldsymbol{ST - pixel}}$ij = $ {\rm{Extract}}$(lng, lat, ln, $\mathit{\boldsymbol{faa}}\_\mathit{\boldsymbol{tree}}$, tj)

5:end for

6:for each $\mathit{pixe}{\mathit{l}_{ij}}$ in the same $\mathit{tile}$ with $\mathit{til}{\mathit{e}_{\mathit{ij}}}$ do

7:  $ {\rm{Group}}$ $\mathit{pixe}{\mathit{l}_{ij}}$ to $\mathit{til}{\mathit{e}_{\mathit{ij}}}$

8:end for

9:for each $\mathit{til}{\mathit{e}_{\mathit{kj}}}$ with $\mathit{\boldsymbol{Tile\_faa}} = \left\{ {{\mathit{\boldsymbol{A}}_{{\rm{ all }}}}, {\mathit{\boldsymbol{A}}_1}, \cdots, {\mathit{\boldsymbol{A}}_s}} \right\}$ do

10:  Key-Value $\mathit{til}{\mathit{e}_{\mathit{kj}}}$ to $\mathit{til}{\mathit{e}_{\mathit{kj}}}$

11:end for

12: $t i l e_{l n} \longleftarrow \text { All }\left(\text { tile }_{k j s}\right)$

13:for $i=l_{n-1}, l_{n-2}, \cdots, 1$ do

14:  $t i l e_{l i}=\text { Aggregate }\left(t i l e_{l i+1}\right)$)

15:end for

16:return $t i l e_{l i}, i=0, 1, 2, \cdots, n$

预处理步骤如下:

1) 输入参数。包括预处理的原始记录、空间的最大层级$l_{n}$和时间粒度$t B i n$。提取原始记录的地理信息、时间信息和其他属性维度信息,得到每条记录对应的属性聚合树,并利用第1.2节介绍的$ {\rm{Extract}}$操作,得到相应的$\mathit{\boldsymbol{ST - pixel}}$

2) 利用Spark的MapReduce操作,将属于同一时间$t$内同一瓦片内的像素聚合起来,生成聚合数据。由于每个像素的属性聚合树是序列化之后的数组结构,属性聚合树中每一个下标索引即代表一种属性字段,所以可以进一步对属性聚合树下的各个属性字段进行聚合,得到每个瓦片在不同时间下不同属性维度的聚合数据。

3) 对应第1.2节介绍的$ {\rm{Group}}$操作,对瓦片的四叉树编码Quadkey、时间序列$t$和属性聚合树中的各个节点${A_n}$联合生成Key。聚合之后的像素集合作为Value,生成键值对。最终得到最大层级$l_{n}$中各属性节点下各个时间段的聚合数据,与第1.2节介绍的Key-Value操作相对应。

4) 生成最大层级$l_{n}$所有瓦片序列后,根据金字塔逐层聚合关系不断聚合即可以逐层得到${\mathit{l}_{\mathit{n} - 2}}, {\mathit{l}_{\mathit{n} - 3}}, \cdots, 1$层级的瓦片数据,构建多维度的聚合金字塔,对应第1.2节介绍的Aggregate操作。

2.3 数据组织与存储

为增强MAP-Vis的存储扩展性,本文选择分布式的HBase作为存储数据库。HBase作为Google BigTable的开源实现,是一款分布式、多版本、面向列存储的非关系型数据库[14-15],主要用于存储海量的结构化数据。底层以HDFS作为存储系统,具有可伸缩、随机实时读写、高可靠性的特点。MAP模型中,一个带有属性节点的时空瓦片可以由四叉树编码Quadkey、属性节点${A_n}$和时间坐标$t$等3个坐标唯一确定。结合HBase的数据存储模型特征,本文定义了MAP模型在HBase的存储方案:横向上以Quadkey+${An}$联合编码的方式作为每一行的Rowkey,设置Heatmap和Sum两个列族。Heatmap列族按照时间刻度坐标设置各列,负责存储相应时间坐标$t$下的热图数据。Sum列族同样按照时间刻度坐标设置各列,负责存储相应时间坐标$t$下热图数据中所有像素的采样总值。

本框架的HBase表结构设计将既定的属性维度加入到Rowkey中,让时间做横向扩展,属性做纵向扩展,充分体现了HBase列式数据库的优势。该设计的出发点是若时间维度信息加入Rowkey,则会因数据时间序列过长导致Rowkey的数目急剧增加,从而影响查询效率。对于属性维度而言,一般可视化关注的属性维度数量有限,属性聚合树层级不会过大。

2.4 面向可视化的多维查询

HBase数据的访问方式通常是使用全盘扫描(Scan)或单点查询(Get)两种模式。用户获取数据后在客户端进行业务运算。在返回数据量非常大的情况下,通过上述两种模式获取数据就会在网络I/O层面遇到瓶颈。为此HBase提出了协处理器(CoProcessor)的概念。通过协处理器可以在服务器端对查询范围内的结果进一步聚合,得到中间聚合结果返回客户端,从而提高查询效率。图 3为MAP-Vis系统基于HBase协处理器概念实现的时空查询示意图。

图 3 MAP-Vis系统的多维查询
Fig. 3 The multidimensional query in MAP-Vis

可视化所需的查询是时间、空间、属性查询等多维度的联动查询。即客户端发送请求后,中间件先分析请求参数,然后将请求内容分解为时间、空间、属性等具体查询类别,对HBase数据库进行查询,各个Region的数据通过协处理器再聚合后返回给客户端。

时间/空间查询采用的是异步请求,即每一张瓦片单独向服务端发送查询请求。当服务端接收到查询请求操作时,中间件将请求参数解析为HBase数据库的时间/空间过滤条件,行键Rowkey为瓦片四叉树编码Quadkey与属性索引位置组合,列限定符为查询时间范围内的各个时间刻度坐标$t$,经初次查询后可以得到各个时间坐标的聚合数据。再调用HBase数据库端的协处理器,将查询时间范围内各时间节点的数据做聚合计算,得到最终的聚合结果, 然后返回前端渲染。

属性查询的接收参数与时间/空间相同,在得到相应时间范围的数据后,统计各个类别的数据总和,在中间件上进一步统计整个时间/空间范围内的瓦片序列的每一个类别节点的总值,最后将结果提交至服务端进行前端渲染绘制。

3 实验结果及分析

实验以纽约曼哈顿区的出租车数据为可视化对象,该数据集记录了2014年1月~2016年6月共30个月的出租车信息。单条记录包含出租车乘客的上下车空间位置和乘客支付方式等其他信息。大小共约54.5 GB,总记录约5亿条。图 4是MAP-Vis框架实现的出租车数据可视化原型界面,基于HTML、CSS和Javascript实现,地图底图使用OpenStreetMap数据[16],地图显示使用Leaflet库[17]进行交互,时间轴和属性柱状图使用d3[18]库进行交互。

图 4 MAP-Vis系统原型界面
Fig. 4 The web interface of MAP-Vis

实验从MAP模型的有效性、存储扩展性和预处理能力扩展性等3个角度测试了MAP-Vis数据的可视化性能。集群测试的基本环境共9个节点,配置如表 1所示。

表 1 计算节点基本信息
Table 1 The basic information of computing nodes

下载CSV
属性 配置信息
CPU 双路六核Intel(R)Xeon(R) E5-2620 2 GHz
Memory 32 GB
Network 1 Gbps
OS CentOS 6.2 64 bit
JVM JVM 1.8.0
HBase HBase 1.2.0
Spark Spark1.6.0
Zookeeper Zookeeper 3.4.5

3.1 MAP模型的有效性

实验以查询的聚合数据对应的原始数据的大小作为自变量,并通过改变查询的时间跨度对其进行控制。原始数据共30个月,本文以3个月为间隔,调整预处理前的原始数据的大小,对地图进行完全相同的操作(放大/缩小/平移),统计各自的平均响应时间,MAP模型随原始数据容量的变化趋势如图 5所示。

图 5 不同数据容量的响应时间
Fig. 5 Response time with different data size

图 5可以看出,响应延迟稳定在700 ~1 000 ms之间,能够保证亚秒级的响应,达到流畅的交互可视化体验。随着原始数据规模的扩大,响应时间曲线基本保持平稳,未呈明显的线性增长。说明MAP模型应用于可视化时能够很好地适应大规模的时空数据集。

3.2 MAP数据分布式存储扩展性

实验以HBase集群使用的Region数目作为自变量,观察查询响应时间的变化。原始数据是2014和2015年24个月的数据, 共47 GB,实验结果如图 6所示。

图 6 不同Region数的响应时间
Fig. 6 Response time with different HBase Regions

图 6中,实线是响应时间的变化趋势,虚线是查询效率提升比例。从图 6可以看出,随着集群Region数目的增加,整体的响应时间不断下降,从3.2 s减少到0.9 s,效率提升约2.4倍,这是因为数据存储得更加分散,单个Region访问频率降低,访问排队时间也随之减少。因此,本框架通过增加Region的数量提升了查询效率,充分体现了集群分布式优势,显著改善了可视化交互体验。

3.3 MAP数据预处理能力扩展性

实验以Spark预处理集群为实验对象,以集群的计算节点数作为自变量,统计预处理时间变化(不包括导入HBase数据库的时间)。预处理的原始数据为30个月数据, 共54 GB,预处理时间的变化趋势如图 7所示。

图 7 不同节点数的预处理时间
Fig. 7 Preprocess time with different processing nodes

图 7可以看出,节点的增加使得预处理时间呈明显下降趋势,从360 min下降到160 min,效率提升约1.3倍。因此,通过引入更多的计算节点,Spark集群有更多的Worker节点和Executor进程分摊预处理任务,从而显著提高预处理效率。

4 结论

时空大数据因海量、时空、高维等特征,使得可视化存在内存消耗大、渲染延迟高、可视效果差等问题。为解决该问题,本文提出了一种融合瓦片金字塔模型和键值对化方法的时空大数据组织模型:多维度聚合金字塔(MAP),并设计实现了一套基于MAP模型的开源可视化框架(MAP-Vis)。MAP组织模型能够同时考虑时间和空间维度,兼顾属性信息,三者逐级聚合汇聚,适应时空大数据快速高可视化。设计的开源可视化框架(MAP-Vis)以Spark作为预处理工具,以分布式HBase数据库作为存储平台。其中,HBase持久化存储MAP模型数据具备高可扩展性,时空查询高效,充分体现了分布式存储与计算的优势,实现亚秒级数据查询与读取,达到良好的交互式可视化效果。

后续将在以下方面对MAP-Vis进一步完善:1)推广至线/面类型数据;2)支持对矩形、多边形查询;3)添加分析功能模块,将MAP-Vis扩展成完整的可视分析系统。

参考文献

  • [1] Li D R, Ma J, Shao Z F. The theory of space time big data and its application[J]. Satellite Application, 2015(9): 7–11. [李德仁, 马军, 邵振峰. 论时空大数据及其应用[J]. 卫星应用, 2015(9): 7–11. ]
  • [2] Ren L, Du Y, Ma S, et al. Visual analytics towards big data[J]. Journal of Software, 2014, 25(9): 1909–1936. [任磊, 杜一, 马帅, 等. 大数据可视分析综述[J]. 软件学报, 2014, 25(9): 1909–1936. ] [DOI:10.13328/j.cnki.jos.004645]
  • [3] Godfrey P, Gryz J, Lasek P. Interactive visualization of large data sets[J]. IEEE Transactions on Knowledge and Data Engineering, 2016, 28(8): 2142–2157. [DOI:10.1109/TKDE.2016.2557324]
  • [4] Tigani J, Naidu S. Google BigQuery Analytics[M]. John Wiley & Sons, 2014.
  • [5] Root C, Mostak T. MapD: a GPU-powered big data analytics and visualization platform[C]//Proceedings of ACM SIGGRAPH 2016 Talks. Anaheim, California: ACM, 2016: #73.[DOI: 10.1145/2897839.2927468]
  • [6] Gray J, Chaudhuri S, Bosworth A, et al. Data cube:a relational aggregation operator generalizing group-by, cross-tab, and sub-totals[J]. Data Mining and Knowledge Discovery, 1997, 1(1): 29–53. [DOI:10.1023/A:1009726021843]
  • [7] Sismanis Y, Deligiannakis A, Kotidis Y, et al. Hierarchical dwarfs for the rollup cube[C]//Proceedings of the 6th ACM International Workshop on Data Warehousing and OLAP. New Orleans, Louisiana, USA: ACM, 2003: 17-24.[DOI: 10.1145/956060.956064]
  • [8] Liu Z, Jiang B, Heer J. imMens: real-time visual querying of big data[C]//Computer Graphics Forum. Oxford, UK: Blackwell Publishing Ltd, 2013, 32(3pt4): 421-430.
  • [9] Lins L, Klosowski J T, Scheidegger C. Nanocubes for real-time exploration of spatiotemporal datasets[J]. IEEE Transactions on Visualization and Computer Graphics, 2013, 19(12): 2456–2465. [DOI:10.1109/TVCG.2013.179]
  • [10] Im J F, Villegas F G, Mcguffin M J. VisReduce: fast and responsive incremental information visualization of large datasets[C]//Proceedings of 2013 IEEE International Conference on Big Data. Silicon Valley, CA, USA: IEEE, 2013: 25-32.[ DOI:10.1109/BigData.2013.6691710]
  • [11] Cheng D L, Schretlen P, Kronenfeld N, et al. Tile based visual analytics for twitter big data exploratory analysis[C]//Proceedings of 2013 IEEE International Conference on Big Data. Silicon Valley, CA, USA: IEEE, 2013: 2-4.[DOI: 10.1109/BigData.2013.6691787]
  • [12] Zaharia M, Chowdhury M, Franklin M J, et al. Spark: cluster computing with working sets[C]//Proceedings of the 2nd Usenix Conference on Hot Topics in Cloud Computing. Boston, MA, USA: ACM, 2010: 10.
  • [13] Fox A, Eichelberger C, Hughes J, et al. Spatio-temporal indexing in non-relational distributed databases[C]//Proceedings of 2013 IEEE International Conference on Big Data. Silicon Valley, CA, USA: IEEE, 2013: 291-299.[DOI: 10.1109/BigData.2013.6691586]
  • [14] Dimiduk N, Khurana A. HBase in Action[M]. New York: Manning Publications, 2012.
  • [15] George L. HBase:the definitive guide[J]. Andre, 2011, 12(1): 1–4.
  • [16] Haklay M, Weber P. OpenStreetMap:user-generated street maps[J]. IEEE Pervasive Computing, 2008, 7(4): 12–18. [DOI:10.1109/MPRV.2008.80]
  • [17] Agafonkin V. Leaflet: an open-source JavaScript library for mobile-friendly interactive maps[EB/OL].[2018-06-01] http://leafletjs.com.
  • [18] Bostock M, Ogievetsky V, Heer J. D3 data-driven documents[J]. IEEE Transactions on Visualization and Computer Graphics, 2011, 17(12): 2301–2309. [DOI:10.1109/TVCG.2011.185]