How yotkadata/uhi_detector works
1. Purpose and Runtime Entry Point
This is a Python 3.10 urban-heat-island analysis project. It combines Landsat-derived geospatial layers—NDVI, emissivity, and land-surface temperature (LST)—with deep-learning roof/building segmentation. The interactive delivery surface is a Streamlit application launched from app.py, with page logic in app/landsat_maps.py and app/segmentation.py.
2. Streamlit Presentation and Interaction Layer
app.py is the application entry point and coordinates the Streamlit UI. The application exposes project visualization and live segmentation workflows; styling is local rather than a separate frontend build.
• app.py
• app/landsat_maps.py
• app/segmentation.py
• app/style.css
3. Segmentation Inference Pipeline
The roof/building-footprint workflow accepts high-resolution satellite or orthophoto imagery, runs a pretrained U-Net segmentation model with a ResNet-34 or ResNet-50 encoder, and produces mask predictions. Tiled inference and postprocessing/blending are separated, allowing images larger than model patch dimensions to be processed without hard seams.
• src/predict.py
• src/predict_orthophotos.py
• src/smooth_tiled_predictions.py
• data/models/landcover_25_epochs_resnet50_backbone_batch16_freeze_iou_0.86.hdf5
The model runtime depends on TensorFlow/Keras through segmentation_models; SM_FRAMEWORK=tf.keras must be set before startup.
4. Training and Dataset Preparation Boundary
Model development is an offline pipeline, not part of normal app execution. Source imagery and labels are prepared into patches, then the U-Net is trained/evaluated in notebooks. This boundary is represented by persisted .hdf5 model artifacts consumed by prediction code.
• src/prepare_data.py
• notebooks/segmentation_step_1_data_preparation.ipynb
• notebooks/segmentation_step_2_model.ipynb
5. Landsat Raster-Derivation Pipeline
A separate geospatial-processing path derives environmental layers from Landsat bands: NDVI and emissivity use red/NIR inputs; LST additionally uses thermal band 10. Raster creation, LST-specific preparation, and visualization are modularized. Generated layer metadata/color bounds are stored as JSON and used by the mapping/presentation workflow.
• src/create_rasters.py
• src/prepare_lst_layer.py
• src/plot.py
• data/raster_files/LC09_L1TP_179032_20230217_20230310_02_T1_lst_repr_colored_bounds.json
6. Spatial Data and Map Boundaries
GeoJSON area boundaries provide geographic context for city/map views, while raster data and segmentation imagery enter through file-based local workflows. OpenStreetMap building footprints are an external data source mentioned by the project, distinct from model-generated footprints.
• data/geojson/berlin.geojson
• data/geojson/berlin-wedding.geojson
• src/utils.py
GDAL is a material system dependency for geospatial raster IO and transformations.
7. Batch and Example Prediction Paths
In addition to interactive inference, folder-oriented scripts support batch processing. The repository ships sample GeoTIFF inputs and an output-oriented example directory, making the prediction pipeline reproducible without acquiring new imagery.
• src/predict_from_folder.py
• data/predict/examples/source/
• data/predict/examples/prediction/
Main entry points: predict.py Interactive inference · app.py App entry point · predict_from_folder.py Folder batch prediction · landsat_maps.py Landsat maps page
Components 20
Streamlit app
- App entry point · Coordinates map and segmentation workflows.
app.py - Landsat maps page
app/landsat_maps.py - Segmentation page
app/segmentation.py - Local styling
app/style.css
Segmentation
- Interactive inference · Loads the pretrained U-Net and produces masks.
src/predict.py - Orthophoto inference · Processes high-resolution imagery.
src/predict_orthophotos.py - Tiled prediction blending · Combines tile predictions without hard seams.
src/smooth_tiled_predictions.py - Pretrained U-Net model · ResNet-50 land-cover segmentation weights.
data/models/landcover_25_epochs_resnet50_backbone_batch16_freeze_iou_0.86.hdf5 - Folder batch prediction
src/predict_from_folder.py - Example GeoTIFF inputs
- Example predictions
Landsat mapping
- Raster derivation · Derives NDVI and emissivity from Landsat bands.
src/create_rasters.py - LST preparation · Uses thermal band 10 for land-surface temperature.
src/prepare_lst_layer.py - Raster visualization
src/plot.py - Layer color bounds · Generated layer display metadata.
data/raster_files/LC09_L1TP_179032_20230217_20230310_02_T1_lst_repr_colored_bounds.json - Berlin area boundaries · City and Wedding geographic context.
data/geojson/berlin.geojson - Spatial utilities · Handles local spatial data workflows.
src/utils.py
Offline model development
- Patch preparation · Prepares source imagery and labels into training patches.
src/prepare_data.py - Data preparation notebook
notebooks/segmentation_step_1_data_preparation.ipynb - U-Net training notebook · Trains and evaluates the segmentation model.
notebooks/segmentation_step_2_model.ipynb
Connections 19
- App entry point → Landsat maps page: serves
- App entry point → Segmentation page: serves
- App entry point → Local styling: uses
- Segmentation page → Interactive inference: runs
- Interactive inference → Orthophoto inference: processes imagery via
- Orthophoto inference → Tiled prediction blending: blends tiles with
- Interactive inference → Pretrained U-Net model: loads
- Folder batch prediction → Example GeoTIFF inputs: reads
- Folder batch prediction → Interactive inference: uses
- Folder batch prediction → Example predictions: writes
- Patch preparation → Data preparation notebook: implemented in
- Data preparation notebook → U-Net training notebook: prepared patches feed
- U-Net training notebook → Pretrained U-Net model: produces
- Raster derivation → LST preparation: feeds raster inputs to
- LST preparation → Layer color bounds: generates display bounds
- Raster visualization → Layer color bounds: uses
- Landsat maps page → Raster visualization: renders layers through
- Landsat maps page → Berlin area boundaries: uses map context
- Spatial utilities → Berlin area boundaries: reads