Skip to main content
Hi All, 

 

 

I have output some shapefiles with counts from an amalgamation of some points and some polygons.

 

For example: I have produced a shapefile with the number of house fires in each county for all the UK.

 

All is good.

 

 

But what I want to do is now, is produce a rate, based on population in each county.

 

So for example: I want the rate of House Fires (HF) per county per 1000 population.

 

 

Rate = (HF / Population) * 1000

 

 

Both Expression evaluator and Attribute Creator are producing 0(zeros), this is frustrating.

 

 

Please help?

 

 

 

 
Oh by the way, I have added an inspector to the data just before trying Expression evaluator or Attribute Creator and both the HF and Population attribute information are showing as (64 bit real). The output values are also set as numbers.
I am using FME DEsktop 2014 SP3 
I have tracked it down.I think I may have hit a bug in FME.

 

I tried the following caluculations where

 

HF = 1 and Population = 1000

 

HF + Population = 1001

 

HF * Population = 1000

 

HF / Population = 0 , this should be 0.001.

 

 
Si,

 

In your calculation try *1000.000 (for example) as opposed to 1000 OR somewhere in your calculation put in *1.000

 

This should then make FME reveal the decimal places you require

 

...............

 

Hope this helps

 

Howard L'
Hi,

 

 

Probably both HF and Population values don't have decimal places.

 

The / operator returns integer when both operands are integer.

 

e.g. "1 / 2" returns "0", it doesn't return "0.5".

 

 

Even though the data type is shown as "64 bit real" in Data Inspector, it will be interpreted as integer when the expression is evaluated, if it doesn't have decimal places.

 

 

To avoid the "integer division trap", try adding decimal places to at least one operand of the / operator.

 

e.g.

 

Rate = 1000.0 * HF / Population

 

Rate = @double(HF) / Population * 1000

 

Rate = (HF + 0.0) / Population * 1000

 

and so on.

 

 

It's the spec of the / operator in FME 2014 or earlier.

 

But be aware that the spec has been changed in FME 2015.

 

In FME 2015, "1 / 2" returns "0.5".

 

 

Takashi
Thanks for the response.

 

Used Rate = (HF + 0.0) / Population * 1000 as a work around.

 

 

Reply