Skip to main content
Question

Calculate distance using attribute


Forum|alt.badge.img

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

3 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • May 2, 2018

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.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 4, 2018

@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).


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • May 5, 2018

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings