This topic describes how to use DLA Ganos to query and compute raster data in Lindorm (HBase Enhanced Edition) based on GeoTrellis.

GeoTrellis is a geographic data processing engine that is developed based on Spark. GeoTrellis can read, write, and manage raster data at a fast speed. It also supports a large number of geometric operations. For more information about GeoTrellis, see https://geotrellis.readthedocs.io/en/latest/.

Read raster data

  1. Initialize a Spark session.
     val spark: SparkSession = {
        val session = SparkSession.builder
          .master("local[*]")
          .withKryoSerialization
          .config(additionalConf)
          .getOrCreate()
        session
      }
    
     // Load the Raster driver of DLA Ganos.
     spark.withGanosRaster
  2. Use the GeoTrellis catalog to load the catalog table.
    val inputUri = "hbase://ID of the hb-proxy-pub-hbase instance-001.hbase.rds.aliyuncs.com:2181? master=localhost&attributes=GF1C"
    val cat=spark.read.ganos.geotrellisCatalog(URI.create(inputUri))
    cat.show
    The catalog table contains the IDs of layers and metadata, and supports spatio-temporal queries.
    val layer = cat.where($"layer.id.zoom" === "2").select(raster_layer).collect
    • You can obtain layer IDs and load data by using the catalog table.
       val lots = layer.map(spark.read.ganos.geotrellis.loadLayer).map(_.toDF).reduce(_ union _)
      lots.show
    • You can also call the loadLayers interface to load multiple layers at the same time.
      val df = spark.read.ganos.geotrellis.loadLayers(layers)

Generate raster data

You can write the DataFrame model to the Lindorm table.
lazy val layer = Layer(scratchDir.toUri, LayerId("test-layer", 4))
df.write.ganos.geotrellis.asLayer(layer).save()