Given two points $p_1=(x_1,y_1,t_1)$ and $p_2=(x_2,y_2,t_2)$, where $x$ and $y$ refer to the geographic coordinates in the plane, and $t$ to some measured value. Two distance measures to evaluate the similarity between these two points come to my mind: $$d_1(p_1,p_2) = \sqrt{ (x_1-x_2)^2+(y_1-y_2)^2+(t_1-t_2)^2 }$$ $$d_2(p_1,p_2) = \sqrt{ (x_1-x_2)^2+(y_1-y_2)^2 }+ \sqrt{ (t_1-t_2)^2 }$$

Measure $d_1$ is simply Euclidean distance in 3d-space, while $d_2$ is the sum between spatial distance and attribute distance.

Which measure does make more sense and should be applied for e.g. clustering?

  • $\begingroup$ The answer is completely dependent on the nature of t and, even knowing it, it is you who decides which (or what) formula is more valuable wrt your study goals. $\endgroup$
    – ttnphns
    Oct 31, 2013 at 10:30
  • $\begingroup$ Thank you for your answer. What do you mean by "answer is completely dependent on the nature of t"? Lets assume $t$ is a temperature attribute with values in the range 0 to 100 degrees. How does this information help to choose an appropriate measure? $\endgroup$
    – Funkwecker
    Oct 31, 2013 at 10:33

1 Answer 1


Neither makes ultimately sense.

First of all, Earth is not flat. Don't use Euclidean distance on latitude, longitude coordinates, because that is highly inaccurate.

So lets assume you don't have GPS data, but, e.g. meters in a room; then Euclidean on this attribute makes sense.

Control yourself by looking at units. Physical data has units, for a very good reason... $$ \sqrt{(x_1-x_2)^2+(y_1-y_2)^2} \sim_\text{units} \sqrt{m^2 + m^2} \sim m $$

I.e. Euclidean distance, applied to two coordinates in meter, returns a distance in meters!

Now assume that your third attribute is e.g. Volt.

$$ \sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(v_1-v_2)^2} \sim_\text{units} \sqrt{m^2 + m^2 + V^2} \sim ??? $$

You cannot add (squared) meters to (squared) volts. They are entirely different things.

You might, instead, want to look at an algorithm that can deal with multiple relations. For example Generalized DBSCAN can trivially be used to cluster this data by specifying a different $\varepsilon$ for each Relation. You would then specify "neighbors" as "within 1 meter of distance and 10 Volts in the measurement".

See how nicely this works out for some algorithms to keep different data separate?

  • $\begingroup$ Thank you for your answer. You made a good point. However, is it not a very common approach in e.g. data mining to mix a large variety of different data of different scales and units. E.g. income, population, and sex in a socio-economic data set? Is such an approach totally wrong? $\endgroup$
    – Funkwecker
    Nov 4, 2013 at 6:15
  • $\begingroup$ It may work; normalization can be thought of removing the units from the equations. However, the result will heavily depend on the preprocessing, and you will get fundamentally different results depending on how you preprocess your data. $\endgroup$ Nov 4, 2013 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.