HBase Ganos的REST接口采用GeoJson形式来描述时空数据,详细可参考GEOJSON RFC
一个典型的时空”点”数据(可理解为轨迹点)格式如下:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands",
"dtg": 1536041936000,
"id": "1"
}
}
整个数据可分为三部分:
为了方便的生成GeoJson串,可使用通用的GeoJson库
FeatureCollection featureCollection = new FeatureCollection();
featureCollection.add(new Feature());
String json= new ObjectMapper().writeValueAsString(featureCollection);
使用如下语句引入geojson包:
pip install geojson
基本使用方式为:
point_feature = Feature(id="1",geometry=Point((1.6432, -19.123)),properties={"id":"1","dtg":1536041936000,"name": "Dinagat Islands"})
polygon_feature = Feature(id="my_feature2",geometry=Polygon([(0,0),(0,1),(1,1),(1,0),(0,0)]),properties={"id":"2","dtg":1536041936000,"name": "Dinagat Islands"})
feature_collection = FeatureCollection([point_feature,polygon_feature])
在文档使用中是否遇到以下问题
更多建议
匿名提交