K-Nearest Neighbors and MySql Geographical Index

时间秒杀一切 提交于 2019-12-05 05:34:34

问题


I have a set of geo-tagged pictures in mySql database. You can consider my Pictures table to be:

create table `Pictures` (

location Point NOT NULL, 
timeCreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

SPATIAL INDEX(location)

)ENGINE= MyISAM DEFAULT CHARSET=utf8;

I intend to perform a K-Nearest Neighbor algorithm based on the location of the pictures. Say, if K=10, select the 10 pictures which are geographically closest to the user location.

I appreciate your suggestions.


回答1:


Have a look to the link below. I believe it addresses the same problem that you have by solely using MySQL queries (if your problem is to find the 10 nearest pictures to users location).

MySQL Great Circle Distance (Haversine formula)

I hope that this can help you solve your problem.




回答2:


No support for KNN.

A more proper and accurate response is simply that, as of now, neither MySQL nor MariaDB support KNN. Though PostGIS the free spatial extension to PostgreSQL does.



来源:https://stackoverflow.com/questions/9530970/k-nearest-neighbors-and-mysql-geographical-index

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