Skip to content
croppersPublic

About

Estimate roof area from satellite imagery and calculate solar energy & rainwater harvesting potential

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

64 Commits

Folders and files

Repository files navigation

Roofm²

Roofm² is a streamlined planning tool for measuring a roof from satellite imagery and estimating:

  • horizontal roof area;
  • likely rooftop solar capacity and monthly generation; and
  • monthly and annual rainwater collection potential.

The full workflow runs on one page: search for an address, verify or draw the roof, review the assumptions, calculate, and download a PDF.

Quick start

Requirements: Node.js 22, npm, and Python 3.13. nvm use will read the included .nvmrc.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
npm ci
npm run dev

Open http://localhost:3000. The development command starts both Next.js and the local Python solar function. No API key is required.

Environment variables

Variable Required Purpose
ROOFM2_CONTACT_EMAIL No Contact included in the server-side Nominatim user agent.
CLIMATE_API_URL No Override the official NASA POWER climatology endpoint.
NOMINATIM_API_URL No Override the OpenStreetMap Nominatim search endpoint.
OVERPASS_API_URL No Override the OpenStreetMap Overpass endpoint.

Never commit .env.local or API keys.

How the estimate works

  • Map and area: Leaflet displays Esri World Imagery. A user-drawn or suggested OpenStreetMap building polygon is measured geodesically with Turf. The result is horizontal plan-view area, not sloped surface area.
  • Solar: The app estimates screening technical potential from roof area, tilt, effective whole-roof panel coverage, and module efficiency. The 20% default coverage is a residential starting assumption that acts as a proxy for unsuitable roof faces, shade, obstructions, access paths, setbacks, and panel layout; it is not detected from imagery. An open-source PySAM function runs the PVWatts V8 model locally against hourly NASA POWER irradiance, temperature, and wind data. It runs the fixed 2021–2023 weather years independently and returns their mean monthly AC production, making results reproducible while reducing dependence on one unusual year.
  • Rainwater: NASA POWER monthly precipitation climatology is converted deterministically using liters = mm/day × days × plan area m² × collection efficiency. The result is roof runoff potential after the selected collection efficiency, not usable water supply.
  • Report: jsPDF creates a text-and-table report locally in the browser. The address is not stored by this project.

If hourly weather or the Python model is unavailable, the interface clearly labels a lower-detail monthly horizontal-irradiance fallback. Defaults are editable and disclosed in the interface. Solar generation, rainwater volume, and the suggested building outline are planning estimates—not engineering designs, quotes, or guarantees. The solar model applies one tilt and azimuth to all panels and does not size an array to electricity use. Detailed roof facets, shade, obstructions, structural suitability, equipment layout, permitting, and utility interconnection are outside the model. Rainwater totals do not model tank capacity, overflow, first-flush diversion, demand timing, treatment, or seasonal storage requirements.

External services and responsible use

An explicit address search sends the query to this app’s server and then to Nominatim. Coordinates are sent to Overpass and NASA POWER when their respective features are used. The production calculation does not send requests to NREL. Shared OpenStreetMap and NASA services have usage limits; applications with material traffic should configure providers and caching that support their volume.

Data and service attribution:

  • address and building data: © OpenStreetMap contributors;
  • imagery: Esri and the providers named in the map attribution;
  • climate: NASA POWER;
  • solar performance model: PySAM implementation of PVWatts V8.

Quality checks

npm run lint
npm run typecheck
npm test
python -m unittest discover -s tests
npm run build

Unit tests cover NASA POWER parsing, hourly PySAM execution, solar units, area-to-capacity conversion, deterministic rainwater calculation, invalid climate values, and polygon validation. CI runs the JavaScript and Python checks on pull requests and pushes.

Project structure

app/                  Next.js page, metadata, and global styles
api/                  Vercel Python solar function
components/           Search, map, workflow, charts, and PDF report
pages/api/            Server-side provider adapters
solar_model/          NASA POWER parsing and PySAM PVWatts execution
tests/                Python model tests
utils/                Area and estimation formulas
utils/server/         Shared API validation, timeout, and cache helpers

Deployment

Vercel deploys the Next.js application and the root api/solar.py Python function from the same GitHub repository. Production is connected to the main branch and the custom roofm2.com domain. The pinned Python runtime and dependency versions are defined in .python-version and requirements.txt.

License

Open source under the MIT License. Contributions are welcome at github.com/croppers/roofm2.

About

Estimate roof area from satellite imagery and calculate solar energy & rainwater harvesting potential

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages