registry_KNN_dist {ARPALData}R Documentation

Identifies the K-nearest-neighbors (stations) to all the monitoring sites included in a given ARPALdf registry data.frame. The neighbors are identified computing the Euclidean distance among the sites' coordinates.

Description

For each element included in reg_X, it identifies the k-nearest neighbors locations (among those included in reg_Y) according to an Euclidean distance metric. reg_X and reg_Y must be two 'ARPALdf' objects obtained using get_ARPA_Lombardia_xxx_registry'.

Usage

registry_KNN_dist(reg_X, reg_Y, k = 1)

Arguments

reg_X

Dataset of class 'ARPALdf' containing the stations list obtained as registry (from 'get_ARPA_Lombardia_xxx_registry' command). The object must contain the following colums: 'IDStation','NameStation','Longitude' and 'Latitude'.

reg_Y

Dataset of class 'ARPALdf' containing the stations list obtained as registry (from 'get_ARPA_Lombardia_xxx_registry' command). The object must contain the following colums: 'IDStation','NameStation','Longitude' and 'Latitude'.

k

Integer value. Represents the number of neighbors the user wants to identify.

Value

A data.frame object having the same length of reg_X. For each row (stations in reg_X) it contains the name and the IDStation code for the k-nearest neighbors.

Examples

if (require("tidyverse")) {
    regAQ <- get_ARPA_Lombardia_AQ_registry()
    regAQ <- regAQ %>% filter(Pollutant %in% c("PM10","Ammonia"))
    regW <- get_ARPA_Lombardia_W_registry()
    registry_KNN_dist(regAQ,regW,k=2)
}


[Package ARPALData version 1.5.2 Index]