I have a two data frames with lat-lon values and some additional information I want to merge two dataFrames in range of values
df1
lat1 lon1 lat2 lon2 a1 a2 a2
1.0 1.0 4.0 7.0 a d p
2.0 2.0 5.0 8.0 b e q
3.0 3.0 6.0 9.0 c f r
This is of size 30 million rows
df2
lat lon x
1.0 1.0 m
1.0 2.0 n
2.0 3.0 o
This is of size 20 million rows
Now for each row in df1 i want to merge with df2 having all the lat in df2 between lat1 and lat2 and lon in lon1 and lon2
lat1<=lat<=lat2
lon1<=lon<=lon2
I have tried
Best way to join / merge by range in pandas
how to perform an inner or outer join of DataFrames with Pandas on non-simplistic criterion
But still i run out of memory.
What is the most optimal way to do this?