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

vector: standard error messages when importing from GRASS GIS in R #47

Open
florisvdh opened this issue Jun 15, 2024 · 0 comments
Open

Comments

@florisvdh
Copy link

This usecase is for R where we are using package {terra}. It uses GDAL for reading & writing any supported data source format. With the GDAL-GRASS standalone driver installed this works fine for raster, but throws standard error messages when reading a vector layer.

The examples below use vector data sources in the GRASS GIS 'North Carolina basic dataset', downloaded from https://grass.osgeo.org/download/data/.

Example 1: point data
library(terra)
#> terra 1.7.78
result_1 <- vect(
  x = "/home/floris/grassdata/nc_basic_spm_grass7/PERMANENT/vector/schools/head",
  layer = "schools"
)
#> Warning: Cannot reset cursor. (GDAL error 1)
#> Warning: Attributes not found. (GDAL error 1)
result_1
#>  class       : SpatVector 
#>  geometry    : points 
#>  dimensions  : 167, 29  (geometries, attributes)
#>  extent      : 619215.1, 671714.6, 203559, 248159.8  (xmin, xmax, ymin, ymax)
#>  source      : head (schools)
#>  coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +datum=NAD83 +units=m +no_defs 
#>  names       :   cat   TAG        NAMESHORT        NAMELONG CORECAPACI
#>  type        : <int> <chr>            <chr>           <chr>      <num>
#>  values      :     1   568      SWIFT CREEK SWIFT CREEK EL~        448
#>                    2   340       BRIARCLIFF BRIARCLIFF ELE~        540
#>                    3   414 FARMINGTON WOODS FARMINGTON WOO~        523
#>  MOBILEUNIT MOBILECAPA GLEVEL LOGRADE HIGRADE (and 19 more)
#>       <num>      <num>  <chr>   <chr>   <chr>              
#>           2        NaN      E      NA      NA              
#>           0        NaN      E      NA      NA              
#>           7        NaN      E      NA      NA

Created on 2024-06-15 with reprex v2.1.0

Collected standard output and standard error

DBMI-SQLite driver error:
DB_PREVIOUS is not supported

DBMI-SQLite driver error:
DB_PREVIOUS is not supported

DB_PREVIOUS is defined in GRASS GIS in include/grass/dbmi.h.

Example 2: polygon data
library(terra)
#> terra 1.7.78
result_2 <- vect(
  x = "/home/floris/grassdata/nc_basic_spm_grass7/PERMANENT/vector/zipcodes/head",
  layer = "zipcodes"
)
#> Warning: Cannot reset cursor. (GDAL error 1)
#> Warning: Attributes not found. (GDAL error 1)
result_2
#>  class       : SpatVector 
#>  geometry    : polygons 
#>  dimensions  : 48, 12  (geometries, attributes)
#>  extent      : 610047.9, 677060.7, 196327.5, 258102.6  (xmin, xmax, ymin, ymax)
#>  source      : head (zipcodes)
#>  coord. ref. : +proj=lcc +lat_0=33.75 +lon_0=-79 +lat_1=36.1666666666667 +lat_2=34.3333333333333 +x_0=609601.22 +y_0=0 +datum=NAD83 +units=m +no_defs 
#>  names       :   cat OBJECTID WAKE_ZIPCO PERIMETER ZIPCODE_ ZIPCODE_ID
#>  type        : <int>    <int>      <num>     <num>    <num>      <num>
#>  values      :     1        1  2.625e+08 8.075e+04        2         27
#>                    2        2  3.163e+07 3.106e+04        7         25
#>                    3        3   5.44e+08 1.153e+05        8         20
#>      ZIPNAME    ZIPNUM           ZIPCODE        NAME SHAPE_Leng SHAPE_Area
#>        <chr>     <num>             <chr>       <chr>      <num>      <num>
#>    CREEDMOOR 2.752e+04   CREEDMOOR 27522   CREEDMOOR  8.078e+04  2.624e+08
#>  YOUNGSVILLE  2.76e+04 YOUNGSVILLE 27596 YOUNGSVILLE  3.106e+04  3.163e+07
#>      RALEIGH 2.762e+04     RALEIGH 27615     RALEIGH  1.153e+05   5.44e+08

Created on 2024-06-15 with reprex v2.1.0

Collected standard output and standard error

DBMI-SQLite driver error:
DB_PREVIOUS is not supported

DBMI-SQLite driver error:
DB_PREVIOUS is not supported

DB_PREVIOUS is defined in GRASS GIS in include/grass/dbmi.h.

R session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.0 (2024-04-24)
#>  os       Linux Mint 21.3
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language nl_BE:nl
#>  collate  nl_BE.UTF-8
#>  ctype    nl_BE.UTF-8
#>  tz       Europe/Brussels
#>  date     2024-06-15
#>  pandoc   3.1.11 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/x86_64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.2   2023-12-11 [3] RSPM (R 4.3.0)
#>  codetools     0.2-20  2024-03-31 [3] RSPM (R 4.3.0)
#>  digest        0.6.35  2024-03-11 [3] RSPM (R 4.3.0)
#>  evaluate      0.24.0  2024-06-10 [3] RSPM (R 4.4.0)
#>  fastmap       1.2.0   2024-05-15 [3] RSPM (R 4.4.0)
#>  fs            1.6.4   2024-04-25 [3] RSPM (R 4.3.0)
#>  glue          1.7.0   2024-01-09 [3] RSPM (R 4.3.0)
#>  htmltools     0.5.8.1 2024-04-04 [3] RSPM (R 4.3.0)
#>  knitr         1.47.2  2024-06-04 [1] Github (yihui/knitr@f50b75b)
#>  lifecycle     1.0.4   2023-11-07 [3] RSPM (R 4.3.0)
#>  magrittr      2.0.3   2022-03-30 [3] RSPM (R 4.2.0)
#>  purrr         1.0.2   2023-08-10 [3] RSPM (R 4.2.0)
#>  R.cache       0.16.0  2022-07-21 [3] RSPM (R 4.2.0)
#>  R.methodsS3   1.8.2   2022-06-13 [3] RSPM (R 4.2.0)
#>  R.oo          1.26.0  2024-01-24 [3] RSPM (R 4.3.0)
#>  R.utils       2.12.3  2023-11-18 [3] RSPM (R 4.3.0)
#>  Rcpp          1.0.12  2024-01-09 [3] RSPM (R 4.3.0)
#>  reprex        2.1.0   2024-01-11 [3] RSPM (R 4.3.0)
#>  rlang         1.1.4   2024-06-04 [3] RSPM (R 4.4.0)
#>  rmarkdown     2.27    2024-05-17 [3] RSPM (R 4.4.0)
#>  rstudioapi    0.16.0  2024-03-24 [3] RSPM (R 4.3.0)
#>  sessioninfo   1.2.2   2021-12-06 [3] RSPM (R 4.2.0)
#>  styler        1.10.3  2024-04-07 [3] RSPM (R 4.3.0)
#>  terra       * 1.7-78  2024-05-22 [1] RSPM (R 4.4.0)
#>  vctrs         0.6.5   2023-12-01 [3] RSPM (R 4.3.0)
#>  withr         3.0.0   2024-01-16 [3] RSPM (R 4.3.2)
#>  xfun          0.44    2024-05-15 [3] RSPM (R 4.4.0)
#>  yaml          2.3.8   2023-12-11 [3] RSPM (R 4.3.0)
#> 
#>  [1] /home/floris/lib/R/library
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/lib/R/site-library
#>  [4] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Motivation:

In R the GRASS GIS interface is provided by package {rgrass} (@rsbivand), which in turn uses the {terra} package (@rhijmans) for reading & writing with GDAL. In the {rgrass} package we intend to (re-)implement the GDAL-GRASS driver to access layers in order to avoid the extra r.out.gdal or v.out.ogr steps that cause extra writing & reading overhead. (rsbivand/rgrass#75)

System specs:

$ ogrinfo --version
GDAL 3.8.4, released 2024/02/08
$ 
$ apt policy libgdal-grass
libgdal-grass:
  Installed: 1:1.0.2-7+jammy3
  Candidate: 1:1.0.2-7+jammy3
  Version table:
 *** 1:1.0.2-7+jammy3 500
        500 http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu jammy/main amd64 Packages
        100 /var/lib/dpkg/status
     3.4.1-3 500
        500 http://ftp.belnet.be/ubuntu jammy/universe amd64 Packages
$ 
$ inxi -Sxxx
System:
  Host: xxx Kernel: 5.15.0-112-generic x86_64 bits: 64 compiler: gcc
    v: 11.4.0 Desktop: Cinnamon 6.0.4 tk: GTK 3.24.33 wm: muffin vt: 7
    dm: LightDM 1.30.0 Distro: Linux Mint 21.3 Virginia
    base: Ubuntu 22.04 jammy
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

1 participant