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

Deadly 提交于 2019-12-03 12:17:44
jisaacstone

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.

I had this same error (Cannot get geometry object from data you send to the GEOMETRY field) but when trying to import spatial data from a mysql dump. I found that some rows had "null" (X is null or Y is null) spatial data even though the column was "NOT NULL"..

Check if you have the same problem as I'm describing with this SQL:

SELECT id FROM locations WHERE X(coordinates) IS NULL OR Y(coordinates) IS NULL;

If you have some rows then this is what worked for me:

UPDATE locations SET coordinates = POINT(0,0) WHERE X(coordinates) IS NULL OR Y(coordinates) IS NULL;

Then try your mysqldump (or from phpmyadmin) and import again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!