Solar azimuth angle calculator from latitude, declination and hour angle
The solar azimuth angle calculator finds the compass bearing of the sun from an observer's latitude, the sun's declination, and the local solar hour angle.
Run — free
It reports an angle measured clockwise from true north together with a familiar sixteen-point compass direction. Enter all three angles in decimal degrees, using negative hour angles before local solar noon and positive values after noon. The calculation is deterministic, runs without network access, and is suitable for checking solar geometry used in daylighting, photovoltaic planning, shadow studies, and educational astronomy.
Enter the three solar-geometry angles correctly
Start with the observer's geographic latitude in decimal degrees. Northern latitudes are positive, southern latitudes are negative, and the allowed range runs from minus ninety to plus ninety degrees. Solar declination describes the sun's angular position north or south of the celestial equator. It changes through the year and is positive when the sun is north of that equator. The hour angle describes time relative to local solar noon rather than civil clock noon. Use zero at local solar noon, negative values during the solar morning, and positive values during the solar afternoon. Fifteen degrees of hour angle corresponds to approximately one hour of solar time. All three inputs must use the same degree convention; do not supply radians. Longitude and time zone are not inputs because this calculator assumes that declination and local solar hour angle have already been determined. If starting from a date, clock time, and longitude, calculate those astronomical quantities first before using this focused spherical-trigonometry step.
Understand the angle and compass result
The result uses the navigation-style azimuth convention: zero degrees is true north, ninety degrees is east, one hundred eighty degrees is south, and two hundred seventy degrees is west. Values increase clockwise and remain below three hundred sixty degrees. Alongside the numeric angle, the calculator assigns the closest of sixteen compass points, such as NNE, SE, or WNW. Each compass sector spans twenty-two and a half degrees, so the label is a readable summary rather than a replacement for the more precise numeric value. The calculation forms the sun's local east and north vector components from latitude, declination, and hour angle, then applies a quadrant-aware arctangent. That approach avoids the north-versus-south ambiguity that can arise when azimuth is recovered from an inverse cosine alone. The bearing is relative to true north, not magnetic north. A field compass can therefore disagree unless local magnetic declination is applied separately. The output describes direction even if the modeled sun is below the horizon.
Recognize limits and singular positions
Solar azimuth is meaningful when the sun's direction has a horizontal component. If the supplied geometry places the sun exactly at the zenith, directly overhead, every horizontal direction points away from the same position and no unique azimuth exists. The same mathematical ambiguity occurs at the nadir, directly below the observer. The calculator rejects those singular cases instead of returning an arbitrary bearing. Very close to either singularity, small changes in an input can cause a large change in azimuth; that sensitivity is a property of the geometry, not numerical randomness. The calculation also does not correct for atmospheric refraction, terrain, building obstructions, magnetic declination, or the apparent radius of the solar disk. Those effects matter for observed sunrise, sunset, and shading boundaries. For engineering work, retain the numeric bearing and document how declination and hour angle were obtained. Repeating the same input produces the same result, which makes the calculator useful in test fixtures, spreadsheets, scripts, and reproducible solar-position workflows through the API at $0.002 per request.
What you can do with it
Orient a photovoltaic array
Find the sun's true-north bearing for a known solar instant before comparing it with a panel or tracker orientation.
Plan shadows and daylight
Use the azimuth as an input to a site, facade, or shading study when the relevant declination and solar hour angle are known.
Check astronomy calculations
Verify a spherical-trigonometry worksheet or software test with a deterministic bearing and an easy-to-read compass sector.
FAQ
What direction is zero degrees azimuth?
Zero degrees is true north. The angle increases clockwise, placing east at ninety degrees, south at one hundred eighty degrees, and west at two hundred seventy degrees.
Should morning hour angles be positive or negative?
Use negative hour angles before local solar noon, zero at local solar noon, and positive hour angles after local solar noon.
Does the compass direction use magnetic north?
No. Both the angle and compass label refer to true north. Apply the location's magnetic declination separately when comparing the result with a magnetic compass.
Can the calculator return a direction when the sun is below the horizon?
Yes. The spherical geometry still defines the direction of the sun, although it is not visible. The calculator does not test terrain or the visible horizon.
Why can solar azimuth be undefined?
At the exact zenith or nadir the solar direction has no horizontal component, so there is no unique compass bearing. The calculator reports that singular geometry as invalid input.
What does the API calculation cost?
Each API request costs $0.002. The same deterministic calculation can run in the browser without network access.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/trig/azimuth-of-sun \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"lat":40.7128,"declination":23.44,"hour_angle":-30}'const res = await fetch("https://api.kit.forhosting.com/trig/azimuth-of-sun", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"lat": 40.7128,
"declination": 23.44,
"hour_angle": -30
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/trig/azimuth-of-sun",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"lat": 40.7128,
"declination": 23.44,
"hour_angle": -30
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/trig/azimuth-of-sun", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"lat":40.7128,"declination":23.44,"hour_angle":-30}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"lat":40.7128,"declination":23.44,"hour_angle":-30}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/trig/azimuth-of-sun", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"lat": 40.7128,
"declination": 23.44,
"hour_angle": -30
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "trig.azimuth_of_sun",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |