操作步骤

  1. 准备数据
    将样例数据上传至OSS指定目录下:
    oss://bucket名称/3320D_2010_315_RGB_LATLNG.tif
  2. 加载OSS数据
    新建工程dla-ganos-examples,在pom.xml中添加依赖:
    <dependency>
         <groupId>com.aliyun.ganos</groupId>
      <artifactId>dla-ganos-sdk</artifactId>
      <version>1.0</version>
    </dependency>
    创建scala文件OSSTest.scala
    import com.aliyun.ganos.dla._
    import com.aliyun.ganos.dla.raster._
    import com.aliyun.ganos.dla.oss._
    import com.aliyun.ganos.dla.geometry._
    import com.typesafe.config.ConfigFactory
    import org.apache.log4j.{Level, Logger}
    import org.apache.spark.SparkConf
    import org.apache.spark.sql.SparkSession
    
    object OSSTest extends App {
    
      Logger.getLogger("org").setLevel(Level.ERROR)
      Logger.getLogger("com").setLevel(Level.ERROR)
      val spark: SparkSession = {
        val session = SparkSession.builder
          .withKryoSerialization
          .config(additionalConf)
          .getOrCreate()
        session
      }
    
      spark.withGanosGeometry
      spark.withGanosRaster
    
      val uri = new java.net.URI("oss://ape-data/raster")
    
      val options = Map(
        "crs"->"EPSG:4326",
        "endpoint" -> "EndPoint地址",
        "accessKeyId" -> "用户AccessKeyID",
        "accessKeySecret" -> "用户AccessKeySecret")
      
      val rf = spark.read.ganos.oss(options).loadLayer(uri)
      rf.show
      def additionalConf = new SparkConf(false)
    }
    编译工程:
    mvn clean package

    输出dla-ganos-examples-1.0.jar包,并将Jar包上传至OSS。

  3. 提交任务33
    1. 登录DLA控制台
    2. 在左侧导航栏单击Serverless Spark > 作业管理进入作业管理页面。(图示中①)
    3. 单击创建作业(图示中②),输入相关参数后,在编辑处输入如下命令:
      {
          "name": "OSSTest",
          "file": "oss://ape-data/dla-ganos-examples-1.0.jar",
          "className": "com.aliyun.ganos.dla.examples.OSSTest",
          "conf": {
              "spark.driver.resourceSpec": "medium",
              "spark.executor.instances": 2,
              "spark.executor.resourceSpec": "medium"
          }
      }
    4. 输入完成后左上角执行按钮(图示中③),执行命令。
    5. 在作业运行状态为SUCCESS后(图示中④),即可查看作业状态。11