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

GDAL driver error after installing stars in R #724

Closed
jofeggg opened this issue Nov 13, 2024 · 2 comments
Closed

GDAL driver error after installing stars in R #724

jofeggg opened this issue Nov 13, 2024 · 2 comments

Comments

@jofeggg
Copy link

jofeggg commented Nov 13, 2024

When I run perform_PCA funtion of the biodivMapR package, I got this error after installing stars package (latest version)

Error: lexical error: invalid char in json text.
Driver: ENVI/ENVI .hdr Labelled
(right here) ------^

Here is a link to the function code:

https://github.com/jbferet/biodivMapR/blob/master/R/Lib_PerformPCA.R

With stars 0.6-6 it worked perfectly

@jbferet
Copy link

jbferet commented Dec 15, 2024

dear @jofeggg and @edzer
The error is raised by the sf package v1.0-19 which seems to have lost compatibility with functions in gdalUtilities. The error does not occur when using sf v1.0-18 and stars v0.6-7.
an example code is provided here below to reproduce the error. The data are Sentinel-2 raster subsets downloaded from my repository and used as illustration for the package biodivMapR.
in this example, gdalUtilities::gdalinfo works with sf v1.0-18 (and stars v0.6-7), but the error reported by @jofeggg occurs with sf v1.0-19.

I will open an issue for sf.

library(magrittr)
# url for the S2 raster subset
url <- 'https://gitlab.com/jbferet/myshareddata/-/raw/master/biodivMapR_S2_Sample/RASTER/S2A_T33NUD_20180104_Subset'
destfile <- file.path(tempdir(),'S2A_T33NUD_20180104_Subset')
download.file(url = url, destfile = destfile, method = 'auto', quiet = FALSE, mode = "wb")
# url for the subset header
urlhdr <-  'https://gitlab.com/jbferet/myshareddata/-/raw/master/biodivMapR_S2_Sample/RASTER/S2A_T33NUD_20180104_Subset.hdr'
destfile_HDR <- paste0(destfile,'.hdr')
download.file(url = urlhdr, destfile = destfile_HDR, method = 'auto', quiet = FALSE, mode = "w")

gdalUtilities::gdalinfo(datasetname = destfile, json = TRUE, quiet = T) %>%
  jsonlite::fromJSON()

@edzer
Copy link
Member

edzer commented Dec 15, 2024

apparently an issue in gdalUtilities.

@edzer edzer closed this as completed Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants