Skip to main content

Solar & Environmental Analysis

The simulation engine includes modules for solar analysis and environmental assessment, using industry-standard libraries for accurate calculations.

Solar Analysis

pvlib Integration

The engine uses pvlib (Photovoltaic Library) for solar position and irradiance calculations:

  • Solar position — Precise sun altitude and azimuth for any location, date, and time
  • Irradiance modeling — Global Horizontal Irradiance (GHI), Direct Normal Irradiance (DNI), Diffuse Horizontal Irradiance (DHI)
  • Shadow casting — Calculate shadow lengths and directions based on building heights and sun position

How It Works

1. Input: Building geometry (towers + heights) + location (lat/lon)


2. Solar position calculation (pvlib)
- Compute sun path for the full year
- Sample at key hours (9am, 12pm, 3pm)
- Calculate altitude and azimuth angles


3. Shadow geometry computation (Shapely)
- Project shadow polygons from each building face
- Calculate shadow length = height / tan(solar_altitude)
- Apply azimuth for shadow direction


4. Analysis outputs
- Shadow overlap maps between towers
- Sunlight hours for each building face
- Shadow coverage at different times of day/year
- Solar exposure scores

Key Calculations

MetricLibraryDescription
Sun positionpvlibAltitude + azimuth angles
Shadow lengthCalculatedbuilding_height / tan(altitude)
Shadow polygonShapelyProjected from building footprint
IrradiancepvlibSolar energy per unit area
Sunlight hourspvlibHours of direct sun exposure

Setback Calculations

Setbacks are regulatory distances between buildings and site boundaries:

          ┌──── Front Setback ────┐
│ │
Side │ ┌───────────────┐ │ Side
Setback │ │ │ │ Setback
│ │ Building │ │
│ │ Footprint │ │
│ │ │ │
│ └───────────────┘ │
│ │
└──── Rear Setback ─────┘

Setbacks are calculated based on:

  • Building height — Taller buildings require larger setbacks
  • Road width — Wider abutting roads may reduce front setback requirements
  • Zone — Different zones have different base setback rules
  • Authority — BDA, BBMP, etc. have different regulations

Coordinate Systems

The engine uses pyproj for coordinate transformations:

CRSUse Case
WGS84 (EPSG:4326)Geographic coordinates (lat/lon) — input/output
UTM (auto-detected)Projected coordinates (meters) — calculations

All geometric calculations (area, distance, setbacks) are performed in UTM coordinates for metric accuracy, then results are converted back to WGS84 for display.

Integration with Frontend

The frontend receives analysis results and visualizes them:

  1. SunCalc (JavaScript) provides real-time sun position for the interactive map
  2. pvlib (Python) provides the detailed analysis data stored in solution results
  3. Three.js renders 3D shadow volumes on the map
  4. Users can scrub through time of day/year to see shadow movement