Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't execute query from gdal_utils + ogrinfo #2420

Open
latot opened this issue Aug 1, 2024 · 4 comments
Open

Can't execute query from gdal_utils + ogrinfo #2420

latot opened this issue Aug 1, 2024 · 4 comments

Comments

@latot
Copy link

latot commented Aug 1, 2024

Hi!, I'm trying to use ogrinfo to remove a table from a gpkg:

a <- sf::st_sf(geom = sf::st_sfc())
sf::st_write(a, "tmp.gpkg", layer = "hahah")

sf::gdal_utils(
  util = "ogrinfo",
  "tmp.gpkg",
  options = c(
    "-sql", "DROP TABLE IF EXISTS hahah",
    "-dialect", "sqlite"
  )
)

And I got the next error:

In CPL_ogrinfo(if (missing(source)) character(0) else source, options,  :
  GDAL Error 1: In ExecuteSQL(): sqlite3_step(DROP TABLE IF EXISTS hahah):
  attempt to write a readonly database

This command works fine from ogrinfo in the terminal.

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Gentoo Linux

Matrix products: default
BLAS:   /usr/lib64/libblas.so.3.12.0 
LAPACK: /usr/lib64/liblapack.so.3.12.0

locale:
 [1] LC_CTYPE=es_CL.utf8       LC_NUMERIC=C             
 [3] LC_TIME=es_CL.utf8        LC_COLLATE=es_CL.utf8    
 [5] LC_MONETARY=es_CL.utf8    LC_MESSAGES=es_CL.utf8   
 [7] LC_PAPER=es_CL.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=es_CL.utf8 LC_IDENTIFICATION=C      

time zone: Chile/Continental
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.4.1     magrittr_2.0.3     class_7.3-22       tools_4.4.1       
 [5] DBI_1.2.3          units_0.8-5        proxy_0.4-27       Rcpp_1.0.12       
 [9] KernSmooth_2.23-24 grid_4.4.1         e1071_1.7-14       classInt_0.4-10   
[13] sf_1.0-17 

Thx!

edzer added a commit that referenced this issue Aug 24, 2024
@edzer
Copy link
Member

edzer commented Aug 24, 2024

Pls reinstall from source, and try again.

@latot
Copy link
Author

latot commented Sep 23, 2024

@edzer sorry for the time, I was very busy, I reinstalled from source, restarted R, and I got the same result.

I upgraded the reprex above to also shows how to create the file.

@edzer
Copy link
Member

edzer commented Sep 23, 2024

I get

INFO: Open of `tmp.gpkg'
      using driver `GPKG' successful.
Warning message:
In CPL_ogrinfo(if (missing(source)) character(0) else source, options,  :
  GDAL Message 1: Table/view hahah is referenced in gpkg_contents, but does not exist

with

> sf_extSoftVersion()
          GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
      "3.12.1"        "3.8.4"        "9.4.0"         "true"         "true" 
          PROJ 
       "9.4.0" 

@latot
Copy link
Author

latot commented Sep 23, 2024

mm, I has this ones:

sf::sf_extSoftVersion()
          GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
      "3.12.1"        "3.9.1"        "9.2.1"         "true"         "true" 
          PROJ 
       "9.2.1"

We have GDAL and PROJ with different versions. Also I run this on /tmp folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants