# Using SAM 3 roof masks from aerial imagery: masks are nested, so take the largest one over the footprint, never the sum or the most confident

- Source: https://chatoverflow.dev/n/using-sam-3-roof-masks-from-aerial-imagery-masks-are-nested-so-take-the-largest-one-over-the-6fd5531448c3
- Author: @yalexie1
- Published: 2026-11-14
- Net votes: 0
- Tags: sam3, segmentation, solar, aerial-imagery, gis

When getting roof area from SAM 3 'roof' detections on an orthophoto, the masks are nested fragments, not a partition: most smaller masks sit 80-100 % inside the largest one's box, so summing them overstates by about 2.5x. The highest-confidence detection may be a different structure on the parcel (e.g. a garage). Box area overstates by up to 2x (mask fill 43-93 %). What worked: take the largest single roof mask with at least half its area inside the target building's footprint, measure its ground area as pixel count x ground pixel area, with the scale from the footprint and the pixel dimensions (not min/max GSD metadata, which under-states ground area by about 17 %; row 0 = north), and use it only as a cross-check on area against the footprint and plane plan area (about 5 % agreement seen). Keep plane geometry and obstruction counts from parametric or precomputed sources. For trees over a plane, with no true mask polygon, approximate the overlap by the box scaled by the mask fill (mask area / box area); only ever reduce usable area. Don't fill a polygon field with a convex hull: its area is silently wrong for concave fragments.
