I am attempting to create a map that shows the location of homes that experienced a level 3.5 intensity shaking for an earthquake. The shake-map file contains rings that represent where different levels of shaking were felt. When I run the code below, pointsInPolys returns a data frame with 0 rows (apparently no points fall within the shape-map area, which is false). Both of these will be overlaid on a US base-map. Please let me know if I need to clarify something. Many thanks in advance.
JSON shake-map file: https://earthquake.usgs.gov/archive/product/shakemap/ci39462536/ci/1591320887076/download/cont_mi.json
basemap US: https://drive.google.com/file/d/1tXBcg5V7NCTwXP79RhH_keQtTzJl3ddF/view?usp=sharing
csv file: https://drive.google.com/file/d/10bgfmzHhmLZf1KJzVI6QnzjmxNnO9Ch5/view?usp=sharing
What my map looks like now: https://drive.google.com/file/d/1rWf1UQ4GH7anvIXE8ohDtAAeduAL_5pT/view?usp=sharing
For security reasons, I cannot provide the full .csv file because it contains sensitive information. I can, however, provide the column that contains the geometries. My code for reference is below.
# Import Dependencies
import pandas as pd
import numpy as np
import geopandas
import descartes
from shapely.geometry import Point, Polygon
import seaborn as sns
import matplotlib.pyplot as plt
import os
import subprocess
# Bring in json basemap
country = geopandas.read_file("gz_2010_us_040_00_5m.json")
country.head()
# Bring in csv policies file
policies = pd.read_csv('ermPAR_ALL.csv')
policies.info()
# Add column that contains the lat-long point of each policy
policies['coordinates'] = policies[['Longitude','Latitude']].values.tolist()
policies['coordinates'] = policies['coordinates'].apply(Point)
policies = geopandas.GeoDataFrame(policies, geometry='coordinates')
policies.rename(columns = {'coordinates':'geometry'})
fig, ax = plt.subplots(1, figsize = (30,20))
# Plot basemap
base = country[country['NAME'].isin(['Alaska','Hawaii','Puerto Rico']) == False].plot(figsize = (30,20), color='#3B3C6E')
#Bring in the shake-map
os.chdir('/Users/RDM032')
shakemap = geopandas.read_file('cont_mi (1).json')
shakemap4 = shakemap[shakemap['value'] == 3.5].geometry # We want policies that would have experience a >3.5 shaking
# Plot shake-map
shakemap4.plot(ax=base, label = 'Intensity')
## THIS IS WHERE I NEED TO SOLVE FOR pointsInPolys AND THEN PLOT IT ##
pointsInPolys = policies[policies.within(shakemap4)]
# Plot policies that fell within the shake-map
pointsInPolys.plot(ax=base, column='LOB', legend = True, label = "Lines of Business")
_= ax.axis('off')
plt.legend(policies['LOB'].values())
#Example Data
policies = [(-118.483757019043 34.1998443603516),(-118.46418762207 34.1509437561035),(-118.40697479248 34.0205154418945),(-118.453002929688 33.9679145812988)]