Skip to content

Commit

Permalink
Update members_geocoder.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik-Brown01 committed Dec 27, 2023
1 parent b43f6f7 commit 5c775a9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/members_geocoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ def default(self, obj):
return obj.tolist()
return super(NpEncoder, self).default(obj)

def convert_types(entry):
if isinstance(entry, np.integer):
entry = int(entry)
if isinstance(entry, np.floating):
entry = float(entry)
if isinstance(entry, np.ndarray):
entry = entry.tolist()
if isinstance(entry, list):
entry = str(entry)
return entry

def generate_members_info(AIRTABLE_API_KEY, AIRTABLE_APP_KEY, AIRTABLE_TBL_KEY, GEOAPIFY_API_KEY):
"""
Generate members' information by geocoding their addresses.
Expand Down Expand Up @@ -257,8 +268,8 @@ def generate_members_info(AIRTABLE_API_KEY, AIRTABLE_APP_KEY, AIRTABLE_TBL_KEY,
# Exclude 'lat' and 'lon' from the properties
gdf = gdf.drop(columns=['lat', 'lon'])

gdf['Legislation'] = gdf['Legislation'].apply(lambda x: str(x))
gdf['Membership Status'] = gdf['Membership Status'].apply(lambda x: str(x))
df = pd.DataFrame(members_list).applymap(convert_types)


# Export to GeoJSON
gdf.to_file(path / 'rtc_members.geo.json', driver='GeoJSON')
Expand Down

0 comments on commit 5c775a9

Please sign in to comment.