I found there are a number of RDMS have the spatial capability e.g. mysql, postgreSQL

I considering which I should go forward!

I would like to store the lat lon coord from the tracker to the db and make a query to find the nearest place or compare with the defined location.

Could anyone give me an idea on this topic?

  • 1
    Do you need a client-server architecture? Maybe something simple like spatialite or GDAL/OGR could be a simpler solution? – BradHards Apr 14 '13 at 8:07

Without a doubt, go for Postgres.

PostGres+PostGIS is an fully featured spatial database, and has a lot of documentation, and you'll easily find help from people on forums and here.

MySQL was late to the spatial field, and lacks many features which are there in Postgre+PostGIS. Even the community using MySQL for spatial purposes is minuscule when compared to the users of PostGIS. The future of MySql is also question, with most of the Original Developers having forked the code, and moved to a different project called MariaDB.

Fore more details, have a look at these two questions: PostgreSQL vs. MySQL - Advantages / Disadvantages with a spatial component & MySQL vs PostgreSQL spatial application


If all you need to do is store a lat/long and compare to other lat/longs, you may not even need spatial functions. It's possible to use the Haversine formula to calculate the distance. In this case you could use pretty much any database capable of storing numeric data and doing math functions.

Might be that the flexibility and scalability of a spatial database makes way more sense for your project... but sometimes simpler is better.

  • 1
    I'm downvoting for suggesting the use of simple euclidean distance. At the very least, Haversine formula en.wikipedia.org/wiki/Haversine_formula should be used to calculate distances. – Devdatta Tengshe Apr 15 '13 at 3:05
  • Note that the question was seeking the nearest place, not necessarily calculating precise distance... for some use cases, euclidean will return the same result with less effort. I like your suggestion of using haversine though, I learn something new every day. – John Bryant Apr 15 '13 at 6:56
  • The problem is not for the some cases where it will give similar results, but for cases where it gives wrong results. Example, three points near the North Pole, 2 in the Easter Hemisphere, and 1 in the Western Hemisphere. You can get wrong results. And in this Case the computer (or rather the RDBMS) is doing the calculation. You might as well ask it to do the right calculation. – Devdatta Tengshe Apr 15 '13 at 8:23
  • Agreed! Thanks for setting me straight. Glad to learn a reliable way to do this without a spatial DB. – John Bryant Apr 15 '13 at 8:57
  • 1
    With projected coordinates (very common in GIS), there is nothing wrong in using Pythagoras. But since OP stated lat/long, great-circle distance is needed. – Uffe Kousgaard Apr 15 '13 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.