Build a continuous horizon profile from measurements of horizon altitude at known bearings around a site, or predict the horizon and visible terrain from a DEM.
createHor(
az,
alt,
loc,
dem = NULL,
loc.crs = NULL,
name = "",
alt.unc = 0.5,
smooth = F,
.scale = 1000,
eye.height = 1.6,
max.distance = 10000,
az.step = 0.25,
distance.step = NULL,
features = NULL,
curvature = TRUE,
refraction.k = NULL,
atm = skyscapeR.env$atm,
temp = skyscapeR.env$temp,
tempgrad = -10,
panorama = TRUE,
width = 4096,
panorama.distance.step = "adaptive",
panorama.acuity = 1,
terrain.palette = "temperate",
land_cols = NULL,
sea_cols = NULL,
sea_level = 0,
n_sea = 3L,
palette_n = 256L,
lighting = c("relief", "directional"),
light.azimuth = 315,
light.altitude = 45,
ambient = 0.4,
haze = 0.65,
image.dir = getwd(),
attribution = "User-supplied DEM",
license = "See source DEM terms",
ncores = NULL,
verbose = TRUE,
progress = interactive() && verbose,
contrast = 0.7
)
az |
Array of azimuth values |
alt |
Array of altitude values. |
loc |
Observer location. For DEMs, pass a single CRS-bearing terra SpatVector point directly as loc, or a numeric latitude and longitude. Ground elevation is read from the DEM unless supplied as a third numeric value. Measured horizons take latitude, longitude and elevation. |
dem |
Optional single-band terra SpatRaster or local raster filename. Supply dem in place of az and alt. Requires the optional terra package. |
loc.crs |
CRS for numeric DEM observer coordinates in x,y order (easting, northing or longitude, latitude). Without it, numeric loc uses latitude, longitude in WGS84. A single terra SpatVector point carries its own CRS. An optional third numeric coordinate is ground elevation in metres. |
name |
Name of site. |
alt.unc |
Either a single value or an array of altitude uncertainty. |
smooth |
Logical to control whether to smooth horizon profile using rolling mean. Defaults to FALSE |
.scale |
Number of samples in the rolling mean when smooth = TRUE. The grid spacing is 0.01 degrees, so 1000 samples span approximately 10 degrees. |
eye.height |
Observer height above the selected ground elevation in metres. |
max.distance |
DEM search radius in metres, default 10000. Include any distant terrain that could form the horizon within the DEM coverage. |
az.step |
Maximum spacing of numerical DEM rays in degrees. The default is 0.25. An equal number of steps fills the circle. |
distance.step |
Maximum spacing of samples along each ray in metres. By default use half the smaller native cell dimension estimated at the site. |
features |
Optional |
curvature |
Apply Earth curvature to DEM sightlines. Default TRUE. |
refraction.k |
Default NULL applies Patat when curvature is enabled. Set zero for geometric curvature without terrestrial refraction, or supply a coefficient below one for the effective-radius model. |
atm |
Ground atmospheric pressure in millibars for Patat terrestrial refraction. |
temp |
Ground air temperature in degrees Celsius. |
tempgrad |
Vertical temperature gradient in kelvins per kilometre (default -10). |
panorama |
Render an external terrain PNG for a DEM. Default TRUE. Set FALSE for the numerical horizon alone. |
width |
DEM panorama width in pixels, an even integer from 32 to 81920. Default 4096 by 2048 pixels. Height is half the width. Widths above 8192 are assembled from temporary image tiles. Both dimensions grow with width, so a tenfold increase generates 100 times as many pixels. |
panorama.distance.step |
The default, "adaptive", starts at one local DEM cell and increases radial spacing with distance using the larger of the requested angular acuity and one horizontal PNG pixel. This transverse footprint is a proxy for radial detail. A narrow ridge may fall between samples. Use a positive number for fixed spacing in metres or NULL to reuse distance.step. The numerical horizon uses distance.step independently. Inspect metadata$image$sampling for the effective angle, sample count and actual step range. On large DEM-only panoramas, the renderer checks near terrain against a conservative upper bound for the remaining terrain on each ray. It skips distant samples only where all remaining elevations are hidden and keeps neighbours for surface shading. Terrain with added archaeological features uses the full sampling path. |
panorama.acuity |
Angular detail target in arcminutes for adaptive PNG sampling. Defaults to 1 (nominal 20/20 acuity). Larger values coarsen distant terrain. |
terrain.palette |
Named land/water pair from |
land_cols, sea_cols |
Opaque R colour names or hex colours in increasing elevation order. NULL inherits the respective ramp from terrain.palette. Supply either vector to override just that ramp. One colour gives a uniform base. Colours interpolate in Lab space. |
sea_level |
DEM elevation in metres at or below which the sea colour ramp is used. Default 0. A level water surface uses the shallow colour. This is an elevation threshold. Use NULL to apply the land palette over the whole visible elevation range, including depressions. The temperate land ramp starts at the lowest visible land level or sea threshold, whichever is higher. Other palettes with a threshold start at sea_level. The ramp ends at the highest visible elevation. The sea ramp starts at the lowest visible elevation. |
n_sea |
Number of entries reserved for the sea ramp, leaving at least two land colours. Default 3. |
palette_n |
Total number of palette entries, from 4 to 65536. Default 256. |
lighting |
Relief lighting (default) blends a light at the observer (75 percent) with the directional source (25 percent). It shades both sides of a slope and lifts deep shadows. The standalone renderer brightness response is min(1, ambient + contrast * illumination), with illumination floored at 0.15. Terrain and visible horFeature surfaces use the same lighting. Choose "directional" for one-sided hillshade. Lighting affects the PNG only. |
light.azimuth, light.altitude |
Direction towards the illustrative light source in degrees clockwise from true north and above the horizon. Defaults are 315 and 45 degrees. Hillshading uses upward surface normals in metric east, north and vertical coordinates. This is local illumination without cast shadows from other terrain. |
ambient |
Fraction of illumination retained on slopes facing away from the light (0 to 1). Default 0.40. Use 1 for unshaded palette colours. |
haze |
Maximum fraction of distance haze (0 to 1). Default 0.65. Set haze=0 and ambient=1 to inspect the colour mapping alone. |
image.dir |
Directory for the DEM PNG. Defaults to the working directory. Site names form the filename; different images with the same name receive a checksum suffix. |
attribution |
Credit for the DEM, included in plots and exports. The generic default credit is omitted from plots. |
license |
Source licence or terms for the DEM, included in exports. |
ncores |
Maximum DEM tracing workers. Defaults to half the available logical cores, rounded down with a minimum of one. The startup message reports used and available cores. Workers share file-backed DEM data and process separate bearings. |
verbose |
Announce the DEM radius, sampling and rendering stages. |
progress |
Show a progress bar for each tracing stage. Default on in interactive verbose sessions. |
contrast |
Relief-light contrast (0 to 1), default 0.70, following the standalone renderer. It controls slope detail independently of ambient brightness. Ignored for directional lighting, which retains ambient + (1 - ambient) * illumination. Regenerate existing panoramas to apply new settings. |
Measured bearings. To evaluate sightlines between measured bearings, the constructor repeats the azimuths one turn in each direction, removes duplicate azimuth entries and linearly interpolates altitude and altitude uncertainty onto a 0.01-degree grid from -90 to 450 degrees. Scalar uncertainty is repeated. Optional smoothing applies a running mean over the specified number of grid samples to both series, with zero fill at the outer ends. Latitude, longitude and elevation identify the observer; omitted elevation defaults to zero. Interpolation cannot recover narrow features between measurements.
Observer and DEM coverage. For a DEM, supply a point with a CRS, projected x and y with loc.crs, or WGS84 latitude and longitude. The optional third coordinate is ground elevation in metres in the DEM's vertical datum. Otherwise ground elevation is bilinearly sampled at the site. Observer elevation in the returned georeference is ground elevation plus eye.height. A terrain model represents bare earth. A surface model includes the objects represented in its elevations. Use a single continuous band in metres with a defined horizontal CRS. Missing samples and terrain beyond the raster edge are skipped. A warning and the incomplete.bearings metadata identify incomplete coverage. Each bearing needs at least one usable sample.
Sampling narrow ridges. Terrain is sampled along true bearings from north, clockwise. A WGS84 local azimuthal equidistant projection sets the distances and bearings. Sample coordinates are transformed to the source grid for bilinear elevation extraction in batches. Each horizon angle is the maximum sampled elevation angle along its ray. The requested radius is included wherever covered. A missing observer ground elevation without an override or an observer outside the DEM cause an error. Rays and distance samples are discrete. A finer constructor output grid cannot recover a ridge between rays, steps or DEM cells. Increase the radius and refine both sampling intervals to check convergence for a site. At 5 km the default 0.25-degree rays are approximately 22 metres apart. The supplied altitude uncertainty is an assumption in degrees.
Curvature and terrestrial refraction. By default the apparent altitude at each sampled distance d (metres) follows Patat (2011), equations 1 and 2. The geometric angle is atan((z-observer)/d - d/(2R)). Add (d/R) times 0.252 P (34.2 + tempgrad) / T squared in radians, using temperature T in kelvins and the latitude-dependent radius R from Appendix A1. The same corrected angles determine the numerical horizon and the visible terrain in the PNG. An explicit numeric refraction.k selects a spherical vertical section of effective radius 6371008.8 / (1 - refraction.k) metres. At ground distance d and elevation z, the forward component is (R + z) sin(d/R) and the vertical component is z minus observer elevation minus 2 (R + z) sin(d/(2R)) squared, where the square applies to the sine. The angle is obtained with atan2. With curvature disabled, use the height difference and horizontal distance directly. Terrestrial refraction applies to the terrain sightline. Atmospheric refraction is controlled separately in astronomical calls.
Panorama and reconstructed features. By default a second set of rays paints the first visible terrain at each
azimuth and elevation, using local surface normals, elevation colours and
distance haze. The transparent sky edge follows the numerical horizon.
With features, each PNG column is traced directly through the reconstructed
terrain; its edge can differ from the interpolated numerical horizon between
rays. Refine az.step and width when examining narrow structures.
The panorama spans the full 360 degrees from nadir to zenith. The horizon object
stores its bounds, checksum, attribution and licence in metadata$image.
Save the external PNG alongside the RDS. If you move them, use relinkHor
to reconnect the image. A rendering failure returns the numerical horizon with a warning.
Plotting also falls back to the numerical horizon if the image is missing or has changed.
A skyscapeR.horizon list with metadata (site name and georeference) and a data frame named data. Its az, alt and alt.unc columns contain azimuth, horizon altitude and altitude uncertainty, all in degrees.
H01 compared 334 bearings at 31 observing setups.
At the surveyed bearings, createHor() reproduced the observed terrain skyline to within half a degree in 91.9% of cases.
See the H01 field validation in the skyscapeR technical manual for the survey protocol, station results and limitations.
With the same 1 m terrain, createHor() reproduced Horizon’s skylines to a mean absolute difference of 0.004 degrees at each of two English sites. Against field measurements at 344 Irish bearings, createHor() using SRTM had a mean absolute error of 0.328 degrees, lower than either HeyWhatsThat or PeakFinder on that sample. Field accuracy varied by site. See the H02 comparison in the skyscapeR technical manual.
The numerical skyline is a maximum over sampled terrain, not an accuracy certificate for the DEM. Horizontal and vertical datum differences, observer height, missing raster values, vegetation and buildings can exceed the sampling error. DEM elevations and a supplied observer ground elevation must use a compatible vertical datum. No geoid conversion or vertical-datum correction is performed automatically. Refine the angular and distance sampling and expand the radius until the relevant sightlines are stable. Compare with surveyed bearings and altitudes where available.
alt.unc is supplied by the user and is not estimated from DEM resolution,
control residuals or atmospheric variability. Smoothing a measured profile can
remove narrow notches or peaks. Adaptive panorama sampling and illustrative
lighting concern the image; they do not increase numerical horizon precision.
The terrestrial refraction approximation assumes the supplied atmosphere and
cannot reproduce all near-ground gradients or mirage conditions.
Save the DEM provenance, observer location and datum, constructor arguments, feature objects, returned horizon and external PNG. Rebuilding from the same source is distinct from merely replotting the saved horizon.
H03 examines DEM sampling against an analytic ridge and a level spherical surface. H03 scientific validation.
At 334 surveyed bearings, the median absolute skyline error was 0.036 degrees and 91.9 percent of predictions were within half a degree. H01 study.
On matched 1 m terrain at two English sites, the mean absolute skyline difference from Horizon was 0.004 degrees. Agreement with surveyed bearings varied by site. H02 study.
On a level surface with 5 m radial sampling, geometric and effective-radius horizon dips agreed with the analytic values to within 0.000000009 degrees. H03 study.
Across 32 synthetic wall panoramas, the largest numerical skyline discrepancy was 0.0261 degrees. Pixel width affected the displayed width of the opening. H04 study.
At eight withheld landmarks in a tilted synthetic panorama, both bearing and skyline altitude were recovered to within one image pixel. H05 study.
The field-to-sky replay recovered the Gacrux position between the Skorba West entrance edges, 2.41 degrees above the measured skyline at the illustrated instant. W02 study.
Patat, F. (2011). Horizon synthesis for archaeo-astronomical purposes. Astronomische Nachrichten 332, 743-749. doi:10.1002/asna.201111570.
importPeakFinder, plot.skyscapeR.horizon
createHWT, downloadHWT
## Not run:
observer <- terra::vect("observer.gpkg") # one point with a CRS
h <- createHor(dem="terrain.tif", loc=observer, eye.height=1.6)
## End(Not run)
# Create a skyscapeR.horizon from 5 measurements:
az <- c(0,90,180,270,360)
alt <- c(0,5,5,0,0)
hor <- createHor(az, alt, alt.unc=0.1, loc=c(40.1,-8), name='Test')
plot(hor)
## Not run:
# loc is latitude, longitude. Distances and elevations are metres.
terrain <- createHor(dem="site-dtm.tif", loc=c(51.19,-1.75),
name="Survey site", max.distance=5000, eye.height=1.6,
image.dir="horizons", attribution="Survey DTM", license="Survey terms")
plot(terrain)
exportStellarium(terrain, name="Survey site")
## End(Not run)