HOW TO
Shadow analysis such as calculating shadow lengths plays a crucial role for urban planning and environmental studies. For instance, in urban planning, calculating shadow lengths can help determine the optimal placement of new buildings to prevent casting long shadows over public parks, ensuring they receive adequate sunlight for recreational use.
This article provides the workflow to calculate shadow lengths using Arcade in the ArcGIS Enterprise portal and ArcGIS Online.
var buildingHeight = $feature.Building_Height;
var sunAltitude = $feature.SunAltitude;
var sunAzimuth = $feature.SunAzimuth;
if (IsEmpty(buildingHeight) || IsEmpty(sunAltitude) || IsEmpty(sunAzimuth) || sunAltitude <= 0) {
return null;
}
var toRadians = PI / 180;
var sunAltitudeRadians = sunAltitude * toRadians;
var shadowLength = buildingHeight / Tan(sunAltitudeRadians);
return "Length: " + Round(shadowLength, 2) + " meters, Azimuth: " + Round(sunAzimuth, 2) + " degrees";
The code block below shows the example of the full working script:
var buildingHeight = $feature.Building_Height;
var sunAltitude = $feature.SunAltitude;
var sunAzimuth = $feature.SunAzimuth;
if (IsEmpty(buildingHeight) || IsEmpty(sunAltitude) || IsEmpty(sunAzimuth) || sunAltitude <= 0) {
return null;
}
var toRadians = PI / 180;
var sunAltitudeRadians = sunAltitude * toRadians;
var shadowLength = buildingHeight / Tan(sunAltitudeRadians);
return "Length: " + Round(shadowLength, 2) + " meters, Azimuth: " + Round(sunAzimuth, 2) + " degrees";
The attribute table below shows the calculated shadow lengths in the 'ShadowGeometry' field.
Article ID: 000034650
Get help from ArcGIS experts
Download the Esri Support App