The RESTful API of ApsaraDB for HBase Ganos (HBase Ganos) uses the GeoJSON format to describe spatio-temporal data. For more information, see The GeoJSON Format.
The following sample code shows the typical data format of a spatio-temporal point. A spatio-temporal point can be considered as a trajectory point. The following example shows the data format:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands",
"dtg": 1536041936000,
"id": "1"
}
}The data consists of three parts:
- Time data: The data is stored as attribute information in properties.dtg. In this example, the time data is a timestamp in milliseconds. A timestamp is a 13-digit integer.
- Spatial data: The geometry.type parameter indicates that the spatial data is the data of a point. The geometry.coordinates parameter indicates the latitude and longitude coordinates of the point.
- Other attributes: Other attributes of the point are stored in properties, such as properties.name and properties.id.
GeoJSON libraries
You can use GeoJSON libraries to generate GeoJSON strings.
- The geojson-jackson library for Java. For more information about geojson-jackson, see geojson-jackson. The following code provides an example on the basic usage of GeoJSON in Java:
FeatureCollection featureCollection = new FeatureCollection(); featureCollection.add(new Feature()); String json= new ObjectMapper().writeValueAsString(featureCollection); - pythonRun the following command to install GeoJSON:
The following code provides an example on the basic usage of GeoJSON for Python:pip install geojsonpoint_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])