{ "cells": [ { "cell_type": "markdown", "id": "5636a4ba-8798-4ae7-9247-1ebbea456749", "metadata": {}, "source": [ "Urban Tree Canopy and Heat Islands in Chicago\n", "\n", "This project addresses the critical relationship between urban tree canopy coverage and the urban heat island (UHI) effect in the City of Chicago. Cities are experiencing hotter summers, and the UHI effect—where built environments absorb and reflect heat—significantly amplifies these impacts\n", "\n", "The core problem is to quantify the mitigating role of green infrastructure: Trees cool cities by providing shade and reducing surface temperatures. This study utilizes geospatial data on public tree distribution, community area boundaries, and Land Surface Temperature (LST) to examine this relationship in Chicago.\n", "\n", "The project aims to map heat patterns against tree distribution and use statistical analysis to confirm that areas with greater tree density experience lower UHI intensity. The final outcome provides policy insights into neighborhoods that would benefit most from targeted greening to improve climate resilience and equity." ] }, { "cell_type": "code", "execution_count": 19, "id": "db97af50-15db-4cc9-9839-983ff699d2fc", "metadata": {}, "outputs": [], "source": [ "# Import necessary libraries\n", "import geopandas as gpd\n", "import pandas as pd\n", "from shapely.geometry import Point\n", "import folium\n", "import numpy as np\n", "import statsmodels.api as sm\n", "import matplotlib.pyplot as plt # For enhanced visualization" ] }, { "cell_type": "code", "execution_count": 20, "id": "4b45cd6d-2e21-410b-ba0b-16cbfd54646c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loaded 77 community areas.\n", "Processed 47346 trees with valid coordinates.\n" ] } ], "source": [ "# --- Load Community Areas (Polygons) ---\n", "COMM_AREAS_URL = \"https://data.cityofchicago.org/resource/igwz-8jzy.geojson\"\n", "comm_areas = gpd.read_file(\n", " COMM_AREAS_URL\n", ").to_crs(\"EPSG:4326\")\n", "print(f\"Loaded {len(comm_areas)} community areas.\")\n", "\n", "# --- Load Tree Inventory (Points) ---\n", "# Data Source: Chicago Tree Inventory dataset (working URL)\n", "TREES_URL = \"https://data.cityofchicago.org/resource/ydr8-5enu.csv?$limit=50000\"\n", "trees = pd.read_csv(\n", " TREES_URL,\n", " dtype=str # read all columns as text [cite: 45]\n", ")\n", "\n", "# Convert latitude & longitude to numeric [cite: 49]\n", "trees[\"latitude\"] = pd.to_numeric(trees[\"latitude\"], errors=\"coerce\")\n", "trees[\"longitude\"] = pd.to_numeric(trees[\"longitude\"], errors=\"coerce\")\n", "\n", "# Drop rows without valid coordinates [cite: 52]\n", "trees = trees.dropna(subset=[\"latitude\", \"longitude\"])\n", "\n", "# Convert to GeoDataFrame\n", "geometry = [Point(xy) for xy in zip(trees[\"longitude\"], trees[\"latitude\"])]\n", "trees_gdf = gpd.GeoDataFrame(trees, geometry=geometry, crs=\"EPSG:4326\")\n", "print(f\"Processed {len(trees_gdf)} trees with valid coordinates.\")" ] }, { "cell_type": "code", "execution_count": 21, "id": "caea31db-42f0-4cdd-a80e-d912d0baabf7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tree count aggregation complete.\n" ] } ], "source": [ "# Count trees per community area\n", "trees_joined = gpd.sjoin(trees_gdf, comm_areas, predicate=\"within\")\n", "tree_counts = trees_joined.groupby(\"community\").size().reset_index(name=\"tree_count\")\n", "\n", "# Merge counts back into community areas\n", "comm_tree = comm_areas.merge(tree_counts, on=\"community\", how=\"left\")\n", "comm_tree[\"tree_count\"] = comm_tree[\"tree_count\"].fillna(0).astype(int)\n", "\n", "# Calculate area in square kilometers for density calculation later (using local projection)\n", "comm_tree['area_sqkm'] = comm_tree.to_crs(epsg=3857).geometry.area / 10**6\n", "comm_tree['density'] = comm_tree['tree_count'] / comm_tree['area_sqkm']\n", "\n", "print(\"Tree count aggregation complete.\")" ] }, { "cell_type": "code", "execution_count": 22, "id": "36d11543-288f-433b-bec5-468189f7a717", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Choropleth map of Tree Count generated.\n" ] }, { "data": { "text/html": [ "