Finding the Closest INMET Station for Each Municipality
Source:vignettes/nearest_station.Rmd
nearest_station.RmdIntroduction
Many climate analyses require assigning each municipality to its
closest meteorological station. The nearest_stations()
function automates this process by identifying the nearest INMET station
for every municipality.
Preparing the data
The package includes datasets with Brazilian municipalities and INMET weather stations.
Finding the nearest station
Use nearest_stations() to identify the closest station
for each municipality.
mun_stations_pe <- nearest_stations(
municipality = municipality_pe,
inmet_stations = inmet_stations_pe,
n = 1
)
head(mun_stations_pe)
#> # A tibble: 6 × 5
#> state_muni code_ibge7 code_wmo distance station_order
#> <chr> <dbl> <chr> <dbl> <int>
#> 1 PE 2600054 A301 25.7 1
#> 2 PE 2600104 A350 79.5 1
#> 3 PE 2600203 A307 104. 1
#> 4 PE 2600302 A341 25.2 1
#> 5 PE 2600401 A357 9.32 1
#> 6 PE 2600500 A322 66.1 1