Use elevation data to compute the locations that can be seen, or how much higher they would have to be to be seen, from a certain position. The raster data coordinate reference system must planar (not lon/lat), with the elevation values in the same unit as the distance unit of the coordinate reference system.
x: SpatRaster, single layer with elevation values. Values should have the same unit as the map units
loc: location (x and y coordinates) or a cell number
observer: numeric. The height above the elevation data of the observer
target: numeric. The height above the elevation data of the targets
curvcoef: numeric. Coefficient to consider the effect of the curvature of the earth and refraction of the atmosphere. The elevation values are corrected with: elevation = elevation - curvcoeff * (distance)^2 / (earth_diameter). This means that with the default value of 0.85714, you lose sight of about 1 meter of elevation for each 385 m of planar distance
output: character. Can be "yes/no" to get a binary (logical) output showing what areas are visible; "land" to get the height above the current elevation that would be visible; or "sea" the elevation above sea level that would be visible