· Apr 26 2m read

Geo Vector Search #1

Geographic use of vector search

The basic idea is to use Vectors in the mathematical sense.
I used geographic coordinates. These are of course only 2-dimensional
but much easier to follow as vectors in text analysis with >200 dimensions.

The example loads a list of worldwide capitals with their coordinates
The coordinates are interpreted as vectors from geographic point 0°N/0 W
(some very wet spot in the Gulf of Guinea, >400 km from the African Coast)
Finding common directions from that spot is a quite theoretical case.
So adjustment to your preferred starting point is implemented.
Now finding similar directions for some target city makes sense.
It's a methematical use of VECTOR_COSINE() function other than text search.

And as this is just 2 dimensional COSINE is just what we (hopefully) learned at school.
So the results are far better to understand: 

  • 1  =  total match, same direction 0° deviation from original
  • 0  = no match at all,  direction points 90° away from original
  • -1 = total opposite direction pointing backward by 180° from original
  •  ~0.999  = quite close to original 

You just get information on the direction, not on the size.
So your vector from Paris to Budapest  points also to Minsk or someplace In Asia

The demo is controlled by a rathrer simple menu:

  Use Geographc Vectors
     1 - Initialize Tables
     2 - Import Data
     3 - Set Base Location
     4 - Generate Vectors
     5 - Select Target Location
     6 - Show Best Matches
Select Function or * to exit :

for multiple retries, you always restart at

  • #3 set your starting location
  • #4 adjust coordinates to your selected base
  • #5 set your target location  defining your base vector
  • #6 see what's in between or in front of your vector
    • adjust tolerance from -1...+1



DemoServer Mgmt Portal
DemoServer WebTerminal

Discussion (3)1
Log in or sign up to continue