Skip to content

lazysf

0.4.0Package record

Delayed Read for 'GDAL' Vector Data Sources

0packages depend
3.4Kdownloads / year
65.5%test coverage
13/13flavors OK

Overview

About

Lazy read for drawings. A 'dplyr' back end for data sources supported by 'GDAL' vector drivers, that allows working with local or remote sources as if they are in-memory data frames. Basic features work with any drawing format ('GDAL vector data source') supported by the 'gdalraster' package.

Changes in 0.4.0

Breaking changes

  • The backend now uses gdalraster for all GDAL access. Geometry columns in collected results are wk-typed (wk::wkb, wk::wkt, wk::rct).
  • st_as_sf() is no longer registered for tbl_GDALVectorConnection. Use collect() first, then sf::st_as_sf() on the resulting tibble.
  • DBI class names renamed: SFSQLConnection → GDALVectorConnection, SFSQLDriver → GDALVectorDriver, SFSQLResult → GDALVectorResult. The driver constructor is now GDALSQL() (was SFSQL()).
  • The magrittr pipe (%>%) is no longer re-exported. Use R's native pipe (|>).

Compatibility

  • Full compatibility with dbplyr >= 2.6.0. The new dbplyr dialect system (sql_dialect()) caused several silent regressions with the previous development code:
Show all changes in 0.4.0Hide the rest of the changes in 0.4.0
  • sql_translation(), sql_escape_logical(), and sql_query_fields() now dispatch on a custom dialect class (sql_dialect_gdal_vector / sql_dialect_gdal_sqlite) rather than the connection class, matching how dbplyr 2.6.0 dispatches these generics.
  • Identifier quoting now uses double quotes (ANSI SQL) rather than backticks. GDAL's embedded SQLite engine rejects backtick-quoted identifiers generated by dbplyr 2.6.0's default SQLite dialect.
  • supports_window_clause() was removed from dbplyr 2.6.0; it is now conditionally registered only when the generic exists.
  • Spatial SQL translations (SpatiaLite functions) are gated on dialect: SQLITE connections get full spatial translations, OGRSQL connections get base translations only.

New features

  • New geom_format argument to dbConnect() controls geometry output: "WKB" (default), "WKT", "NONE", or "BBOX". Configurable globally via options(lazysf.geom_format = ...).
  • New dialect argument to dbConnect() controls SQL dialect: "SQLITE" (the default), "OGRSQL", "INDIRECT_SQLITE", or "" (let GDAL choose). SQLITE is the default because it supports subqueries (required for dbplyr verb chaining) and spatial SQL functions like ST_Area(). Configurable globally via options(lazysf.dialect = ...).
  • lazysf() now passes ... through to dbConnect(), so geom_format and dialect can be set directly: lazysf(dsn, geom_format = "WKT").
  • Added db_connection_describe() method for informative printing: GDAL <SQLITE> WKB [/path/to/file.gpkg].
  • New sql_query_fields() method generates LIMIT 0 SQL for field discovery (replacing dbplyr's default WHERE (0 = 1) which OGRSQL can't handle). For named tables, dbSendQuery() intercepts this and uses $getLayerDefn() for pure OGR metadata access — no SQL execution at all. Subqueries are correctly wrapped in parentheses with an alias.
  • New .schema_from_defn() builds typed empty data frames from OGR layer definitions, mapping OGR field types to R types (OFTInteger → integer, OFTReal → double, OFTDateTime → POSIXct, OFSTBoolean → logical, etc.). Schema column names and types match what fetch() returns.
  • New dbListFields() method uses $getLayerDefn() for schema introspection without executing SQL.
  • Geometry columns are now automatically marked with wk types on materialization: wk::wkb() for WKB, wk::wkt() for WKT, and wk::rct() for BBOX. CRS from the layer's spatial reference is attached to all geometry vectors.
  • New sql_translation() method provides SpatiaLite function translations for the SQLITE dialect. R functions like st_area(), st_intersects(), st_buffer(), st_transform() etc. translate to their SpatiaLite SQL equivalents, enabling idiomatic dplyr pipelines with spatial operations: lazysf("countries.gpkg") |> filter(st_area(geom) > 1e6). OGRSQL dialect falls back to base SQLite translations only.
  • Added sql_escape_logical() method: TRUE/FALSE map to 1/0 for SQLite, NA maps to NULL.
  • Added supports_window_clause() method (returns TRUE for SQLITE dialect).
  • Future-proofed for upcoming dbplyr sql_dialect() generic. When the next version of dbplyr ships with the new dialect system, lazysf will automatically provide SQLite translation without any code changes.
  • New use_arrow argument to dbConnect() and lazysf() enables GDAL's Arrow C stream interface for reading features. Columnar transfer via GDALVector$getArrowStream() and nanoarrow, typically much faster for larger datasets. Requires GDAL >= 3.6. Configurable globally via options(lazysf.use_arrow = ...).
  • Geometry columns are automatically marked with wk types on materialization. CRS is attached. This enables sf::st_as_sf() on the collected tibble via sf's wk support without any lazysf-specific method.

Bug fixes

  • Multiline SQL from dbplyr is now collapsed to a single line before passing to GDALVector. GDAL's constructor rejects SQL with newline characters, which dbplyr generates for rename(), transmute(), and any verb that enumerates columns explicitly.
  • Table-qualified column prefixes from GDAL (e.g. nc.AREA from SELECT "nc".*) are now stripped automatically so column names match what dbplyr expects.
  • OGRFeatureSet class is stripped from fetch results. The gdalraster print method for this class conflicts with wk-typed geometry columns.
  • FID column name is normalized to uppercase "FID" in both the fetch() and Arrow paths, matching GDAL's behavior (GeoPackage stores "fid" but fetch() returns "FID").
  • Geometry column from getLayerDefn() is excluded from the attribute field loop in .schema_from_defn() — getLayerDefn() includes geometry as a field but fetch() handles it separately via returnGeomAs.

Known issues

  • GDAL's GDALVector initialization emits "SpatiaLite is not available" warnings on systems without SpatiaLite linked. These are harmless C++ diagnostics that can't be suppressed from R. Tracked upstream in gdalraster.
  • No window functions: slice_min(), slice_max(), row_number() etc. are not supported by GDAL's SQLite engine. Use arrange() |> head() instead.
  • Spatial SQL function availability depends on GDAL build configuration. ST_Area() and ST_SRID() work without SpatiaLite (GDAL-native). ST_AsText(), ST_Intersects(), and most geometry operations require SpatiaLite.

Dependencies

  • gdalraster (>= 2.0.0) replaces sf in Imports.
  • wk added to Imports for geometry type marking.
  • sf removed from dependencies (was previously in Imports, then Suggests).
  • nanoarrow added to Suggests (for Arrow stream interface).
  • dbplyr (>= 2.0.0) now required (2nd edition backend API).
  • magrittr removed from dependencies.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 3.1 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK13 OK2026-06-09
  • ERROR12 OK, 1 ERROR2026-06-08
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 0.4.0
READMEYes · 449 wordsVignettesYes · 1 · dynamicNEWSYes · 100% structured · mentions 0.4.0Citation fileNoWebsiteYes · pkgdown
Help pages
9 (5 internal)includes a package overview page
Examples that run
100%4 run in a plain check
Exported functions with examples
67%
Documented parameters
67%
Return-value docs
33%
Help pages citing references
0%
Vignettes (1)

Downloads

3.4K
CRAN downloads in the past year
Rank #9,964 · ~9/day · ~282/mo
Daily download trend is not available in this view yet.
35630 days
1K90 days
3.4K1 year
Compare downloads with other packages →
Also on86 r2u5 autocran

Repository

30Stars
2Forks
3Open issues
0Open PRs
0Releases
88Commits
3Commit identities
spatial-gdal-sf-dbi
88 commits · Last activity 2026-07-12 · 0% stars, 30d
Responsiveness
How these are sampled
PRs merged (all time)
100%
Median days to close, 50 most recently updated closed issues
47
Median days to close, 50 most recently updated closed PRs
0

Stars over time

2024-10-04 · 222026-08-20 · 30
PracticesBeta

10 development-tooling and community-health practices detected across 6 families in the upstream repository

Checks run against github.com/hypertidy/lazysf on 2026-10-22.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Governance and community (1)
Code of conduct
Docs source (4)
README.Rmdpkgdown

GitHub Pages site last deployed 2026-07-12 · The repository has a site deploy workflow

pkgdown site last built 2026-07-12, before release 0.4.0 (2026-07-13)

Reproducibility and dev environment (1)
data-raw/
Show all practicesHide 2 practices
CRAN release process (1)
cran-comments.md
Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v4 (2026-10-20)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • GitHub Copilotfirst seen 2026-02-18
    Pull request: opened by its own account
    Commits: 5 by its own account
  • Claude Codefirst seen 2026-07-12
    Named in .Rbuildignore: .claude
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
11 external dependencies (excludes base and recommended)

Installing lazysf adds 32 packages (21 with compiled code, 28 MB of source tarballs). Heaviest: stringi 11 MB, gdalraster 3.2 MB, Rcpp 1.8 MB.

Depends (1)
R >= 4.1.0
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

People & History

People (1)
Author, Maintainer since 0.1.0 (2020)
Releases (4)

Pick two releases to compare their code metrics.

  • 0.4.0Latest
    record
    2026-07-13 · current release · diff ↗ ·
    removed 3 exports
    %>%, SFSQL, st_as_sf
    added 1 export
    GDALSQL
  • R
    R 4.6.0 released · 2026-04-24
  • 0.3.0
    record
    2026-02-17 · diff ↗
  • R
    R 4.5.0 released · 2025-04-11
  • 0.2.0
    record
    2025-04-03 · diff ↗
  • R
    R 4.4.0 released · 2024-04-24
  • R
    R 4.3.0 released · 2023-04-21
  • R
    R 4.2.0 released · 2022-04-22
  • R
    R 4.1.0 released · 2021-05-18
  • 0.1.0
    record
    2020-11-14
  • R
    R 4.0.0 released · 2020-04-24

Package metadata

First published
2020-11-14
Total releases
4 / 6 yrs
License
GPL-3 OSI
Minimum R
≥ 4.1.0
Download size
249 KB

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("lazysf")
Sumner, M. (2026). lazysf: Delayed Read for 'GDAL' Vector Data Sources (Version 0.4.0) [Computer software]. https://doi.org/10.32614/CRAN.package.lazysf

This package has no citation file, so citation() returns this entry built from DESCRIPTION.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for lazysf version 0.4.0 [Data set]. HJJB, LLC. Data release v2026-10-24. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy