Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spatial Index in MySQL - ERROR - Cannot get geometry object from data you send to the GEOMETRY field

I am new to the whole 'spatial index' thing, but it seems to be the best solution for filtering based on latitude/longitude. So I added a column to my table:

So I created a geometry field:

  ALTER TABLE `addresses` ADD `point` POINT NOT NULL 

And then I tried to add an index:

  ALTER TABLE `addresses` ADD SPATIAL INDEX ( `point` ) 

But I get an error:

  #1416 - Cannot get geometry object from data you send to the GEOMETRY field

What am I doing wrong here?

like image 233
jisaacstone Avatar asked May 03 '11 20:05

jisaacstone


Video Answer


1 Answers

OK I found the solution: Can't create a spatial index if some of the column fields contain no data. After running

  UPDATE `addresses` SET `point` = POINT( lng, lat )

Everything worked fine.

like image 142
jisaacstone Avatar answered Sep 27 '22 22:09

jisaacstone