{"id":19891842,"url":"https://github.com/inbo/territoria","last_synced_at":"2025-10-24T03:02:40.720Z","repository":{"id":39274795,"uuid":"374921323","full_name":"inbo/territoria","owner":"inbo","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-04T11:32:08.000Z","size":208,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-04T19:08:02.330Z","etag":null,"topics":["bird","breeding","cluster","home-range","r","territory"],"latest_commit_sha":null,"homepage":"https://inbo.github.io/territoria","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inbo.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":".zenodo.json"}},"created_at":"2021-06-08T07:29:31.000Z","updated_at":"2023-07-18T09:15:16.000Z","dependencies_parsed_at":"2025-06-04T12:53:21.323Z","dependency_job_id":"bbb9af31-7a35-4cf7-962c-0f08eb11fdb8","html_url":"https://github.com/inbo/territoria","commit_stats":{"total_commits":39,"total_committers":2,"mean_commits":19.5,"dds":0.02564102564102566,"last_synced_commit":"23e08ce479aefe17928d61c74e6a0bb8c6b249a5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/inbo/territoria","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inbo%2Fterritoria","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inbo%2Fterritoria/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inbo%2Fterritoria/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inbo%2Fterritoria/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inbo","download_url":"https://codeload.github.com/inbo/territoria/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inbo%2Fterritoria/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263991444,"owners_count":23540665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bird","breeding","cluster","home-range","r","territory"],"created_at":"2024-11-12T18:19:50.104Z","updated_at":"2025-10-24T03:02:40.645Z","avatar_url":"https://github.com/inbo.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = file.path(\"man\", \"figures\", \"README-\"),\n  out.width = \"100%\"\n)\n```\n\n# territoria\n\n\u003c!-- badges: start --\u003e\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![Lifecycle: stable](https://lifecycle.r-lib.org/articles/figures/lifecycle-stable.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n[![License](https://img.shields.io/badge/license-GPL--3-blue.svg?style=flat)](https://www.gnu.org/licenses/gpl-3.0.html)\n![GitHub](https://img.shields.io/github/license/inbo/territoria)\n[![R build status](https://github.com/inbo/territoria/workflows/check%20package%20on%20main/badge.svg)](https://github.com/inbo/territoria/actions)\n[![Codecov test coverage](https://codecov.io/gh/inbo/territoria/branch/main/graph/badge.svg)](https://app.codecov.io/gh/inbo/territoria?branch=main)\n![r-universe name](https://inbo.r-universe.dev/badges/:name?color=c04384)\n![r-universe package](https://inbo.r-universe.dev/badges/territoria)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/inbo/territoria.svg)\n![GitHub repo size](https://img.shields.io/github/repo-size/inbo/territoria.svg)\n\u003c!-- badges: end --\u003e\n\nThe goal of `territoria` is to cluster observations from different breeding bird surveys into territoria.\n\n## Installation\n\nYou can install the development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"inbo/territoria\")\n```\n\n## Example\n\nWe start by simulating some observations.\nWe need for  every observation their `x` and `y` coordinates in a projected coordinate system.\n`survey` is an integer id for every survey.\nA survey is a unique combination of an area and date.\n`status` is an integer indication the breeding status.\nA higher value assume more certainty about breeding.\nSet this to a constant value if you don't distinct between different certainties.\nIn this example we use three classes: `1`, `2` and `3`.\n\n```{r sim-data}\nlibrary(territoria)\nset.seed(20210806)\nobs \u003c- simulate_observations()\nnames(obs)\nsummary(obs$centroids)\nsummary(obs$observations)\nobs \u003c- obs$observations[obs$observations$observed, ]\n```\n\nOnce we have a data.frame with the observations, we connect to a SQLite database and import the observations.\nThis assigns every observation to its own cluster.\n\n```{r import-data}\nconn \u003c- connect_db()\nimport_observations(observations = obs, conn = conn, max_dist = 336)\nresult \u003c- get_cluster(conn = conn)\nnrow(result$observations) == nrow(result$cluster)\n```\n\nNext, we need to calculate the distance matrix.\nThis is not the full distance matrix.\nWe omit all irrelevant distances, e.g. between observations from the same survey or with a distance larger than twice the maximum cluster distance.\n\n```{r distance}\ndistance_matrix(conn = conn, max_dist = 366)\n```\n\nNow we can start the clustering.\nThe clustering takes into account all observations with a `status` greater than or equal to the set status.\n\n```{r cluster-3}\ncluster_observation(conn = conn, status = 3, max_dist = 336)\nresult3 \u003c- get_cluster(conn = conn)\nnrow(result3$observations) \u003e nrow(result3$cluster)\n```\n\nRepeat the clustering for every status level.\nNote that skipping levels implies that we combine them with the lower level.\n\n```{r cluster-1}\ncluster_observation(conn = conn, status = 1, max_dist = 336)\nresult1 \u003c- get_cluster(conn = conn)\nnrow(result1$observations) \u003e nrow(result1$cluster)\nnrow(result3$cluster) \u003e nrow(result1$cluster)\nsummary(result1$observations)\nsummary(result1$cluster)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finbo%2Fterritoria","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finbo%2Fterritoria","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finbo%2Fterritoria/lists"}