Skip to main content

Hi

I have a polygon with name A and some points around with names A, B , C, D

I would like to calculate the distance between the centerpoint of polygon and the point with the same name of polygon (distance polygon A point A)

Thx

Francesco

Replace the polygon with the center point (CenterPointReplacer).

Then use the NeighborFinder (group by name) to find the closest point (candidate) to the centerpoint (base).

This will add an attribute _distance, with the requested distance.


@frsisani

Or extract centerpoint (CenterPointReplacer)

FeatureMerge unconditionaly (req = 1 and sup = 1) to points.

Create lines Vertex replace with centerpoint and Vertex add with points.

Function @Length() holds the distance (can ber accesed via Aritmetic Editor in all transformer that provide acces to this editor, for instance tester or Attributecreator).


Alternatively, this procedure is also possible. This is a way to calculate distance literally using attributes.

  1. CenterPointExtractor: Extract coordinates (x0, y0) of center point from each polygon. 
  2. CoordinatExtractor: Extract coordinates (x1, y1) from each point.
  3. FeatureMerger: Merge (x1, y1) to polygon feature using their name (A, B, C ...) as Join On. 
  4. ExpressionEvaluator: Calculate the distance between (x0, y0) and (x1, y1) with this math expression. The AttributeCreator or the AttributeManager can also be used here.
@hypot((@Value(x1)-@Value(x0)),(@Value(y1)-@Value(y0)))

0684Q00000ArJypQAF.png