I am new to python and currently working with Json file and I need to determine the location of each tweet and represent the grid in which they are present with the count of tweets in each grid cell.I tried comparing the xmin, xmax, ymin and ymax values of the polygon but it doesn't seems to be working. Any sort of advice would be helpful. This the function which i have used to return the grid_id but it returns only 3 gird ids , implying that all the tweets were made from those 3 grids, which is not the case
lt =[]
def match_tweets():
for d in dic.values():
for x in lst:
if ((x['xmin'][0]<= tweet_long[1][0][0] and tweet_long[1][0][0]<=x['xmax'][0]) and (x['ymin'][0]<=tweet_lat[0][0][0] and tweet_lat[0][0][0]<x['ymax'][0])):
x['count']+=1
return lst.append(x['grid_id'])
The data in dic looks like this
{0: [[[-37.95935781]], [[144.92340088]], [['melbourne']]],
1: [[[-37.95935781]], [[144.92340088]], [['melbourne']]],
2: [[[-37.95935781]], [[144.92340088]], [['melbourne']]],
3: [[[-37.95935781]], [[144.92340088]], [['melbourne']]],
4: [[[-37.95935781]], [[144.92340088]], [['melbourne']]],
5: [[[-37.94917514]], [[144.92501796]], [['tb', 'tasmania']]],
The data in lst looks like
[{'id': 'A1',
'xmin': [144.7],
'xmax': [144.85],
'ymin': [-37.65],
'ymax': [-37.5],
'coordinates': [[[144.7, -37.5],
[144.85, -37.5],
[144.85, -37.65],
[144.7, -37.65],
[144.7, -37.5]]],
'count': 0},