# Project: I wanted to figure out a way to send mail to certain addresses for prospectice clients in certain locations.
# I found a database with all the addresses (70,000) of the city of interest
# I created a tool where I can put the longitude and latitude of certain streets and it would give all addresses within the chosen coordinates
# I obtained the addreses and sent them mail. DONE!
# FUTURE GOALS:
# 1. Make it a web app so anyone can use it. Also, create a way for people to select the area of interest.
# 2. Figure out a way to make it personalized.
# If you have ideas, want to help, or have comment, reach out (juandavidcampolargo.com/contact)
# Start writing code here...
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('city_of_aurora.csv')
df.head()
BBox = (df.LON.min(), df.LON.max(), df.LAT.min(), df.LAT.max())
df.count()
BBox
#Reduction of Data Frame
#You can get coordinates by creating a map of the area using openstreetmap.org/export
#LAT min: top |||| #LON min: left
#Latitude
#max
df1 = df[df['LAT'] > 41.7308]
#min
df2 = df1[df1['LAT'] < 41.7967]
#Longitude
#min
df3 = df2[df2['LON'] > -88.3745]
#max
df_final = df3[df3['LON'] < -88.2784]
#1st: check to the number
##df_final.count()
df_final.count()
#2nd: check the map
#color
import plotly.express as px
fig = px.scatter_mapbox(df_final, lat="LAT", lon="LON")
fig.update_layout(mapbox_style="open-street-map")
fig.show()
#B&W
mapbox_key="pk.eyJ1IjoiamRjYW1wb2xhcmdvIiwiYSI6ImNreHMzZXh4cTRyOGcydW80aWcyc2ZrMXMifQ.SqgAQ26kdjR4jA4EcGnWCQ"
fig = px.scatter_mapbox(
df_final, lat="LAT", lon="LON", color="CITY", hover_name='CITY', hover_data=['CITY'], zoom=11)
# Now using Mapbox
fig.update_layout(mapbox_style="light", mapbox_accesstoken=mapbox_key)
fig.show()
#Goal: Find 25 addresses in 4 different locations
#1 Mariela Address (424 Forest Ave, Aurora, IL)
#Reduction of Data Frame
#You can get coordinates by creating a map of the area using openstreetmap.org/export
#LAT min: top |||| #LON min: left
#Latitude
#max
df1 = df[df['LAT'] > 41.77365]
#min
df2 = df1[df1['LAT'] < 41.77466]
#Longitude
#min
df3 = df2[df2['LON'] > -88.30620]
#max
df_final1 = df3[df3['LON'] < -88.30122]
#1st: check numbers
df_final1.count()
#2nd: check the map
#color
import plotly.express as px
fig = px.scatter_mapbox(df_final1, lat="LAT", lon="LON", zoom=15)
fig.update_layout(mapbox_style="open-street-map")
fig.show()
df_Mariela = df_final1.drop(['LON', 'LAT','UNIT', 'REGION', 'ID', 'DISTRICT', 'HASH'], axis=1)
##Insert Column STATE with value (IL) at index 5
df_Mariela.insert (3, "STATE", "IL")
# df_Mariela1 = df_Mariela['STATE'] = 'IL'
df_Mariela.head(45)
print(df_Mariela)
#2 Victor Mancilla (420 W New York Ave, Aurora, IL)
#Reduction of Data Frame
#You can get coordinates by creating a map of the area using openstreetmap.org/export
#LAT min: top |||| #LON min: left
#Latitude
#max
max_lat = 41.7615
min_lat = 41.7621
df1 = df[df['LAT'] > max_lat]
#min
df2 = df1[df1['LAT'] < min_lat]
#Longitude
#min
min_lon = -88.3247
max_lon = -88.3211
df3 = df2[df2['LON'] > min_lon]
#max
df_final1 = df3[df3['LON'] < max_lon]
#1st: check numbers
df_final1.count()
#2nd: check the map
#color
import plotly.express as px
fig = px.scatter_mapbox(df_final1, lat="LAT", lon="LON", zoom=15)
fig.update_layout(mapbox_style="open-street-map")
fig.show()
df_Victor = df_final1.drop(['LON', 'LAT','UNIT', 'REGION', 'ID', 'DISTRICT', 'HASH'], axis=1)
##Insert Column STATE with value (IL) at index 5
df_Victor.insert (3, "STATE", "IL")
# df_Mariela1 = df_Mariela['STATE'] = 'IL'
df_Victor.head()
print(df_Victor)