library(rnoaa)
library(crul)
library(data.table)
Airports data from https://openflights.org/data.html
airpts <- "https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat"
path <- "airports.csv"
invisible(crul::HttpClient$new(airpts)$get(disk = path))
airptsdf <- data.table::fread(path, data.table = FALSE)
names(airptsdf) <- c("id", "name", "city", "country",
"iata", "icao", "latitude", "longitude", "altitude", "timezone",
"dst", "tz_database_time_zone", "type", "source")
head(airptsdf)
id name city country
1 1 Goroka Airport Goroka Papua New Guinea
2 2 Madang Airport Madang Papua New Guinea
3 3 Mount Hagen Kagamuga Airport Mount Hagen Papua New Guinea
4 4 Nadzab Airport Nadzab Papua New Guinea
5 5 Port Moresby Jacksons International Airport Port Moresby Papua New Guinea
6 6 Wewak International Airport Wewak Papua New Guinea
iata icao latitude longitude altitude timezone dst tz_database_time_zone
1 GKA AYGA -6.081690 145.392 5282 10 U Pacific/Port_Moresby
2 MAG AYMD -5.207080 145.789 20 10 U Pacific/Port_Moresby
3 HGU AYMH -5.826790 144.296 5388 10 U Pacific/Port_Moresby
4 LAE AYNZ -6.569803 146.726 239 10 U Pacific/Port_Moresby
5 POM AYPY -9.443380 147.220 146 10 U Pacific/Port_Moresby
6 WWK AYWK -3.583830 143.669 19 10 U Pacific/Port_Moresby
type source
1 airport OurAirports
2 airport OurAirports
3 airport OurAirports
4 airport OurAirports
5 airport OurAirports
6 airport OurAirports
limit to those in the US
airptsdf <- subset(airptsdf, country == "United States")
head(airptsdf)
id name city country iata icao
3201 3411 Barter Island LRRS Airport Barter Island United States BTI PABA
3202 3413 Cape Lisburne LRRS Airport Cape Lisburne United States LUR PALU
3203 3414 Point Lay LRRS Airport Point Lay United States PIZ PPIZ
3204 3415 Hilo International Airport Hilo United States ITO PHTO
3205 3416 Orlando Executive Airport Orlando United States ORL KORL
3206 3417 Bettles Airport Bettles United States BTT PABT
latitude longitude altitude timezone dst tz_database_time_zone type
3201 70.1340 -143.5820 2 -9 A America/Anchorage airport
3202 68.8751 -166.1100 16 -9 A America/Anchorage airport
3203 69.7329 -163.0050 22 -9 A America/Anchorage airport
3204 19.7214 -155.0480 38 -10 N Pacific/Honolulu airport
3205 28.5455 -81.3329 113 -5 A America/New_York airport
3206 66.9139 -151.5290 647 -9 A America/Anchorage airport
source
3201 OurAirports
3202 OurAirports
3203 OurAirports
3204 OurAirports
3205 OurAirports
3206 OurAirports
Search for each airport with rnoaa - using ghcnd data via meteo_*
functions
ghcnd_stats <- ghcnd_stations()
# Get all stations within 2 kilometers
meteo_nearby_stations(lat_lon_df = airptsdf[1:5, ],
station_data = ghcnd_stats, radius = 2)
$`3411`
# A tibble: 1 x 5
id name latitude longitude distance
<chr> <chr> <dbl> <dbl> <dbl>
1 USW00027401 BARTER ISLAND WSO AP 70.1 -144 1.94
$`3413`
# A tibble: 2 x 5
id name latitude longitude distance
<chr> <chr> <dbl> <dbl> <dbl>
1 USC00501312 CAPE LISBURNE 68.9 -166 0.972
2 USW00026631 CAPE LISBURNE AFS 68.9 -166 1.32
$`3414`
# A tibble: 0 x 5
# ... with 5 variables: id <chr>, name <chr>, latitude <dbl>, longitude <dbl>,
# distance <dbl>
$`3415`
# A tibble: 2 x 5
id name latitude longitude distance
<chr> <chr> <dbl> <dbl> <dbl>
1 USW00021503 HILO NAS 19.7 -155 0.563
2 USW00021504 HILO INTL AP 19.7 -155 0.587
$`3416`
# A tibble: 3 x 5
id name latitude longitude distance
<chr> <chr> <dbl> <dbl> <dbl>
1 USW00012841 ORLANDO EXECUTIVE AP 28.5 -81.3 0.0295
2 USW00012824 ORLANDO AAF 28.6 -81.3 0.502
3 USC00086633 ORLANDO WTP 28.6 -81.4 1.74