# [postgis-users] Off topic : Relative distance measurement

Øyvind Vestavik oyvindve at idi.ntnu.no
Wed Jan 24 09:53:19 PST 2007

```Sorry for posting off topic but I was wondering if anyone have any
thoughts on comparing two points using distance() or something similar
and then converting the retrieved distance into a value between 0 and 1
where 1 means that the points are the same and 0 means the points are
as far apart as possible.

i tried something like the formula below, but unless using a lot of
desimals the metric will return 1 for all but very long distances.

simGeo = 1 - (distance / (EquatorialLength / 2))

The reason for this strange request is that I'm comparing gazetteer
entries from two different sources based on their names (implemented as
term vectors) and their locations (Points). The hypothesis is that if
the entries share many names and have Identical or near identical points
representing the place, they are the same place.
To have the metrics comparable they should both be a value between 0 and
1, something like this.

((simVSP x weightVSP) + (simGeo x weightGeo))/2

If anyone has any tips on how to transform for instance a number of
meters to a value between 0 and 1 ?

--
Kind Regards
Øyvind Vestavik

```