Description Usage Arguments Value Examples
Spatial index distance matrix
1 2  | spatial_link_index(data1, lat1, lon1, id1, data2, lat2, lon2, id2,
  within = NULL, closest = FALSE)
 | 
 | 
 Dataset 1  | 
 | 
 Latitude variable in dataset 1  | 
 | 
 Longitude variable in dataset 1  | 
 | 
 Unique key in dataset 1  | 
 | 
 Dataset 1  | 
 | 
 Latitude variable in dataset 2  | 
 | 
 Longitude variable in dataset 2  | 
 | 
 Unique key in dataset 2  | 
 | 
 Link   | 
 | 
 Closest within Boolean (unique key is id2, so typically zip code)  | 
This function returns a data table of pairwise distances within
kilometers with column names id1, id2 and Distance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14  | years <- 2000:2002 # possible range 1990-2018
within_km <- 9.656 # 6 miles
parameter_code <- 81102 # for PM 10
##----- Get PM10 annual data and set unique Monitor key
# Download AQS data in Data_AQS/all.
# get_AQS_data_annual(years)
PM <- load_annual_average(years)
PM <- subset(PM, Parameter.Code == parameter_code)
##----- Zip codes
ZIP <- get_zip_codes()
##----- Spatial index to join monitors and Zip codes.  May take a couple of minutes
Link_PM_Zip_Index <- spatial_link_index(PM, "Latitude", "Longitude", "Monitor",
                                        ZIP, "Latitude.zip", "Longitude.zip", "zip",
                                        within = within_km) 
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.