| Type: | Package |
| Title: | Download and Read Brazilian Meteorological Data from INMET |
| Version: | 0.2.0 |
| Description: | Automates the download and processing of historical weather data from the Brazilian National Institute of Meteorology (INMET). It provides a cached catalogue of automatic stations, resumable and validated downloads, and parsers for formatting inconsistencies in raw CSV files across different years. It removes structural artifacts, standardizes column names, parses timestamps, and returns data frames ready for analysis. Data are retrieved from https://portal.inmet.gov.br/dadoshistoricos and https://apitempo.inmet.gov.br/estacoes/T. |
| Depends: | R (≥ 4.0.0) |
| Encoding: | UTF-8 |
| LazyData: | true |
| Language: | en-US |
| License: | GPL (≥ 3) |
| URL: | https://github.com/rodrigosqrt3/rmet |
| BugReports: | https://github.com/rodrigosqrt3/rmet/issues |
| RoxygenNote: | 7.3.3 |
| Imports: | curl, jsonlite |
| Suggests: | spelling, testthat (≥ 3.0.0), knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-19 19:02:39 UTC; rodri |
| Author: | Rodrigo Fonseca Villa
|
| Maintainer: | Rodrigo Fonseca Villa <rodrigo03.villa@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-21 10:20:03 UTC |
rmet: Access Historical Weather Data from INMET
Description
Tools to discover stations and download, cache, and parse historical hourly weather data from Brazil's National Institute of Meteorology (INMET).
Main functions
-
inmet_get()downloads and reads data in one call. -
inmet_download()downloads annual archives. -
inmet_read()parses cached archives. -
inmet_stations()searches the official station catalogue.
Author(s)
Maintainer: Rodrigo Fonseca Villa rodrigo03.villa@gmail.com (ORCID)
See Also
Useful links:
Clear the rmet cache
Description
Clear the rmet cache
Usage
inmet_cache_clear(
years = NULL,
dest_dir = tools::R_user_dir("rmet", "cache"),
ask = interactive(),
catalog = FALSE
)
Arguments
years |
Integer years to remove, or |
dest_dir |
Cache directory. |
ask |
Ask for confirmation before deleting. |
catalog |
Also remove the cached official station catalogue. |
Value
Invisible NULL.
Inspect downloaded INMET archives
Description
Inspect downloaded INMET archives
Usage
inmet_cache_status(dest_dir = tools::R_user_dir("rmet", "cache"))
Arguments
dest_dir |
Cache directory used by |
Value
Invisibly, a data frame with archive year, path, size, validity, and whether a partial download exists.
Download INMET historical data archives
Description
Downloads one or more annual ZIP files from INMET's historical data portal.
Complete archives already in the cache are reused. Interrupted downloads are
kept in a .part file and resumed on the next attempt.
Usage
inmet_download(
years = as.integer(format(Sys.Date(), "%Y")),
dest_dir = tools::R_user_dir("rmet", "cache"),
max_tries = 15L,
quiet = FALSE,
force = FALSE
)
Arguments
years |
Integer vector of years to download. Available years start in 2000. Defaults to the current year. |
dest_dir |
Character. Cache directory. It is created when necessary. |
max_tries |
Positive integer. Maximum attempts per year. |
quiet |
Logical. Suppress progress messages. |
force |
Logical. Download again even when a valid archive is cached. |
Details
Files are first written to <year>.zip.part. A partial file is never exposed
as a complete ZIP. After an integrity check succeeds, the file is atomically
moved to <year>.zip whenever the operating system permits it.
Value
Invisibly, a named character vector containing the paths of all successfully downloaded archives.
See Also
inmet_read(), inmet_get(), inmet_extract()
Examples
paths <- inmet_download(2023, dest_dir = tempdir())
Extract INMET archives
Description
Extract INMET archives
Usage
inmet_extract(
years,
dest_dir = tools::R_user_dir("rmet", "cache"),
out_dir = file.path(dest_dir, "csv"),
overwrite = FALSE,
quiet = FALSE
)
Arguments
years |
Integer years to extract. |
dest_dir |
Directory containing annual ZIP files. |
out_dir |
Destination directory. |
overwrite |
Overwrite existing files. |
quiet |
Suppress progress messages. |
Value
Invisibly, paths returned by utils::unzip().
Download and read INMET data in one call
Description
This is the recommended high-level interface. It downloads missing annual
archives, reuses valid cached files, and returns the result of inmet_read().
Usage
inmet_get(
years,
stations = NULL,
dest_dir = tools::R_user_dir("rmet", "cache"),
tz = "UTC",
variables = NULL,
start_date = NULL,
end_date = NULL,
max_tries = 15L,
force = FALSE,
quiet = FALSE
)
Arguments
years |
Integer vector of years. |
stations |
Optional station codes. Matching is case-insensitive. |
dest_dir |
Directory containing |
tz |
Output time zone. Defaults to |
variables |
Optional meteorological columns to retain. |
start_date, end_date |
Optional inclusive date limits in |
max_tries |
Maximum download attempts per year. |
force |
Download archives again even if they are valid. |
quiet |
Suppress progress messages. |
Value
A data frame as documented in inmet_read().
Examples
weather <- inmet_get(
years = 2023,
stations = "A801",
variables = c("temp_dry_c", "precip_mm"),
dest_dir = tempdir()
)
Read cached INMET historical data
Description
Parses CSV files inside annual INMET archives into a consistent data frame.
Usage
inmet_read(
years,
stations = NULL,
dest_dir = tools::R_user_dir("rmet", "cache"),
tz = "UTC",
variables = NULL,
start_date = NULL,
end_date = NULL,
quiet = FALSE
)
Arguments
years |
Integer vector of years. |
stations |
Optional station codes. Matching is case-insensitive. |
dest_dir |
Directory containing |
tz |
Output time zone. Defaults to |
variables |
Optional meteorological columns to retain. |
start_date, end_date |
Optional inclusive date limits in |
quiet |
Suppress progress messages. |
Value
A data frame. Identifier and station metadata columns are always retained when data are available.
See Also
inmet_get(), inmet_download(), inmet_stations()
Examples
df <- inmet_read(2023, stations = "A801", dest_dir = tempdir())
Search the INMET automatic-station catalogue
Description
Returns automatic weather stations published by INMET. By default, the function uses a cached copy of the official API response and refreshes stale caches periodically. If the service is unavailable, it falls back to an older cache or to the smaller catalogue bundled with the package.
Usage
inmet_stations(
region = NULL,
state = NULL,
search = NULL,
status = NULL,
entity = NULL,
source = c("auto", "remote", "bundled"),
refresh = FALSE,
max_age = 30,
cache_dir = tools::R_user_dir("rmet", "cache"),
quiet = FALSE
)
Arguments
region, state |
Optional region or state abbreviations. |
search |
Optional literal text contained in the station name or code. |
status |
Optional operational status, such as |
entity |
Optional station owner/provider, such as |
source |
One of |
refresh |
Force a fresh request to the official API. |
max_age |
Maximum cache age in days before an automatic refresh. |
cache_dir |
Directory used for the catalogue cache. |
quiet |
Suppress informational messages. |
Value
A data frame with station code, name, region, state, coordinates,
altitude, operational dates and status, and provider metadata. The legacy
start_year column is retained for compatibility.
See Also
Examples
# Offline, reproducible example using the bundled fallback
inmet_stations(state = "RS", source = "bundled")
# Current official catalogue (downloaded once and then cached)
inmet_stations(state = "RS", refresh = TRUE, cache_dir = tempdir())
Hourly weather data from INMET station A801 (Porto Alegre), 2023
Description
A dataset containing one year of hourly meteorological observations from the automatic station A801 (Porto Alegre, RS), downloaded from INMET.
Usage
rmet_example
Format
A data frame with columns as returned by inmet_read().
See ?inmet_read for the full variable reference.
Source
INMET – Instituto Nacional de Meteorologia