Package 'vsils'

Title: Scan 'CRAN' Packages for 'GDAL'-Readable Files
Description: Queries a package source tarball directly from CRAN (via 'GDAL' virtual file system) and identifies files that 'GDAL' can read. No package or file download is required.
Authors: Michael Sumner [aut, cre] (ORCID: <https://orcid.org/0000-0002-2471-7511>)
Maintainer: Michael Sumner <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-05-11 06:49:37 UTC
Source: https://github.com/hypertidy/vsils

Help Index


Refresh a cached CRAN packages DB.

Description

The vsils function cran_package_db() is memoized, meaning that its output is cached by the memoise package, with a timeout every hour. Manually bust this cache by running cran_db_refresh().

Usage

cran_db_refresh()

Value

logical TRUE, or FALSE if no such cache existed

Examples

## Not run: 
cran_db_refresh()

## End(Not run)

Get CRAN package database.

Description

This is a memoized (cached) copy of tools::CRAN_package_db(), it refreshes once an hour.

Usage

cran_package_db()

Details

Force refresh with cran_db_refresh().

See Also

cran_db_refresh

Examples

cran_package_db()

Scan a CRAN package for GDAL-readable files

Description

Queries a package source tarball directly from CRAN (via ⁠/vsitar//vsicurl/⁠) and identifies files that GDAL can read. No download required.

Usage

scan_package(package)

Arguments

package

Character string, name of a package available on CRAN.

Details

The function reads the package tarball directly from CRAN using GDAL's virtual file system handlers (⁠/vsitar/⁠ and ⁠/vsicurl/⁠), so files can be identified without downloading the entire package.

The returned dsn values can be opened directly with GDAL-based tools (e.g. new(gdalraster::GDALVector, ), new(gdalraster::GDALRaster, ), terra::vect(), terra::rast(), sf::read_sf()).

Some false positives may occur (e.g. CSV files detected as spatial, PNG logos, orphan shapefile sidecars). The XYZ driver in particular may incorrectly match spatial weights files (.gal, .gwt).

Value

A tibble with columns:

  • package: the package name

  • driver: GDAL driver name (e.g. "GTiff", "GPKG", "netCDF")

  • dsn: full GDAL-readable URI to the file

Returns NULL if no GDAL-readable files are found.

Examples

scan_package("gdalraster")


# Scan multiple packages
packages <- c("spData", "gdalraster", "sf", "terra", "stars", "vapour")
results <- purrr::map_dfr(packages, purrr::possibly(scan_package, NULL))

# reference a discovered file directly
gpkg <- dplyr::filter(results, package == "spData", driver == "GPKG") |> dplyr::slice(1L)
v <- new(gdalraster::GDALVector, gpkg$dsn)
v$info()
v$close()