That’s an interesting method, it must be fairly new as I haven’t seen it before. Thanks for the tip.
You were very close, here’s a revised version of your script that should work. I’ve added support for multiple bands.
import fme
import fmeobjects
class FeatureProcessor:
def __init__(self):
pass
def input(self, feature: fmeobjects.FMEFeature):
inList = feature.getAttribute('inList{}')
outList = feature.getAttribute('outList{}')
raster = feature.getGeometry()
raster_properties = raster.getProperties()
new_raster = fmeobjects.FMERaster(raster_properties)
for band_no in range(raster.getNumBands()):
band = raster.getBand(band_no)
new_band = fmeobjects.FMERasterTools().replaceCellValuesMultipleRanges(
inList,
inList,
outList,
False,
band)
new_raster.appendBand(new_band)
feature.setGeometry(new_raster)
self.pyoutput(feature, output_tag="PYOUTPUT")
def close(self):
pass