Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geotrellis-user] Geotrellis Custom Tile Metadata

Hey Rob,

Thanks for the quick pointer.  I have been looking deeper into the TileFeature class and the tileToLayout implicit method.  As you recommended, the TileFeature class fits exactly what we want but I am having trouble getting the toTileLayout method to work over the type: RDD[(ProjectedExtent, TileFeature[Tile, CustomMetadata])]

I keep getting compilation errors.  I pasted some sample code below (the first test method compiles but the second does not):


package tmptest

import geotrellis.raster.{CellType, Tile, TileFeature}
import geotrellis.vector.ProjectedExtent
import org.apache.spark.rdd.RDD
import geotrellis.spark.tiling.LayoutDefinition
import geotrellis.spark._

class TestClass {
  def runTileToLayoutCompiles(): Unit = {

    val cellType: CellType = null
    val layoutDefinition: LayoutDefinition = null

    val test1: RDD[(ProjectedExtent, Tile)] = null
    val output1: RDD[(SpatialKey, Tile)] = test1.tileToLayout(cellType, layoutDefinition)
  }

  def runTileToLayoutCompileErrors(): Unit = {
    val cellType: CellType = null
    val layoutDefinition: LayoutDefinition = null

    val test2: RDD[(ProjectedExtent, TileFeature[Tile, CustomMetadata])] = null
    val output2: RDD[(SpatialKey, TileFeature[Tile, CustomMetadata])] = test2.tileToLayout(cellType, layoutDefinition)
  }

}

case class CustomMetadata() {
}

# Compilation output
[error] .../tmptest/TestClass.scala:24: value tileToLayout is not a member of org.apache.spark.rdd.RDD[(geotrellis.vector.ProjectedExtent, geotrellis.raster.TileFeature[geotrellis.raster.Tile,tmptest.CustomMetadata])]
[error]     val output2: RDD[(SpatialKey, TileFeature[Tile, CustomMetadata])] = test2.tileToLayout(cellType, layoutDefinition)



I searched through the code and the TilerMethods class seems to be the only one that defines the 'tileToLayout' method.  However in those method definitions I see no hint for the restrictions on the class type:

# TilerMethods class excerpt
  def tileToLayout[K2: SpatialComponent: ClassTag](cellType: CellType, layoutDefinition: LayoutDefinition)
      (implicit ev: K => TilerKeyMethods[K, K2]): RDD[(K2, V)] =
    tileToLayout(cellType, layoutDefinition, Options.DEFAULT)


I must admit I'm still learning the more advanced Scala features and implicits have my head spinning.  How can I track down when implicit methods are allowed over certain classes but not others?  I extended the Tile class with a subclass, CustomSublclassOfTile, but that still led to compilation errors when calling the tileToLayout method over the type RDD[(ProjectedExtent, CustomSubclassOfTile)].

Thanks,

Alex



On Thu, Feb 16, 2017 at 4:04 PM, Rob Emanuele <remanuele@xxxxxxxxxx> wrote:
Hi Alex,

You can use the TileFeature (https://github.com/locationtech/geotrellis/blob/master/raster/src/main/scala/geotrellis/raster/TileFeature.scala). You'll find that a lot of the functionality on an RDD of Tiles or MultibandTiles, you'll have for a TileFeature. There might be some functionality missing (which is added through implicits), so it might take adding some of the implicits that allow for functionality to be called. You could also use your custom wrapping objects, if you provide the proper implicits (stated int he context bounds of the methods you are trying to use). If you need help with that, or you run into TileFeature functionality that isn't there, let us know.

Thanks,
Rob

On Thu, Feb 16, 2017 at 2:04 PM, Alex Ethier <soccermafia89@xxxxxxxxx> wrote:
Hello,

I've been able to use Geotrellis to load multiple Geotiffs from HDFS to produce an rdd: RDD[(ProjectedExtent, Tile)].  I'd like to include some metadata for the tiles.  For instance each Geotiff can have a separate cloud cover metric associated with it and I want that data to be present with each Tile object.

As I do analytics over the Tiles I will need to take into account the cloud cover metric. 

What is the cleanest way to accomplish this?

Initially I tried wrapping Tiles as a field in a custom object but then I lost the ability to run Geotrellis RDD operations on it such as the .tileToLayout() function.

Thanks,

Alex

_______________________________________________
geotrellis-user mailing list
geotrellis-user@locationtech.org
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/geotrellis-user



--
Robert Emanuele, VP of Research
Azavea |  990 Spring Garden Street, 5th Floor, Philadelphia, PA
remanuele@xxxxxxxxxx  |  @lossyrob

_______________________________________________
geotrellis-user mailing list
geotrellis-user@locationtech.org
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/geotrellis-user


Back to the top