2

Given an RDD[(SpatialKey, Tile)] in GeoTrellis, how do I compute the aggregate KeyBounds[SpatialKey]?

metasim
  • 4,793
  • 3
  • 46
  • 70

1 Answers1

4

For any RDD[(K, V])] where K is Boundable, i.e. there is an implicit Boundable[K] in scope, you can do:

val bounds: KeyBounds[K] =
  tiles.map({ case (key, _) => KeyBounds(key, key) }).reduce(_ combine _)

This will work over SpatialKey and SpaceTimeKey, as GeoTrellis provides the implicit Boundable typeclasses for those types. So in your case,

val bounds: KeyBounds[SpatialKey] =
  tiles.map({ case (key, _) => KeyBounds(key, key) }).reduce(_ combine _)

will work.

Rob
  • 855
  • 7
  • 8