In order to calculate the nearest locations that are represented by latitude/longitude, I was considering dividing the map into small grids, approximately 100x100 meter grids. Essentially each point would be assigned to a grid.
I understand that I could instead also use spatial indexes with MySQL etc, but am planning to use a non-relational database like Cassandra where it would be difficult to do indexing on spatial objects, and so some kind of grid approximation technique could be neat.
What would be the best way of creating such a grid system and mapping the 2-D spatial locations to it?
Edit1: It might be alright if the grids are not perfectly uniform, more so around the poles.
Lines of latitude and longitude form a global grid system. Any point on earth can be located by specifying its latitude and longitude, including Washington, DC, which is pictured here. Lines of latitude and longitude form an imaginary global grid system, shown in Fig.
Expert-verified answer A 'grid' is a network of lines on the globe. These lines are latitudes and longitudes. The latitudes run east-west on the globe, while the longitudes connect the North Pole and the South Pole. The grid helps to determine the accurate location of a place on the earth.
A system of lines is used to find the location of any place on the surface of the Earth. Commonly called a grid system, it is made up of two sets of lines that cross each other. One set—lines of latitude—runs in an east-west direction. The other set—lines of longitude—runs in a north-south direction.
Mapping from the two-dimensional spatial coordinates to your spatial index / geohash is an interesting problem. You might look at this article on quadtrees, geohashes and Hilbert curves. The Hilbert curve is a space-filling curve that provides locality; for your purposes, that means that nearby items in the one-dimensional spatial index will be nearby in two-dimensional space.
The goal (as described by other responders) is to minimize the number of queries necessary to cover the space in question without requesting tons of unnecessary data from the server. How you do the mapping from 2-d space to a 1-d index will affect that goal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With