This topic describes how to use DLA Ganos to load raster data from PolarDB.

Procedure

  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. Initialize connection parameters.
    val options = Map(
        "url" -> "jdbc:postgresql://121.43.XX.XX:5432/ganos_demodb",
        "user" -> "postgres",
        "password" -> "Ganos@2020",
        "dbtable" -> "gf",
        "numPartitions" -> "4")val options = Map(
        "url" -> "jdbc:postgresql://121.43.XX.XX:5432/ganos_demodb",
        "user" -> "postgres",
        "password" -> "Ganos@2020",
        "dbtable" -> "gf",
        "numPartitions" -> "4")
  3. Load the catalog table.
     val cat = spark.read.ganos.polardbRasterCatalog(options)
  4. View the results.

    The catalog table contains the IDs of layers and metadata, and supports spatio-temporal queries.

    • You can specify the ID and zoom to load a specific layer. The default value of z is 0, which indicates the lowest level of the pyramid.
      val layer = spark.read.ganos.polardbRasterImage(options).load(id, zoom)
      Important Multi-band images are automatically split into multiple single-band tiles for display.
    • You can also load multiple layers at the same time based on the collection of layer IDs.
      val layers = spark.read.ganos.polardbRasterCover(options).load(Seq[id], zoom)