Python Forum

Full Version: Finding overlap of boxed coordinates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
What have you got so far?
(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.
Look at shapely
(Aug-31-2021, 08:25 PM)jefsummers Wrote: [ -> ]Look at shapely

Thanks away to check out geopanda and shapely.