Skip to main content
Question

Calculate distance using attribute

  • May 2, 2018
  • 3 replies
  • 143 views

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • 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
  • 2252 replies
  • 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
Celebrity
  • 7843 replies
  • 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