Skip to content

Support st_read GDAL/Ogr2ogr options #2382

@latot

Description

@latot

Hi, I know it exists the options for st_read, but after testing it, seems is not to pass options as read options, or something seems to be not working.

I'm using the query param, which usually works, but some queries need to use in GDAL -dialect sqlite to works, I have played with options with... c("-dialect", "sqlite"), c("dialect", "sqlite"), c("-dialect"="sqlite"), c("dialect"="sqlite") and -dialect sqlite, but seems to now works.

Here a sample:

file_path <- "test.shp"

a <- sf::st_sf(
  id = c(1, 3, 3),
  geometry = sf::st_sfc(
    sf::st_point(),
    sf::st_point(),
    sf::st_point()
  )
)

sf::st_write(a, file_path, layer = "layer")

sf::st_read(
    file_path,
    query = 'SELECT 1 FROM (SELECT COUNT(*) count FROM "layer" GROUP BY "id") x WHERE count > 1',
    options = c("-dialect", "sqlite")
)

This query will fails without using the sqlite dialect.

Thx!

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions