I have GPS coordinates of human mobility in Beijing Area. I want to divide geographical space in to rectangular grid, for example 2 sq. km (delta), and access the indexing position of any point inside the grid. The cells need not be exactly equal size, approximation can work in my case.

I have geographical region with the following coordinates (latitude, longitudes) of bounding box.

Bottom Left  (x1,y1) = 39.77750000, 116.17944444  
Top Left     (x1,y2) = 40.04722222, 116.17944444  
Bottom Right (x2,y1) = 39.77750000, 116.58888889  
Top Right    (x2,y2) = 40.04722222, 116.58888889  

This is rectangular region of 30 km x 34 kms. The solution in my mind is to take delta as 2km, increment latitude and longitude value by delta until upper bound reaches.
To access the index position of GPS point p, Let BL be the Bottom Left point of rectangular region

Row =    Distance [(p.lat,BL.long), (BL.lat, BL.long)] / delta 
Column = Distance [(BL.lat,p.long), (BL.lat, BL.long)] / delta 

Is there any easier way or supporting library to solve this problem? preferably in combination of row and columns (x,y), so that I can measure the closeness of grid cells by finding distance between two grid cells in Cartesian coordinates system. An example image and input dataset may give you clear idea of the description.

Division of Geographical region into Map Grid

The input dataset in given in the link https://drive.google.com/file/d/1JjvS7igTmrtLA4E5Rs5D6tsdAXqzpYqX/view

  • I believe the PostGIS function ST_CreateFishnet will help you ... Aug 8, 2018 at 11:26

1 Answer 1


For sure you can take advantage of grid clustering algorithm. Since you do not need to actually find a, do pretend cluster rotate, just get the lower/upper corner coordinates of each cell and pretend no cluster is found, move to next. At the end designate last cell to visit as cluster density and call it good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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