Python Forum
Finding overlap of boxed coordinates - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Finding overlap of boxed coordinates (/thread-34780.html)



Finding overlap of boxed coordinates - 83dons - Aug-31-2021

I have a panda dataframe that I would like to now query. The dataframe contains the 4 coordinates of a geographic area using longotude and latitude so effectively each entry represents a box shape. What I would like is to query the dataframe and return one line for every occurrence where box overlaps another box and to miss out any rows where there is a box that has no overlap at all. I am ideally looking to show the number of overlaps a row has and to which original rows all link together to form this overlap. Further down the line I would like to visually represent these on the screen to show the overlap perhaps with a backing image to give context.

An example of the data is below (which is for Mars) which uses aerocentric latitude and an east positive longitude I think it was which goes up to 360 from the central point.

UPPER_LEFT_LONGITUDE 347.15
UPPER_LEFT_LATITUDE -36.545832
UPPER_RIGHT_LONGITUDE 347.69
UPPER_RIGHT_LATITUDE -36.486035
LOWER_LEFT_LONGITUDE 347.81
LOWER_LEFT_LATITUDE -40.795116
LOWER_RIGHT_LONGITUDE 348.38
LOWER_RIGHT_LATITUDE -40.735216

Any help appreciated.


RE: Finding overlap of boxed coordinates - jefsummers - Aug-31-2021

What have you got so far?


RE: Finding overlap of boxed coordinates - 83dons - Aug-31-2021

(Aug-31-2021, 04:34 PM)jefsummers Wrote: What have you got so far?

Not a lot. I think I need some comparative maths formula to compare the coordinates but not sure where to start. Was hoping there may be geometric python add in that would pre package the maths.


RE: Finding overlap of boxed coordinates - jefsummers - Aug-31-2021

Look at shapely


RE: Finding overlap of boxed coordinates - 83dons - Aug-31-2021

(Aug-31-2021, 08:25 PM)jefsummers Wrote: Look at shapely

Thanks away to check out geopanda and shapely.