Skip to main content
Hi all,

 

 

In GDAL it's easy to stretch a raster image with a colorramp that can look for example like this:

 

0 255 255 255

 

5 225 225 225

 

10 205 205 205

 

15 190 190 190

 

20 178 178 178

 

25 166 166 166

 

30 154 154 154

 

35 142 142 142

 

40 130 130 130

 

90 0 0 0

 

This ramp stretches for example every pixel with a value between 0 and 5 to an rgb value between 255 and 225. What is the smartest way to do the same thing in FME Workbench? I thought about using the RasterExpressionEvaluator but it seems to me like the expression needs to be quite complicated. Is there a better way of doing it?
Hi,

 

If you find it easy to use GDAL, you can use the SystemCaller transformer (in combination with  a StringConcatenator ) to execute the GDAL command(s).
Hi,

 

 

you're right, the RasterExpressionEvaluator could do this. Have you looked at the FMEpedia articles for this transformer?

 

 

http://fmepedia.safe.com/articles/Samples_and_Demos/Examples-using-the-RasterExpressionEvaluator-Transformer

 

 

http://fmepedia.safe.com/articles/Samples_and_Demos/Using-Conditions-with-the-RasterExpressionEvaluator-Transformer

 

 

David
Hi Itay and David,

 

 

Thank you for your answers!

 

Itay: Yes I know about the SystemCaller but in this case I'm trying to use FME without any other programs involved.

 

David: Yes I have already seen the FMEPedia articles (good examples).

 

 

I can solve it with the RasterExpressionEvaluator but the expression becomes a little complicated. The color ramp in my example will have this expression (if I'm correct):

 

 

if(A<0]<5,((5-A;0])/5)*(255-225) + 225,

 

  if(A/0]>=5 && Am0]<10,((5-At0])/5)*(225-205) + 205,

 

  if(A 0]>=10 && A&0]<15,((5-A&0])/5)*(205-190) + 190,

 

   if(AÂ0]>=15 && A10]<20,((5-A[0])/5)*(190-178) + 178,

 

    if(Ap0]>=20 && Ag0]<25,((5-Ap0])/5)*(178-166) + 166,

 

     if(A60]>=25 && AA0]<30,((5-Ap0])/5)*(166-154) + 154, 

 

      if(A 0]>=30 && A 0]<35,((5-A=0])/5)*(154-142) + 142, 

 

       if(A10]>=35 && A 0]<40,((5-AA0])/5)*(142-130) + 130, ((90-A40])/50)*130))))))))

 

 

The result:

 

Before:

 

 

 

After:

 

 


U can extract the colormap and built a new one..

 

 

Then u can do the testing and mapping using ie rangemappng. I think it does look better then the expressions in the rasterexpressionevaluater.

 

 

the drawback is that this takes a lot of transformers to accomplish...wel at least in my workspace. A workspace that makes density maps to see wether busstops "reach" people and dont make walk them to much.... i just counted: 14 transformers (including mapping) to get it done.

 

Then reattaching the new map to the raster, another 2 transformers.

 

 

....hhmmmm

 

 

I did redo it using a tcl caller. A small tcl script in 1 transformer.

 

Still, the mapping needs to be done.

 

But looks way better.

 

 

Is using tcl also out of the question? Else i'd go for that (or Python)

 

 

Gio

 


As a side note: there is a feature enhancement request at Safe to implement raster support to the fmeobjects Python API. I think this is another good use case for it.

 

 

Consider asking Safe to implement these raster classes so that we can do this kind of operations in a PythonCaller rather then messing about with so many transformers :-)

 

 

The more who request a feature, the more likely it is to be implemented...

 

 

David

Reply