Question

Adding centroid fields

  • 23 November 2012
  • 4 replies
  • 8 views

I want to compute a centroid for polygons then add the X and Y fields to my features.  I could not find any way of doing this in FME desktop as I have it. Can anyone suggest how I might do this please?

4 replies

Userlevel 3
Badge +17
Hi,

 

I think that "CenterOfGravityReplacer" and "CoordinateExtractor" are applicable.
Badge +1
Hi, 

 

maybe  "insidepointreplacer"  then "pointonareaoverlayer" are better,  because centerofgravityreplacer generate the point could be outside of the shape.
Userlevel 3
Badge +17
Yes. "CenterOfGravityReplacer" may generate a point outside of the original shape. I understood that "centeroid" means the center of gravity which can be outside of the shape. "CenterOfGravityReplacer" and "InsidePointReplacer", which is more suitable differs according to chrismugdan's demand.  
Hi,

 

Take your reader,

 

  branch

 

       InsidePointReplacer followed by CoordinatesExtractor

 

                                  ( very fancy to include reprojectors :) )

 

  Merge with original data

 

       FeatureMerger (The best of feature_ID)

 

 Write Results 

 

       Feature-writer

 

             copy attributes from input

 

             add your two X,Y attributes named in the CoordinatesExtractor

 

 

Good Luck

 

(failed to include a picture of the workbench)

Reply