<jupyter_start><jupyter_text>https://geopandas.readthedocs.io/en/latest/gallery/plotting_basemap_background.html<jupyter_code>landuse_polygon = gpd.read_file('../GeoJsonFiles/landuse_polygon.geojson')
ames_shape = gpd.read_file('../GeoJsonFiles/shape/natural.shp')

### ALL THE BUILDINGS!!!
gis_buildings = gpd.read_file('../GeoJsonFiles/iowa-latest-free/gis_osm_buildings_a_free_1.shp')
gis_buildings
gis_osm_poi = gpd.read_file('../GeoJsonFiles/iowa-latest-free/gis_osm_pois_free_1.shp')
poi_crs = gis_osm_poi.to_crs(epsg=3857)

gis_osm_poi
# poi_crs['fclass'].unique()
poi_crs
### CHURCHES
# gis_osm_pofw = gpd.read_file('../GeoJsonFiles/iowa-latest-free/gis_osm_pofw_free_1.shp')

gis_osm_pofw

# pofw_crs = gis_osm_pofw.to_crs(epsg=3857)
# gis_osm_pofw#[gis_osm_pofw['fclass']=='jewish']

# data (list of list with values) – List of list of shape [[lat, lon], [lat, lon], etc.] 
# When you use a custom callback you could add more values after the lat and lon. 
# E.g. [[lat, lon, ‘red’], [lat, lon, ‘blue’]]
bus_route  = gpd.read_file('../GeoJsonFiles/bus_route.geojson', driver='ESRIJSON')
landuse_polygon['landuse'].unique()
landuse_polygon[landuse_polygon['landuse']=='retail'].plot()
ames_shape
ames_school_polygon = gpd.read_file('../GeoJsonFiles/school_polygon.geojson')
ames_school_polygon.plot()
ames_school_polygon.crs
iowa-latest.osm.pbf
G = ox.graph_from_place('Los Angeles, California', network_type='drive')
ox.plot_graph(G)
city = ox.geocode_to_gdf('Ames, Iowa')
ax = ox.project_gdf(city).plot()
_ = ax.axis('off')
G = ox.graph_from_place('Ames, Iowa', network_type='drive')
ox.plot_graph(G)
city.crs
city_wm = city.to_crs(epsg=3857)
landuse_crs = landuse_polygon.to_crs(epsg=3857)
schools_crs = schools.to_crs(epsg=3857)

ax = landuse_crs.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax)
ames_school = ames_school_polygon.to_crs(epsg=3857)

ax = ames_school.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax)<jupyter_output><empty_output><jupyter_text>https://geopandas.readthedocs.io/en/latest/gallery/plotting_with_folium.htmlhttps://python-visualization.github.io/folium/modules.htmlhttps://www.earthdatascience.org/tutorials/introduction-to-leaflet-animated-maps/https://autogis-site.readthedocs.io/en/latest/notebooks/L5/02_interactive-map-folium.htmlhttps://github.com/mapbox/geojson-vtfor including in dashhttps://medium.com/@shachiakyaagba_41915/integrating-folium-with-dash-5338604e7c56https://community.plotly.com/t/how-to-render-map-created-by-folium-dynamically-and-get-the-clicked-data-information/40885/9https://dash-leaflet.herokuapp.com/map_clickhttps://medium.com/analytics-vidhya/brick-by-brick-build-a-multi-page-dashboard-dash-filters-dbec58d429d2https://medium.com/analytics-vidhya/brick-by-brick-build-a-multi-page-dashboard-37912dd7d9e6<jupyter_code>map = folium.Map(location = [42.0219, -93.6227], tiles='OpenStreetMap' , zoom_start = 12)
tooltip = "Click me!"
# folium.Marker(
#     [42.03047530489075, -93.60682804611989], popup="<i>That outlier</i>", tooltip=tooltip, 
#     icon=folium.Icon(icon="home"),
# ).add_to(map)

# style_function = lambda x: {'fillColor': '#0000ff' if
#                            x['properties']['landuse']=='retail' else
#                             '#00ff00'}
# folium.GeoJson(landuse_polygon, name="Land Use", style_function= style_function, show=False).add_to(map)
# folium.GeoJson(schools_crs, name="Schools", show=False).add_to(map)
folium.GeoJson(pofw_crs, name="Churches", show=False).add_to(map)
# folium.GeoJson(poi_crs, name="Point of Interest", show=False).add_to(map)

# folium.plugins.FastMarkerCluster(gis_osm_pofw['geometry'], name="Churches").add_to(map)

#folium.Marker(pofw_crs, name="Churches", show=False).add_to(map)


# test = folium.GeoJson(pofw_crs, name="Churches", show=False,
#                     marker = Marker(radius = 3, # Radius in metres
#                                            weight = 0, #outline weight
#                                            fill_color = '#000000', 
#                                            fill_opacity = 1)
# #                ,
# #                     tooltip = folium.GeoJsonTooltip(fields = ['feeder'],
# #                                                     aliases=['Feeder: '],
# #                                                     style = ("background-color: white; color: #333333; font-family: arial; font-size: 12px; padding: 10px;"),
# #                                                     sticky = True)
#                     ).add_to(map)
# # fillcolor: lambda x: {fillColor':'red' if x['properties']'Post_Cod_1'] == 'High' else 'green','fillOpacity':0.75}



# marker_cluster = folium.plugins.MarkerCluster(test)
# marker_cluster.add_to(map)

# folium.FeatureGroup(name=churches, show=False)

folium.LayerControl().add_to(map)


map
import os
import folium
import pandas as pd
 
marker_cluster = folium.plugins.MarkerCluster(location = pofw_crs.geometry[[1]], name = "Churches").add_to(map)
 

# for each in pofw_crs.iterrows():
# # #     popup = 'Add <b>test</b>'
# # #     print(list([each[1].GeoY,each[1].GeoX]))
# # #     print(list(OSGB36toWGS84(each[1]['GeoX'],each[1]['GeoY'])))
#      folium.Marker(list(pofw_crs.geometry[[each]])).add_to(marker_cluster)
map
gis_osm_pofw.geometry[[2]]



address='931 Maxwell ave, Ames Iowa'
geolocator = Nominatim(user_agent="ORoss_goldfish")
location = geolocator.geocode(address)
print(location.address)
print((location.latitude, location.longitude))

gis_osm_pofw["x"] = gis_osm_pofw["geometry"].apply(lambda geom: geom.x)
gis_osm_pofw["y"] = gis_osm_pofw["geometry"].apply(lambda geom: geom.y)

# Create a list of coordinate pairs
gis_osm_pofw['locations'] = list(zip(gis_osm_pofw["y"], gis_osm_pofw["x"]))
list(gis_osm_pofw['name'])
map = folium.Map(location = [42.0219, -93.6227], tiles='OpenStreetMap' , zoom_start = 12)
# Create a folium marker cluster
marker_cluster = MarkerCluster(locations = gis_osm_pofw['locations'],
                               popups=list(gis_osm_pofw['name']), 
                               name="Churches", show=False)

# Add marker cluster to map
marker_cluster.add_to(map)

folium.LayerControl().add_to(map)


# Show map
map
coords_1 = (gis_osm_pofw.y[1], gis_osm_pofw.x[1])
coords_2 = (gis_osm_pofw.y[2], gis_osm_pofw.x[1])

print(geodesic(coords_1, coords_2).miles)
gis_osm_pofw['lon'] = gis_osm_pofw['geometry'].x
gis_osm_pofw['lat'] = gis_osm_pofw['geometry'].y
gis_osm_pofw
def sieve_Ames_range(df_place):
    '''
    Input variables:
    df_place: A dataframe of places. Need to contain the columns ["longitude", "latitude"].
    Output variables:
    An updated dataframe. Rows out of the range will be deleted.
    The boundary latitudes and longitudes are given by the global variables "lon, lat"_"min, max".
    '''
    return df_place[(df_place["longitude"] >= lon_min) & (df_place["longitude"] <= lon_max)\
                   & (df_place["latitude"] >= lat_min) & (df_place["latitude"] <= lat_max)]; 

# Using Oren's boungs for Aimes
lon_min = -93.7919315;
lon_max = -93.501356;
lat_min = 41.8863363;
lat_max = 42.1634011;<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15433048831677626, 'fraction_numerical': 0.031341821743388835, 'mean_word_length': 4.1313711414213925, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 11, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '514787', 'license': 'MIT', 'n_tokens_mistral': 2918, 'n_tokens_neox': 2751, 'n_words': 377, 'path': 'Oren/06_Mapping_and_Playing.ipynb', 'repo_name': 'kiwymic/operation_goldfish-1', 'size': '7147'}