Skip to content

Commit

Permalink
Merge pull request #547 from jbouffard/improvement/rasterSummary
Browse files Browse the repository at this point in the history
RasterSummary Performance Improvement
  • Loading branch information
Jacob Bouffard committed Nov 28, 2017
2 parents c237ebb + 8b707c9 commit 54d8716
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import geotrellis.util._
import geotrellis.vector.{Extent, ProjectedExtent}
import org.apache.spark.rdd.RDD

import scala.collection.immutable.HashMap
import scala.reflect.ClassTag

case class RasterSummary[K](
Expand Down Expand Up @@ -56,9 +55,11 @@ object RasterSummary {
// the spatial KeyBounds are set outside this call.
val boundsKey = key.translate(SpatialKey(0,0))
val cellSize = CellSize(extent, grid.cols, grid.rows)
HashMap(crs -> RasterSummary(crs, grid.cellType, cellSize, extent, KeyBounds(boundsKey, boundsKey), 1))
(crs -> RasterSummary(crs, grid.cellType, cellSize, extent, KeyBounds(boundsKey, boundsKey), 1))
}
.reduce { (m1, m2) => m1.merged(m2){ case ((k,v1), (_,v2)) => (k,v1 combine v2) } }
.values.toSeq
.reduceByKey { _ combine _ }
.values
.collect
.toSeq
}
}
}

0 comments on commit 54d8716

Please sign in to comment.