Given an RDD[(SpatialKey, Tile)]
in GeoTrellis, how do I compute the aggregate KeyBounds[SpatialKey]
?
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.