Scala:java.lang.IllegalArgumentException:要求失败:nonEmpty输入

时间:2016-03-18 15:00:21

标签: scala apache-spark

我编写了一个代码来处理tiff文件,映射代数操作并将结果存储为tiff文件。当我运行代码时出现此错误。我只向代码传递一个参数,这是一个文件路径。可能导致错误的原因是什么?

错误:

Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: nonEmpty input
        at scala.Predef$.require(Predef.scala:233)
        at geotrellis.spark.stitch.TileLayoutStitcher$.stitch(StitchRDDMethods.scala:21)
        at geotrellis.spark.stitch.SpatialTileLayoutRDDMethods.stitch(StitchRDDMethods.scala:42)
        at RasterData.RasterOperations.MapAlgebraOperations$.readHdfsTiles(MapAlgebraOperations.scala:97)
        at RasterData.RasterOperations.MapAlgebraOperations$.main(MapAlgebraOperations.scala:27)
        at RasterData.RasterOperations.MapAlgebraOperations.main(MapAlgebraOperations.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:685)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:120)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

代码:

object MapAlgebraOperations {

   def main(args: Array[String]) : Unit = {
     readHdfsTiles(args(0))
   }


   def readHdfsTiles(readpath: String): TileLayerRDD[SpatialKey] = {

    implicit val sc = SparkUtils.createSparkContext("MapAlgebra")

    //layer name for reading the RasterRDD
    val nlcd1 = new String("nlcd1")
    val nlcd2 = new String("nlcd2")

    //Hadoop Tiles Location 
    val HdfsPath = new Path(readpath)

    val reader = HadoopLayerReader(HdfsPath)(sc)
    val rastereurope = reader.read[SpatialKey, Tile, TileLayerMetadata[SpatialKey]](LayerId(nlcd1, 1))
    val rasterasia = reader.read[SpatialKey, Tile, TileLayerMetadata[SpatialKey]](LayerId(nlcd2, 1))

    // Local Operations on Tiles
    // Add 100 to each cell on raster Europe 
    val AddRasterEurope: RDD[(SpatialKey, Tile)] with Metadata[TileLayerMetadata[SpatialKey]] = rastereurope.withContext { _ localAdd 100 }

    // Subtract 5 to each cell on raster Asia 
    val SubtractRasterAsia: RDD[(SpatialKey, Tile)] with Metadata[TileLayerMetadata[SpatialKey]] = rasterasia.withContext { _ localSubtract 1 }

    // Union
    val EuropeUnionAsia: RDD[(SpatialKey, Tile)] with Metadata[TileLayerMetadata[SpatialKey]] = rastereurope.withContext { _ union(SubtractRasterAsia) }

    //Intersection
    val EuropeIntersectAsia: RDD[(SpatialKey, Tile)] with Metadata[TileLayerMetadata[SpatialKey]] = rastereurope.withContext { _ intersection(rasterasia) }

    //focal operations on Europe
    val focalEurope = rastereurope.focalMean(Circle(5))

    //Chain Focal Operations
    val focalEuropeChain = focalEurope.focalMean(Circle(5))

    //LeftOuterJoin
    //val LeftOuterJoin = rastereurope.leftOuterJoin(rasterasia).updateValues(Add(_, _))

    //Crop India from Asia

    //Spatial Join
    //val EuropeSpatialJoinAsia = rastereurope.spatialJoin(rasterasia)

    //Define new layer  
    //val layerid1 = new LayerId("newnlcd1",1)
    //val layerid2 = new LayerId("newnlcd2",1)
    //val layerid3 = new LayerId("newnlcd3",1)

    //Writing the resultant RDD to HDFS
    //val writer = HadoopLayerWriter(HdfsPath)(sc)
    //writer.write(layerid1, rddWithContext, ZCurveKeyIndexMethod)
    //writer.write(layerid2, rddWithContext1, ZCurveKeyIndexMethod)
    //writer.write(layerid3, rddWithContext2, ZCurveKeyIndexMethod)

    //Convert the data into GeoTiff
    val addrasterEurope = AddRasterEurope.stitch
    GeoTiff(addrasterEurope, AddRasterEurope.metadata.crs).write("/home/brillio/tiffs/AddRasterEurope.tiff")

    val subrasterAsia = SubtractRasterAsia.stitch
    GeoTiff(subrasterAsia, SubtractRasterAsia.metadata.crs).write("/home/brillio/tiffs/SubtractRasterAsia.tiff")

    val rasterUnion = EuropeUnionAsia.stitch
    GeoTiff(rasterUnion, EuropeUnionAsia.metadata.crs).write("/home/brillio/tiffs/EuropeUnionAsia.tiff")

    val rasterIntersect = EuropeIntersectAsia.stitch
    GeoTiff(rasterIntersect, EuropeIntersectAsia.metadata.crs).write("/home/brillio/tiffs/EuropeIntersectAsia.tiff")

    val rasterfocal = focalEurope.stitch
    GeoTiff(rasterfocal, focalEurope.metadata.crs).write("/home/brillio/tiffs/rasterfocal.tiff")

    val rasterChainfocal = focalEuropeChain.stitch
    GeoTiff(rasterChainfocal, focalEuropeChain.metadata.crs).write("/home/brillio/tiffs/rasterChainfocal.tiff")

    //val EuropeLeftOuterAsia = LeftOuterJoin.stitch
    //GeoTiff(EuropeLeftOuterAsia, LeftOuterJoin.metadata.crs).write("/home/brillio/tiffs/rasterChainfocal.tiff")

    //val rasterres3 = EuropeSpatialJoinAsia.stitch
    //GeoTiff(rasterres3, EuropeSpatialJoinAsia.metadata.crs).write("/home/brillio/tiffs/EuropeSpatialJoinAsia.tiff")
    AddRasterEurope

}
}

0 个答案:

没有答案