I have 50 shapefiles in point, line and polygon.

Each layer have different code; for example road have code 1120 and tracks have 1121 and streams have code 2110.

I want to calculate centroid of each feature up to 9 figure each for longitude and latitude prefix by layer code.

I want output as 1120790989898329085438.

In above code "1120" is feature code, longitude is "79.0989898" and latitude is "32.9085438".

Is there any way to calculate centroid in FME and output in new field or defined field?


Yes, you can use the CentrePointExtractor transformer which will return either the centre point of the bounding box, the centre of gravity, or any point guaranteed to be inside a polygon (not always the same as the centre point).

I don't know how you have feature code stored. If it's as an attribute then you are good to go (with the StringConcatenator below).

If the feature code is the same as the name of the layer then expose and use the format attribute fme_feature_type

If the code/layer relationship requires a lookup, and isn't in the data anywhere, use an AttributeValueMapper transformer to set that up.

Finally use a StringConcatenator transformer to create your output string by concatenating the feature code, longitude, and latitude attributes.

Don't forget to add the output string to the writer schema so it is written out.

  • Thanks sir, I works but I stuck here as describe below – Sachin Apr 21 '17 at 8:33
  • I had used center point extractor using point mode center and add StringConcatenator with result string 2201@Value(_inside_x)@Value(inside_y) After that I get the result 2201158707510.139225325713360.34431 where _x value is 158707510.139225 and _y value is 325713360.34431 I want to remove after decimal values in the result and want result as 2201158707510325713360. Any way to do this. – Sachin Apr 21 '17 at 8:33
  • Yes, use an AttributeRounder transformer on the results of the CoordinateExtractor. That's the easiest way I think. – Mark Ireland Apr 21 '17 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.