Chloropleth of chicago has a strange tilt to it that I cannot fix

48 Views Asked by At

I am trying to make a chlorpleth of environmental inspections in every chicago ward. I am mapping this dataset of environmental inspections in chicago found on the city of chicago data portal to this geojson file of different wards also from city of chicago data. If you do not want to download the files, there is a screenshot of the geomoetry of the geodataframe.

I will attach how I merged them, and the end result, for as much transparency as I can

inspections_df = pd.read_csv('CDPH_Environmental_Inspections.csv')
geometry = [Point(lon, lat) for lon, lat in zip(inspections_df['LONGITUDE'], inspections_df['LATITUDE'])]
inspections_gdf = gpd.GeoDataFrame(inspections_df, geometry=geometry, crs=wards_gpd.crs)
joined_data = gpd.sjoin(wards_gpd, inspections_gdf, how='inner', op='contains').set_crs(epsg=4326)
ward_inspection_counts = joined_data.groupby('ward')['LOCATION'].count().reset_index().rename(columns = {'LOCATION':'Inspections'})
wards_connector = wards_gpd[["geometry","ward"]]
inspections_connected = pd.merge(wards_connector, ward_inspection_counts, how='outer', on='ward')
choropleth_map_Inspections = alt.Chart(inspections_connected).mark_geoshape(stroke='white',
    strokeWidth=0.6).encode(
    color=alt.Color('Inspections:Q', scale=alt.Scale(zero = False, scheme='inferno')),
    tooltip=['ward','Inspections']
).properties(
    width=600,
    height=400,
    title='Inspections in every Chicago Ward'
)

choropleth_map_Inspections

Final Graph

If anybody knows, why does this graph have a weird tilt? What can I do to fix it?

0

There are 0 best solutions below