Skip to main content

Hi I would like to calculate the coordinates of the centroid polygon feature class without changing the geometry type to point. Is this

,

Hi is it possible to only get the coordinates of the centroid of a polygon, without altering the polygon. I have tried CentrepointReplacer this replaces the polygon with point feature?

This is not really a solution that does not change the geometry, but it does keep it intact. Try the following:

  1. Store the current geometry in an attribute using the GeometryExtractor.
  2. Replace the geometry with a centroid using the CenterPointReplacer.
  3. Extract the centerpoint data with a CoordinateExtractor.
  4. Replace the original geometry using the GeometryReplacer, with the stored attribute as a source.

Hope this helps!


The CenterPointReplacer transforms a polygon into the center point of its bounding box. If you want to get coordinates (x, y) of the "center point", you can use the BoundsExtractor to retrieve the coordinates of the bounds and then calculate the center coordinates with the AttributeCreator.

  • x = (xmin + xmax) * 0.5
  • y = (ymin + ymax) * 0.5

In FME 2016 beta, I found a new transformer called "CenterPointExtractor". Coming soon :-)


Both solutions mentioned above will get you the coordinates of the center point. But the center point is not always located inside the polygon. In case you need a point inside the polygon you will need to have a look at the InsidePointReplacer instead of the CenterPointReplacer.


I'm not sure what the definition of "centroid" is. According to my dictionary, the first meaning of "centroid" is the "center of gravity", but there seems to be cases that the word indicates different meanings depending on the context in fact. Since you have tried the CenterPointReplacer already, so I thought that you need to retrieve coordinates of the center point (center of the bounding box).

FME can transform a polygonal geometry into three kind representative point - "center (center of bounding box)", "center of gravity", and "inside point (a point inside of the polygon)". As @erik_jan mentioned, "center" and "center of gravity" may not be inside of the polygon, but it's guaranteed that "inside point" is located within the polygon.

  • @kim's solution can be applied to all kind of representative point in conjunction with an appropriate transformer (CenterPointReplacer, CenterOfGravityReplacer, or InsidePointReplacer).
  • The InsidePointExtractor can also be used if your desired "centroid" means "inside point".
  • My answer can be used only if your desired "centroid" was "center".

Reply