I have a shapefile which has point geometry points with latitude and longitude values.The image when opened in QGIS looks similar to the below picture and I want to know whether I can separate each row of points using latitude and longitude information using GeoPandas or any other library in Python. I am new to GeoPandas and geo-processing.

Similar to Shape file points

My end goal is to find if there are any missing points in each row. The above image doesn't have missing points in each row but the data which I have has missing points in some of the rows.

Things that I tried so far: I started sorting the points based on latitude and longitude information for finding a pattern to separate each row but it doesn't help me that much, so I would like to know if there are any other ways I can separate each row of data points.

  • Welcome, @Maharabooshanam! How do you want to separate the points? Please describe better, what you want to achieve and what you have tried so far. – Stefan Jun 3 at 10:35
  • In the image we have 3 rows and I would like to separate into 3 different geodataframe by using the lat and longitude information. – Maharabooshanam Jun 3 at 10:38
  • Does this topic Dividing shapefile into multiple shapefiles using an attribute value in QGIS Graphical Modeler look similar to what you want ? – Taras Jun 3 at 10:54
  • @Taras I will check and let all know in the comments – Maharabooshanam Jun 3 at 10:58
  • 1
    Are they Always linear in roughly the same direction and parallell? – BERA Jun 3 at 11:18

As some commenters mention, this is not a trivial task unless the rows are aligned vertically or horizontally.

On the other hand, you should not need much in the way of geoprocessing here. You should be able to get a pandas dataframe from the shapefile using GeoPandas like this:

import geopandas as gpd

geo_df = gpd.read_file('path/to/your/shapefile.shp')
point_df = pd.DataFrame({
    'x': geo_df.geometry.x,
    'y': geo_df.geometry.y,

As to how to separate the rows, I would look towards using the Hough transform to identify the equations of lines the points should lie on, then selecting the direction in which three important lines appear and each point lies close to exactly one, and assigning the points to lines. (Hough transform is mostly used for image analysis, but I believe it addresses your need, although you might struggle to get a ready-made solution for point sets.)

| improve this answer | |
  • Thanks for your reply. Again the Hough transform approach for detecting line with geographical coordinates is a tedious task but will see if I can get some leads on it. I am not specific to python based solution even a qgis or any other tool solution would work for me as my end goal is to find missing points in each row of the data. – Maharabooshanam Jun 4 at 8:53
  • True, it is not a trivial solution. But then again, it is not a trivial task you are attempting. Wish you good luck and if this answer helps you, please consider accepting it. – Jan Šimbera Jun 4 at 14:19

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.