I have an image of a land area with certain counts at different longs and lats. I want to sum up the counts which fall in water within that area (the water has a specific color). I'm uncertain on how to do this. This is what I have so far:
latbounds = (min, max)
lonbounds = (min, max)
newlist = []
count=[]
for i, row in df.iterrows():
if row['Latitude'] >= latbounds[0] and row['Latitude'] <= latbounds[1]:
if row['Longitude'] >= lonbounds[0] and row['Longitude'] <= lonbounds[1]:
newlist.append((row['Longitude'], row['Latitude']))
count.append((row['Count']))
len(count)
CountTot= {}
for i in zip(newlist,count):
try:
CountTot[i[0]] = int(i[1]) + int(CountTot[i[0]])
except KeyError:
CountTot[i[0]] = int(i[1])
#for k,v in CountTot.items():
Position=list(CountTot.keys())
NumCount=list(CountTot.values())
x=[]
y=[]
fig, ax = plt.subplots()
ax.imshow(w, extent=[43,44,-80,-79])
for i in Position:
x.append(i[0])
y.append(i[1])
ax.plot(x,y, "o", color="red")
fig