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

error in get_nlcd #88

Closed
YoJimboDurant opened this issue Jul 23, 2022 · 6 comments
Closed

error in get_nlcd #88

YoJimboDurant opened this issue Jul 23, 2022 · 6 comments

Comments

@YoJimboDurant
Copy link

YoJimboDurant commented Jul 23, 2022

I am getting the following error with the test script for get_nlcd.

> NLCD <- get_nlcd( template = FedData::meve, label = "meve", year = 2016 ) Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'crop': [rast] cannot open file: /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2016_Land_Cover_L48.tif In addition: Warning message: /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2016_Land_Cover_L48.tif' does not exist in the file system, and is not recognized as a supported dataset name. (GDAL error 4)`

Canopy and Impervious layers seem to download OK. The file https://storage.googleapis.com/feddata-r/nlcd/2016_Land_Cover_L48.tif exists and can be downloaded.

@bocinsky
Copy link
Collaborator

It seems to be working for me. This is using the CRAN version of everything but FedData (see Session Info, below). Perhaps reinstall from Github and try again?

FedData::get_nlcd(template = FedData::meve, label = "meve", year = 2016)
#> class      : RasterLayer 
#> dimensions : 710, 635, 450850  (nrow, ncol, ncell)
#> resolution : 30, 30  (x, y)
#> extent     : -1100475, -1081425, 1639875, 1661175  (xmin, xmax, ymin, ymax)
#> crs        : +proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs 
#> source     : meve_NLCD_Land_Cover_2016.tif 
#> names      : meve_NLCD_Land_Cover_2016 
#> values     : 11, 95  (min, max)
#> attributes :
#>         ID      COUNT value NLCD.Land.Cover.Class Red Green Blue Opacity
#>  from:   0 7853863229     0          Unclassified   0     0    0       0
#>   to : 255          0   255                       255   255  255     255

Created on 2022-07-23 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23)
#>  os       macOS Big Sur ... 10.16
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Denver
#>  date     2022-07-23
#>  pandoc   2.18 @ /usr/local/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  class         7.3-20     2022-01-16 [1] CRAN (R 4.2.1)
#>  classInt      0.4-7      2022-06-10 [1] CRAN (R 4.2.0)
#>  cli           3.3.0      2022-04-25 [1] CRAN (R 4.2.0)
#>  codetools     0.2-18     2020-11-04 [1] CRAN (R 4.2.1)
#>  curl          4.3.2      2021-06-23 [1] CRAN (R 4.2.0)
#>  data.table    1.14.2     2021-09-27 [1] CRAN (R 4.2.0)
#>  DBI           1.1.3      2022-06-18 [1] CRAN (R 4.2.0)
#>  digest        0.6.29     2021-12-01 [1] CRAN (R 4.2.0)
#>  dplyr         1.0.9      2022-04-28 [1] CRAN (R 4.2.0)
#>  e1071         1.7-11     2022-06-07 [1] CRAN (R 4.2.0)
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.2.0)
#>  evaluate      0.15       2022-02-18 [1] CRAN (R 4.2.0)
#>  fansi         1.0.3      2022-03-24 [1] CRAN (R 4.2.0)
#>  fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.2.0)
#>  FedData       3.0.0.9000 2022-07-23 [1] CRAN (R 4.2.1)
#>  fs            1.5.2      2021-12-08 [1] CRAN (R 4.2.0)
#>  generics      0.1.3      2022-07-05 [1] CRAN (R 4.2.0)
#>  glue          1.6.2      2022-02-24 [1] CRAN (R 4.2.0)
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.2.0)
#>  hms           1.1.1      2021-09-26 [1] CRAN (R 4.2.0)
#>  htmltools     0.5.3      2022-07-18 [1] CRAN (R 4.2.0)
#>  httr          1.4.3      2022-05-04 [1] CRAN (R 4.2.0)
#>  KernSmooth    2.23-20    2021-05-03 [1] CRAN (R 4.2.1)
#>  knitr         1.39       2022-04-26 [1] CRAN (R 4.2.0)
#>  lattice       0.20-45    2021-09-22 [1] CRAN (R 4.2.1)
#>  lifecycle     1.0.1      2021-09-24 [1] CRAN (R 4.2.0)
#>  magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.2.0)
#>  pillar        1.8.0      2022-07-18 [1] CRAN (R 4.2.0)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.2.0)
#>  proxy         0.4-27     2022-06-09 [1] CRAN (R 4.2.0)
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.2.0)
#>  R.cache       0.16.0     2022-07-21 [1] CRAN (R 4.2.1)
#>  R.methodsS3   1.8.2      2022-06-13 [1] CRAN (R 4.2.0)
#>  R.oo          1.25.0     2022-06-12 [1] CRAN (R 4.2.0)
#>  R.utils       2.12.0     2022-06-28 [1] CRAN (R 4.2.0)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.2.0)
#>  raster        3.5-21     2022-06-27 [1] CRAN (R 4.2.0)
#>  Rcpp          1.0.9      2022-07-08 [1] CRAN (R 4.2.0)
#>  readr         2.1.2      2022-01-30 [1] CRAN (R 4.2.0)
#>  reprex        2.0.1      2021-08-05 [1] CRAN (R 4.2.0)
#>  rgdal         1.5-30     2022-04-08 [1] CRAN (R 4.2.0)
#>  rlang         1.0.4      2022-07-12 [1] CRAN (R 4.2.0)
#>  rmarkdown     2.14       2022-04-25 [1] CRAN (R 4.2.0)
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.2.0)
#>  sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.2.0)
#>  sf            1.0-7      2022-03-07 [1] CRAN (R 4.2.0)
#>  sp            1.5-0      2022-06-05 [1] CRAN (R 4.2.0)
#>  stringi       1.7.8      2022-07-11 [1] CRAN (R 4.2.0)
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.2.0)
#>  styler        1.7.0      2022-03-13 [1] CRAN (R 4.2.0)
#>  terra         1.5-21     2022-02-17 [1] CRAN (R 4.2.0)
#>  tibble        3.1.7      2022-05-03 [1] CRAN (R 4.2.0)
#>  tidyselect    1.1.2      2022-02-21 [1] CRAN (R 4.2.0)
#>  tzdb          0.3.0      2022-03-28 [1] CRAN (R 4.2.0)
#>  units         0.8-0      2022-02-05 [1] CRAN (R 4.2.0)
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.2.0)
#>  vctrs         0.4.1      2022-04-13 [1] CRAN (R 4.2.0)
#>  withr         2.5.0      2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun          0.31       2022-05-10 [1] CRAN (R 4.2.0)
#>  yaml          2.3.5      2022-02-21 [1] CRAN (R 4.2.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.2/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@bocinsky
Copy link
Collaborator

Hi @YoJimboDurant. Any updates on this on your end?

@bocinsky
Copy link
Collaborator

Seems to be similar to ropensci/chirps#41, though I haven't successfully reproduced the issue. If anyone can send a reprex with session info, I'd appreciate it!

Something like:

# install.packages("reprex")
reprex::reprex(
  FedData::get_nlcd(
    template = FedData::meve,
    label = "meve",
    year = 2011
  ),
  session_info = TRUE
)

@bocinsky
Copy link
Collaborator

Someone helpfully just sent:

FedData::get_nlcd(template = FedData::meve, label = "meve", year = 2011)
#> Warning: /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/
#> 2011_Land_Cover_L48.tif: No such file or directory (GDAL error 4)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'crop': [rast] file does not exist: /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2011_Land_Cover_L48.tif

Created on 2022-08-10 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23)
#>  os       CentOS Linux 7 (Core)
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       US/Pacific
#>  date     2022-08-10
#>  pandoc   2.18 @ /usr/lib/rstudio-server/bin/pandoc/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.2.1)
#>  class         7.3-20     2022-01-16 [2] CRAN (R 4.2.1)
#>  classInt      0.4-7      2022-06-10 [1] CRAN (R 4.2.1)
#>  cli           3.3.0      2022-04-25 [1] CRAN (R 4.2.1)
#>  codetools     0.2-18     2020-11-04 [2] CRAN (R 4.2.1)
#>  curl          4.3.2      2021-06-23 [1] CRAN (R 4.2.1)
#>  data.table    1.14.2     2021-09-27 [1] CRAN (R 4.2.1)
#>  DBI           1.1.3      2022-06-18 [1] CRAN (R 4.2.1)
#>  digest        0.6.29     2021-12-01 [1] CRAN (R 4.2.1)
#>  dplyr         1.0.9      2022-04-28 [1] CRAN (R 4.2.1)
#>  e1071         1.7-11     2022-06-07 [1] CRAN (R 4.2.1)
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.2.1)
#>  evaluate      0.15       2022-02-18 [1] CRAN (R 4.2.1)
#>  fansi         1.0.3      2022-03-24 [1] CRAN (R 4.2.1)
#>  fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.2.1)
#>  FedData       3.0.0.9000 2022-08-10 [1] Github (ropensci/FedData@57effd4)
#>  fs            1.5.2      2021-12-08 [1] CRAN (R 4.2.1)
#>  generics      0.1.3      2022-07-05 [1] CRAN (R 4.2.1)
#>  glue          1.6.2      2022-02-24 [1] CRAN (R 4.2.1)
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.2.1)
#>  hms           1.1.1      2021-09-26 [1] CRAN (R 4.2.1)
#>  htmltools     0.5.3      2022-07-18 [1] CRAN (R 4.2.1)
#>  httr          1.4.3      2022-05-04 [1] CRAN (R 4.2.1)
#>  KernSmooth    2.23-20    2021-05-03 [2] CRAN (R 4.2.1)
#>  knitr         1.39       2022-04-26 [1] CRAN (R 4.2.1)
#>  lattice       0.20-45    2021-09-22 [2] CRAN (R 4.2.1)
#>  lifecycle     1.0.1      2021-09-24 [1] CRAN (R 4.2.1)
#>  magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.2.1)
#>  pillar        1.8.0      2022-07-18 [1] CRAN (R 4.2.1)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.2.1)
#>  proxy         0.4-27     2022-06-09 [1] CRAN (R 4.2.1)
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.2.1)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.2.1)
#>  Rcpp          1.0.9      2022-07-08 [1] CRAN (R 4.2.1)
#>  readr         2.1.2      2022-01-30 [1] CRAN (R 4.2.1)
#>  reprex        2.0.1      2021-08-05 [1] CRAN (R 4.2.1)
#>  rlang         1.0.4      2022-07-12 [1] CRAN (R 4.2.1)
#>  rmarkdown     2.14       2022-04-25 [1] CRAN (R 4.2.1)
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.2.1)
#>  sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.2.1)
#>  sf            1.0-8      2022-07-14 [1] CRAN (R 4.2.1)
#>  sp            1.5-0      2022-06-05 [1] CRAN (R 4.2.1)
#>  stringi       1.7.8      2022-07-11 [1] CRAN (R 4.2.1)
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.2.1)
#>  terra         1.6-7      2022-08-07 [1] CRAN (R 4.2.1)
#>  tibble        3.1.8      2022-07-22 [1] CRAN (R 4.2.1)
#>  tidyselect    1.1.2      2022-02-21 [1] CRAN (R 4.2.1)
#>  tzdb          0.3.0      2022-03-28 [1] CRAN (R 4.2.1)
#>  units         0.8-0      2022-02-05 [1] CRAN (R 4.2.1)
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.2.1)
#>  vctrs         0.4.1      2022-04-13 [1] CRAN (R 4.2.1)
#>  withr         2.5.0      2022-03-03 [1] CRAN (R 4.2.1)
#>  xfun          0.32       2022-08-10 [1] CRAN (R 4.2.1)
#>  yaml          2.3.5      2022-02-21 [1] CRAN (R 4.2.1)
#> 
#>  [1] /groups/porter/ym/R/x86_64-pc-linux-gnu-library/4.2
#>  [2] /opt/R/4.2.1/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Differences from my config is that this is on CentOS, but that's about it. I'm asking the person to send the results of terra::gdal() which will tell us to which version of GDAL the terra package is bound.

@bocinsky
Copy link
Collaborator

bocinsky commented Aug 10, 2022

It looks like they are running GDAL 2.3.2, which might be the issue. I'm trying to mimic their system in docker to replicate the problem. This does indeed seem to be a GDAL issue.

With GDAL 2.4.2 (on Ubuntu 20.04):

# gdalinfo /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2011_Land_Cover_L48.tif
ERROR 4: /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2011_Land_Cover_L48.tif: No such file or directory
gdalinfo failed - unable to open '/vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2011_Land_Cover_L48.tif'.

With GDAL 3.0.4 (on the same image):

# gdalinfo /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2011_Land_Cover_L48.tif
Driver: GTiff/GeoTIFF
Files: /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2011_Land_Cover_L48.tif
       /vsicurl/https://storage.googleapis.com/feddata-r/nlcd/2011_Land_Cover_L48.tif.aux.xml
Size is 161190, 104424
[...]

@bocinsky
Copy link
Collaborator

Now requiring GDAL (>= 3.0.0), which fixes the issue.

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