Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.21 KB | None | 0 0
  1. package com.yourcompany.raster
  2.  
  3. import geotrellis.spark._
  4. import geotrellis.spark.io.hadoop._
  5. import org.apache.hadoop.fs.Path
  6.  
  7. val zoomLevel = 14 // Zoom level we'll be working with throughout.
  8.  
  9. val hc = HadoopCatalog(sc, new Path("hdfs://localhost.localdomain/user/cloudera/catalog") )
  10.  
  11. // Not sure how to rename, a lot of info in those var names...is that necessary in this context?
  12. val ras594321_14 = hc.load[SpatialKey](LayerId("594321_GSY", zoomLevel) )
  13. val ras670385_14 = hc.load[SpatialKey](LayerId("670385_GSY", zoomLevel) )  
  14.  
  15. val result = (ras670385_14 + ras594321_14) / 80
  16. val resultId = LayerId("result_raster", zoomLevel)
  17.  
  18. hc.save[SpatialKey](resultId, result)
  19.  
  20. // Load it back out
  21. val reloadedResult = hc.load[SpatialKey](resultId)
  22.  
  23. // Check to see that the result and the reloaded result are equal.
  24. result.combinePairs(reloadedResult) { case ((_, originalTile), (_, reloadedTile)) =>
  25.   val (cols1, rows1) = originalTile.dimensions
  26.   val (cols2, rows2) = reloadedTile.dimensions
  27.  
  28.   assert(cols1 == rows1)
  29.   assert(cols2 == rows2)
  30.  
  31.   for(row <- 0 until rows1) {
  32.     for(col <- 0 until cols1) {
  33.       assert(originalTile.getDouble(col, row) == reloadedTile.getDouble(col, row))
  34.     }
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement