I've been working with the python raster api, and I understand that the tiles are a way of chunking the raster, and intelligent tile management can have significant impact on performance.
What I'm struggling with is reading in existing data. The raster data can only be accessed per tile. Since the FMETile is an abstract class, it can't be created directly, and each interpretation type had a different call for creating the tile.
So while I can get the interpretation of a given raster band by
raster = feature.getGeometry()
band= raster.getBand(0)
bandProperties = band.getProperties()
interpretation = bandProperties.getInterpretation()
I can't use that interpretation variable directly in creating a tile.
The only way I can see to access the data itself is to have write a separate create tile method that is essentially a switch statement
def createTile(self, interpretation, numRows, numCols):
if interpretation == fmeobjects.FME_INTERPRETATION_GRAY8:
return fmeobjects.FMEGray8Tile(numRows, numCols)
elif interpretation == fmeobjects.FME_INTERPRETATION_RED8:
return fmeobjects.FMERed8Tile(numRows, numCols)
elif interpretation == fmeobjects.FME_INTERPRETATION_GREEN8:
return fmeobjects.FMEGreen8Tile(numRows, numCols)
{...}
elif interpretation == fmeobjects.FME_INTERPRETATION_INT16:
return fmeobjects.FMEInt16Tile(numRows, numCols), 'INT16')
else:
return None
Then I can do something like
numTileCols= bandProperties.getNumTileCols()
numTileRows= bandProperties.getNumTileRows()
tile = self.createTile(interpretation, numTileRows, numTileCols)
bandData= band.getTile(numTileRows, numTileCols, tile).getData()
Is this really what we need to do every time we don't want to hardcode the interpretation type, or am I missing something obvious?