Skip to contents

Downloads the consolidated INFOSIGA-SP data archive (dados_infosiga.zip) from DETRAN-SP into the local cache. Most users do not need to call this directly: read_infosiga() downloads the archive on demand. Use this function when you want to pre-fetch the data (for example, before going offline) or to force a refresh.

Usage

infosiga_download(overwrite = FALSE, quiet = FALSE, timeout = 3600)

Arguments

overwrite

Logical. If FALSE (default) and the archive is already cached, the existing file is kept and returned. Set to TRUE to download again and replace it.

quiet

Logical. If FALSE (default), report progress with informative messages.

timeout

Download timeout in seconds. The archive is large (around 120 MB), so the default temporarily raises options()$timeout to 3600. Pass a larger value on slow connections.

Value

The path to the cached archive, invisibly.

Details

The archive is updated monthly by DETRAN-SP and accumulates all records from 2015 onward. The download URL can be overridden with the infosigasp.zip_url option, which may be a character vector of mirror URLs tried in order until one succeeds. The default is the official DETRAN-SP endpoint followed by a GitHub-release mirror that serves a point-in-time snapshot when the official portal is unavailable. Override the option to add your own mirror or for testing.

Because DETRAN-SP overwrites the archive in place each month under the same file name, a cached copy can become stale silently. When a cached archive is reused that is older than the infosigasp.stale_days option (30 days by default; set to Inf to disable), a warning suggests refreshing it. The age is taken from the cached file's modification time.

See also

read_infosiga() to import the data, and infosiga_cache_dir() to locate the cache.

Examples

if (FALSE) { # \dontrun{
# Pre-fetch the archive into the cache
infosiga_download()

# Force a refresh after a monthly update
infosiga_download(overwrite = TRUE)
} # }