Skip to content

Error: [vrt] options error: Zero positional arguments expected (GDAL error 1) #1848

@Rapsodia86

Description

@Rapsodia86

Hi @rhijmans,
I am encountering an error in VRT creation when I have the option "-te" provided.
The function runs across a list of filenames. Every time, I run it, on a random file I get:
Error: [vrt] options error
In addition: Warning message:
Zero positional arguments expected (GDAL error 1)

When there is no "-te", there is no problem.
However, when I run this filename/filenames outside the loop, it creates the vrt without an issue. The "-te" arguments are fixed and taken from the maximum extent across all files.

> xmin_all
[1] 486480
> xmax_all
[1] 533800
> ymin_all
[1] 4381630
> ymax_all
[1] 4417540 

[1] "N:/MYDIR/ECO_L2T_LSTE.002_LST_QCmasked_doy2021348214507_aid0001_13N.tif"
[2] "N:/MYDIR/ECO_L2T_LSTE.002_LST_QCmasked_doy2021348214559_aid0001_13N.tif"
Error: [vrt] options error
In addition: Warning message:
Zero positional arguments expected (GDAL error 1) 

But then when I just run it again, it is all fine:

print(files)
[1] "N:/MYDIR/ECO_L2T_LSTE.002_LST_QCmasked_doy2021348214507_aid0001_13N.tif"
[2] "N:/MYDIR/ECO_L2T_LSTE.002_LST_QCmasked_doy2021348214559_aid0001_13N.tif"
vrt_file <- terra::vrt(files,set_names = TRUE,options = c("-te", xmin_all, ymin_all, xmax_all,ymax_all, "-separate"))
> vrt_file
class       : SpatRaster 
size        : 513, 676, 2  (nrow, ncol, nlyr)
resolution  : 70, 70  (x, y)
extent      : 486480, 533800, 4381630, 4417540  (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / UTM zone 13N (EPSG:32613) 
source      : spat_3d186beb2a2c_15640_LuCqFxcmTzL4pna.vrt 
names       : spat_3d186beb2a~CqFxcmTzL4pna_1, spat_3d186beb2a~CqFxcmTzL4pna_2 

> sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] lubridate_1.9.3 stringr_1.5.1   dplyr_1.1.4     terra_1.8-56   

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        R6_2.6.1          codetools_0.2-20  tidyselect_1.2.1  magrittr_2.0.3   
 [6] glue_1.8.0        tibble_3.2.1      pkgconfig_2.0.3   timechange_0.3.0  generics_0.1.3   
[11] lifecycle_1.0.4   cli_3.6.4         fansi_1.0.6       vctrs_0.6.5       compiler_4.4.0   
[16] rstudioapi_0.16.0 tools_4.4.0       pillar_1.9.0      Rcpp_1.0.14       rlang_1.1.5      
[21] stringi_1.8.3    

I tried to save vrt into file, lappy etc. But it is the "-te" argument that randomly errors. Any idea what the reason would be?
Sorry for not providing a lot of details, but it happens on a random file every time I run it, so I would not know which file to share. Especially, while doing it file by file, there is no issue!

gdal()
[1] "3.10.2"

UPDATE:
running terra::vrt(files,set_names = TRUE, options = c("-te", xmin_all, ymin_all, xmax_all,ymax_all)) without "-separate", in the loop also works!
Also, in one run it just failed, then in the next run it worked. I tried with saving to the file, same thing.😕

>     vrt_file <- terra::vrt(files,set_names = TRUE,options = c("-separate","-te", xmin_all, ymin_all, xmax_all,ymax_all))
Error: [vrt] options error
In addition: Warning message:
Zero positional arguments expected (GDAL error 1) 
>     vrt_file <- terra::vrt(files,set_names = TRUE,options = c("-separate","-te", xmin_all, ymin_all, xmax_all,ymax_all))
> vrt_file
class       : SpatRaster 
size        : 513, 676, 1  (nrow, ncol, nlyr)
resolution  : 70, 70  (x, y)
extent      : 486480, 533800, 4381630, 4417540  (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / UTM zone 13N (EPSG:32613) 
source      : spat_3d185db043f5_15640_jKeBpaOmkLpIJuY.vrt 
name        : ECO_L2T_LSTE.002_LST_QCmasked_doy2021335204059_aid0001_13N 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions