O
O
OM12017-05-28 18:25:13
Python
OM1, 2017-05-28 18:25:13

Python + SQLite: how to select records with "nearby" coordinates?

Hey!
It is necessary to select all rows from the table, with coordinates closer than the given threshold from the given coordinate.
The coordinates are stored in the lat and lng columns, respectively
. Mysql is full of examples with the formula for converting to polar coordinates and selecting the nearest records.
But in SQlite, a similar query causes an error, as I understand it, due to the reasonableness of sqlite.
Does anyone have a working example of a database query?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Kazantsev, 2017-05-29
@saintbyte

In order to be quick, you need to use indexes, and the indexes will roll here only for comparison. So you take a 1x1 degree square around a point, take all the points from there and catch the nearest ones.

D
Dimonchik, 2017-05-28
@dimonchik2013

https://stackoverflow.com/questions/3168904/sql-qu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question