Skip to main content

Hello everybody,

in my workbench the scale of an output raster type feature should depend on an attribute RADIUS, which is defined as a numeric published parameter the user can manipulate. I realized that with a private parameter which is defined through a python script as you see below. I set the default value of the RADIUS attribute to '500' so the scale should be '4000'... But the script returns the value '15000'. I also tried to return just the value of the RADIUS itself in this script to test if the RADIUS value is still setted to 500 when the python script is running and it is! And the RADIUS attribute is definitely numeric. It has the type 'Number'. What could be the problem? I don't really know what to do.

Best regards,

Felix

scale=0

if (FME_MacroValueso'RADIUS'] <= 500):
    scale=4000
elif (500 < FME_MacroValues<'RADIUS'] <= 1000):
    scale=8000
else:
    scale=15000

return scale

You have to cast your FME_MacroValues to a number like in:

float(FME_MacroValues['RADIUS']) <= 500


Hi @felixderglueckl,

It might sound strange, but macro values (parameters) are always returned as a string.

 

The type you specify when you set up the parameter can't always be directly translated into a Python type. It mainly serves as a way to narrow down (and check) the user input.

So for your code to work, you'd have to cast the FME_MacroValuess'RADIUS'] to an integer (or float). Use int(FME_MacroValuess'RADIUS']) or float(FME_MacroValuess'RADIUS']) to do this and be aware that these functions will not work on a missing value (NoneType), so you might also want to check for that first, just in case.

>edit]I am too slow... but my answer is a bit more complete...[/edit]


Hi @felixderglueckl,

It might sound strange, but macro values (parameters) are always returned as a string.

 

The type you specify when you set up the parameter can't always be directly translated into a Python type. It mainly serves as a way to narrow down (and check) the user input.

So for your code to work, you'd have to cast the FME_MacroValuess'RADIUS'] to an integer (or float). Use int(FME_MacroValuess'RADIUS']) or float(FME_MacroValuess'RADIUS']) to do this and be aware that these functions will not work on a missing value (NoneType), so you might also want to check for that first, just in case.

>edit]I am too slow... but my answer is a bit more complete...[/edit]

I'm faster but I up voted your answer :)

 

 


I'm faster but I up voted your answer :)

 

 

Ah, a true gentleman! 😉

Reply