1

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.

Vince
  • 20,017
  • 15
  • 45
  • 64

1 Answers1

1

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.)

Jan Šimbera
  • 1,314
  • 9
  • 12
  • 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 04 '20 at 08: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 04 '20 at 14:19