一、Geomesa概述
Geomesa是Apache协议的开源项目,用来处理地理数据的分布式基础引擎。,其核心的模块就并不多,主要就geomesa-spark-core、geomesa-Spark JTS、geomesa-Spark Sql,在开发过程中发现起始用的最多的也就是geomesa-spark-core了
Geomesa支持的数据源很多,Hbase、Accumulo 、Cassandra 、Bigtable Redis 、Kafka 、FileSystem 、Geotools等等十几种。
主要开发功能:
(1)Shp数据源的读取和数据转存
(2)空间数据裁剪功能
(3)缓冲区分析功能
(4)两个图层的相交分析功能
(5)空间数据查询功能
(6)图层差异分析
......
以上的分析都不包含图层的展示功能,都是对底层数据的直接处理能力,桌面工具用的QGIS
二、Geomesa命令行
1.创建表
执行“create-schema”命令创建表,创建表时至少要指定目录名称(-c geomesa)与表名称(-f test),以及表规格(Who:String,What:java.lang.Long,When:Date,*Where:Point:srid=4326,Why:String)。
bin/geomesa-hbase create-schema -c geomesa -f test -s Who:String,What:java.lang.Long,When:Date,*Where:Point:srid=4326,Why:String
打开hbase监控界面(端口:16010),可以看创建的表
2.描述表
执行“describe-schema”命令获取表描述信息,描述表信息时必须要指定目录名称与表名称。
bin/geomesa-hbase describe-schema -c geomesa -f test
3.获取目录中全部表的名称
bin/geomesa-hbase get-type-names -c geomesa
4.删除表
执行“remove-schema”命令删除表,删除表示至少要指定表所在的目录与表名称。
bin/geomesa-hbase remove-schema -c geomesa -f test
bin/geomesa-hbase remove-schema -c geomesa -f example
5.删除目录
执行“delete-catalog”命令删除指定的目录
bin/geomesa-hbase delete-catalog -c geomesa
6.批量导入数据
执行“ingest”命令批量导入数据,导入时需要指定目录名称,表名称,表规格,以及相应的数据转换器等。
数据准备:数据(车牌号,车辆颜色,经度,维度,时间):data.csv,并将数据表放在data文件夹中。
AAA,red,113.918417,22.505892,2017-04-09 18:03:46
BBB,white,113.960719,22.556511,2017-04-24 07:38:47
CCC,blue,114.088333,22.637222,2017-04-23 15:07:54
DDD,yellow,114.195456,22.596103,2017-04-21 21:27:06
EEE,black,113.897614,22.551331,2017-04-09 09:34:48
表结构定义:myschema.sft,并将myschema.sft放在geomesa命令行工具的conf文件夹中。
geomesa.sfts.cars = {
attributes = [
{ name = "carid", type = "String", index = true }
{ name = "color", type = "String", index = false }
{ name = "time", type = "Date", index = false }
{ name = "geom", type = "Point", index = true,srid = 4326,default = true }
]
}
定义转换器:testconvertor.convert
geomesa = {
sfts = {
example = {
type-name = "example"
attributes = [
{ name = "carid", type = "String", index = true }
{ name = "color", type = "String", index = false }
{ name = "double_0", type = "Double", index = false }
{ name = "double_1", type = "Double", index = false }
{ name = "time", type = "Date", index = false }
{ name = "geom", type = "Point", index = true,srid = 4326,default = true }
]
}
}
}
导入数据:
geomesa-hbase ingest --catalog geomesa --feature-name cars --input-format csv -C conf/testconvertor.convert -s conf/myschema.sft "data/data.csv"
7.解释查询
执行“explain”命令获取指定查询语句执行计划的解释说明,解释语句时必须指定目录名称和表名称,以及给定查询语句。
bin/geomesa-hbase explain -c geomesa -f cars -q "carid = 'BBB'"
8.统计分析
执行“stats-analyze”命令对数据表进行统计分析,同时还可以进一步执行“stats-bounds”,“stats-count”,“stats-histogram”,“stats-top-k”命令对数据表做更详细的统计。
bin/geomesa-hbase stats-analyze -c geomesa -f cars
bin/geomesa-hbase stats-bounds -c geomesa -f cars
bin/geomesa-hbase stats-count -c geomesa -f cars
bin/geomesa-hbase stats-histogram -c geomesa -f cars
bin/geomesa-hbase stats-top-k -c geomesa -f cars