Skip to content

RodGal-2020/OTC_Advisor

Repository files navigation

UTHECA OTC Classifier

Overview

OTC_Advisor is an interactive R Shiny application designed to evaluate and visualize Outdoor Thermal Comfort (OTC) in urban outdoor spaces. The tool allows users to upload meteorological data, apply machine learning models for thermal comfort classification, visualize results on dynamic maps, and export outputs in multiple formats. This modular approach enables urban planners, researchers, and technicians to quickly assess perceived thermal sensation at different locations and times, supporting decisions on urban design, climate mitigation, and environmental intervention.

Features

📤 Data Input

  • Multiple file format support: Upload data in Excel (.xlsx), CSV (.csv), ZIP (containing shapefiles), or Geopackage (.gpkg) formats
  • Required environmental variables:
    • Air_temperature (°C)
    • Relative_humidity (%)
    • Wind_speed (m/s)
    • One radiant temperature source: Radiant_temperature, Globe_temperature, OR Solar_radiation
  • Optional coordinates: Longitude and Latitude for spatial visualization

🤖 Classification Models

The application includes three machine learning algorithms, each with two classification modes:

Available Models:

  1. Naive-Bayes (NBD): A simple probabilistic model based on Bayes' theorem, effective with small datasets
  2. XGBoost (XGB): Advanced gradient boosting ensemble learning algorithm, highly accurate for structured data
  3. Multilayer Perceptron (MLP): Artificial neural network that models complex non-linear relationships

Classification Modes:

  • Binary: Predicts thermal comfort probability (0-100%)
    • Output: OTC_Probability (percentage of comfort likelihood)
  • Multiclass: Predicts thermal comfort category
    • Output: OTC_Prediction with categories:
      • Very cold
      • Cold
      • Neither cool nor warm
      • Warm
      • Very hot

All models were trained on the RUROS Mediterranean dataset.

👤 Personal Settings (Optional)

Users can customize predictions based on individual characteristics:

  • Gender: Male, Female
  • Age: < 12, 13-17, 18-24, 25-34, 35-44, 45-54, 55-64, > 65
  • Clothing (clo):
    • Light short-sleeved T-shirt and shorts (0.3 clo)
    • Long-sleeved T-shirt or polo with light trousers (0.5 clo)
    • Long-sleeved shirt + lightweight long trousers (0.7 clo)
    • Office wear: shirt, long trousers, light jacket (0.9 clo)
    • Full business suit (1.0 clo)
    • Warmer clothing (1.2 clo)
  • Metabolic rate (met):
    • Seated relaxed (58 W/m²)
    • Standing (80 W/m²)
    • Walking (150 W/m²)
    • Bicycling (232 W/m²)
    • Running (464 W/m²)

If not specified, the application uses values from the uploaded data file.

🌡️ UTCI Calculation

The app can calculate the Universal Thermal Climate Index (UTCI) independently:

  • Computes UTCI values from environmental data
  • Provides UTCI classification categories
  • Can be used without OTC model predictions

🗺️ Interactive Map Visualization

Dynamic leaflet maps display classified data with extensive customization:

Map Options:

  • Variable selection: Display any numeric or categorical variable
    • Environmental: Air_temperature, Globe_temperature, Relative_humidity, Wind_speed, Radiant_temperature
    • Results: UTCI, Classification.UTCI, OTC_Probability, OTC_Prediction
  • Base map styles:
    • OpenStreetMap (OSM)
    • Satellite imagery
    • Esri base maps
  • Layer opacity: Adjust transparency (0-100%)
  • Raster resolution: Control grid density (20-200 cells)
  • Interpolation radius: Set estimation buffer around data points (100-1000 meters)
    • Uses K-Nearest Neighbors (KNN with k=1) for spatial interpolation

📊 Results Table

Interactive data table showing:

  • All input variables
  • Calculated UTCI values and classifications
  • OTC predictions (probability or category)
  • Numeric values rounded to 3 decimal places
  • Horizontal scrolling for many columns

📈 Data Summary

Real-time status panel displaying:

  • Number of observations
  • Variable statistics
  • Data completeness indicators

💾 Export Options

Download results in multiple formats:

  • CSV: Comma-separated values
  • Excel: .xlsx with formatting
  • Plain text: .txt file
  • Geopackage: .gpkg for GIS software

Download interactive map as standalone HTML file.

Setup

Just open the .Rproj file and launch the following:

renv::install("remotes")
remotes::install_github("RodGal-2020/ArchiData")
renv::restore()

Running the Application

Launch the Shiny app:

shiny::runApp()

Or use the "Run App" button in RStudio.

Workflow

  1. Upload data: Click "📤 Upload Excel, CSV, ZIP File with Shapefiles or Geopackage"
  2. Choose classification mode: Select Binary or Multiclass
  3. Select model: Choose between NBD, XGB, or MLP
  4. (Optional) Enable custom personal settings and configure your profile
  5. Classify: Click "⚙️ Classify OTC" button
  6. Visualize: Explore results on the interactive map
  7. Adjust map: Modify visualization settings (opacity, resolution, variable, etc.)
  8. Export: Download results in your preferred format

Alternatively, use "Only Calculate UTCI" to compute thermal index without OTC classification.

Technical Details

  • Framework: R Shiny with shinydashboard
  • Spatial processing: terra, gstat, FNN packages
  • Machine learning: tidymodels ecosystem
  • Visualization: leaflet for interactive maps
  • Data handling: readxl, openxlsx, DT packages

Project Structure

OTC_Advisor/
├── server.R              # Server logic
├── ui.R                  # User interface
├── models/               # Trained ML models (.RData)
│   ├── XGB_binary.RData
│   ├── XGB_multiclass.RData
│   ├── NB_binary.RData
│   ├── NB_multiclass.RData
│   ├── MLP_binary.RData
│   ├── MLP_multiclass.RData
│   └── otc_classification.R
├── utils/                # Helper functions
│   ├── calculate_utci.R
│   ├── calculate_mrt.R
│   ├── change_var.R
│   ├── raster_map2.R
│   └── status_summary.R
├── read_files/           # Data input/output functions
├── templates/            # Example data files
└── renv/                 # Package management

Development Roadmap

✅ Completed Features

  1. Multiple data format support (.xlsx, .csv, .zip, .gpkg)
  2. Three ML classification models (Naive-Bayes, XGBoost, MLP)
    • Binary classification (comfort probability)
    • Multiclass classification (5 thermal categories)
    • All trained on RUROS Mediterranean dataset
  3. Interactive leaflet map visualization
  4. Map customization options
    • Background transparency control
    • Raster resolution adjustment
    • Interpolation radius settings
  5. Multiple export formats (CSV, Excel, TXT, Geopackage)
  6. Spatial interpolation (KNN with k=1)
  7. UTCI calculation and classification
  8. Custom personal settings (gender, age, clothing, metabolic rate)
  9. Data summary dashboard

🚧 Future Development

  • Enhanced interpolation methods (Kriging, IDW, optimized KNN)
  • Weather API integration (Weather Underground, OpenWeatherMap)
  • Temporal filtering (date/time ranges, hourly/daily aggregation)
  • UI/UX improvements (status bars, collapsible panels, custom themes)
  • Additional thermal comfort indices (PET, PMV, SET*)
  • Batch processing for large datasets
  • User feedback system

Citation

If you use this tool in your research, please cite the UTHECA project and the RUROS dataset used for model training.

License

[Add license information]

Contact

For questions, feedback, or contributions, please contact the development team or open an issue on GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages