---
title: "Coarse raw positions"
author: "Georg Rüppel"
date: "`r Sys.Date()`"
output:
  rmarkdown::html_vignette:
    toc: no
vignette: |
  %\VignetteIndexEntry{Coarse raw positions}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

Unlike with data from GPS devices, exact geographic positions cannot directly be inferred from radio-telemetry data.
Instead, it is necessary to estimate the geographic positions of an animal from available information about the location of the radio-receiving station(s), the antenna bearing, its spatial probability of detection and the strength of the detected radio signal.
For this purpose, movetrack uses a geometric approach described in Baldwin et al. ([2018](https://doi.org/10.1016/j.ecolmodel.2018.08.006)).
This is a three-step process that utilises basic principles of antenna geometry:

1. Raw position estimation
- For **directional antennas**, a coarse raw position is calculated along the directional beam of the receiving antenna.
The distance to the station is assumed to be half of the theoretical antenna detection range, which can be specified for each antenna type ([Motus Docs](https://docs.motus.org/en/stations/station-equipment/antennas#antenna-types)).
- For **omnidirectional antennas**, the station location itself is used as the raw position.

2. Measurement errors
- For **directional antennas**, raw positions are assigned oscillating longitudinal and latitudinal standard deviations, i.e. measurement errors, that arise from antenna geometry and orientation.
Longitudinal error reaches up to half the theoretical antenna detection range when the antenna is oriented east or west and is minimal when oriented north or south; the opposite is true for latitudinal error.
- For **omnidirectional antennas**, the theoretical antenna detection range is used as the longitudinal and latitudinal measurement errors.

![Longitudinal (blue) and latitudinal (orange) measurement errors, which are used in the observation model part of the hidden Markov model, vary depending on the antenna orientation up to half of the theoretical antenna detection range. Note that this figure illustrates measurement errors specifically for a 6-element Yagi antenna.](../man/figures/error.svg)

3. Aggregation

Finally, the raw positions and measurement errors from all antennas are aggregated over user-defined time intervals.
For each interval, weighted means---based on signal strength (e.g., measured in dB)---are calculated for both the raw positions and measurement errors.
This data forms the basis of the observational part in the hidden Markov model (see `vignette("hmm")`).

![Illustration of how raw positions are estimated by integrating data from station locations, antenna bearings, and signal strength (represented by wedge length). Detections from all stations and antennas are aggregated over fixed time intervals, producing a single coarse raw position per interval---illustrated here for two consecutive intervals $t_1$ and $t_2$. For simplicity, only the combined contributions from each station (shown as coloured dots) to the resulting coarse raw positions (diamonds) are displayed. Each position is computed as a signal-strength-weighted mean, with point size indicating the strength of contribution. Estimation accuracy improves with the number of contributing stations and antennas.](../man/figures/raw_positions.svg){width=600}

## References

Baldwin, J. W., Katie, L., Finn, J. T. & Smetzer, J. R. (2018). Bayesian state-space models reveal unobserved off-shore nocturnal migration from Motus data. *Ecological Modelling*, 386, 38--46. doi: [10.1016/j.ecolmodel.2018.08.006](https://doi.org/10.1016/j.ecolmodel.2018.08.006)
