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

get_nlcd() issue #114

Closed
n-a-gilbert opened this issue Jun 20, 2024 · 10 comments
Closed

get_nlcd() issue #114

n-a-gilbert opened this issue Jun 20, 2024 · 10 comments

Comments

@n-a-gilbert
Copy link

I'm trying to use the get_nlcd() function to download NLCD data for the lower 48. I'm using a SpatRaster as my template. I keep getting this error message:

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'as.factor': [rast] cannot open this file as a SpatRaster: C:\Users\12487\AppData\Local\Temp\RtmpOkzDko\file22306a166a7.tif In addition: Warning message: C:\Users\12487\AppData\Local\Temp\RtmpOkzDko\file22306a166a7.tif' not recognized as a supported file format. (GDAL error 4)

I tried downloading the development version of FedData but still received this error. Any ideas for what is going on here? My session info is below. Thanks!

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

Matrix products: default


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

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
[1] terra_1.7-78        dplyr_1.1.4         sf_1.0-16           rnaturalearth_1.0.1 ebirdst_3.2022.3    here_1.0.1         
[7] FedData_4.0.1      

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4             devtools_2.4.5                remotes_2.5.0                 processx_3.8.4               
 [5] lattice_0.22-6                callr_3.7.6                   tzdb_0.4.0                    vctrs_0.6.5                  
 [9] tools_4.4.0                   ps_1.7.6                      generics_0.1.3                curl_5.2.1                   
[13] tibble_3.2.1                  proxy_0.4-27                  fansi_1.0.6                   pkgconfig_2.0.3              
[17] KernSmooth_2.23-22            desc_1.4.3                    lifecycle_1.0.4               compiler_4.4.0               
[21] stringr_1.5.1                 codetools_0.2-20              httpuv_1.6.15                 htmltools_0.5.8.1            
[25] usethis_2.2.3                 class_7.3-22                  later_1.3.2                   pillar_1.9.0                 
[29] urlchecker_1.0.1              ellipsis_0.3.2                classInt_0.4-10               cachem_1.1.0                 
[33] sessioninfo_1.2.2             mime_0.12                     tidyselect_1.2.1              digest_0.6.35                
[37] stringi_1.8.4                 purrr_1.0.2                   rprojroot_2.0.4               fastmap_1.2.0                
[41] grid_4.4.0                    cli_3.6.2                     magrittr_2.0.3                pkgbuild_1.4.4               
[45] utf8_1.2.4                    e1071_1.7-14                  readr_2.1.5                   promises_1.3.0               
[49] sp_2.1-4                      httr_1.4.7                    rnaturalearthhires_1.0.0.9000 hms_1.1.3                    
[53] memoise_2.0.1                 shiny_1.8.1.1                 miniUI_0.1.1.1                profvis_0.3.8                
[57] rlang_1.1.3                   Rcpp_1.0.12                   xtable_1.8-4                  glue_1.7.0                   
[61] DBI_1.2.3                     xml2_1.3.6                    pkgload_1.3.4                 rstudioapi_0.16.0            
[65] jsonlite_1.8.8                R6_2.5.1                      fs_1.6.4                      units_0.8-5
@bocinsky
Copy link
Collaborator

bocinsky commented Jul 1, 2024 via email

@tungttnguyen
Copy link

I also ran into the same problem. It used to work around May 2024. The sources for 2021 dataset may have changed because running the package example did not work either. Can you please check @bocinsky? Thank you!

get_nlcd(
  template = FedData::meve,
  label = "meve",
  year = 2021
)

Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'as.factor': [rast] cannot open this file as a SpatRaster: C:\Users\user007\AppData\Local\Temp\RtmpO66bkW\filed2b45633e1c.tif
In addition: Warning message:
`C:\Users\user007\AppData\Local\Temp\RtmpO66bkW\filed2b45633e1c.tif' not recognized as a supported file format. (GDAL error 4)

@edixon1
Copy link

edixon1 commented Sep 20, 2024

I am also having this issue. As @tungttnguyen suggested, this is specific to the 2021 data set. Calls to 2019 version still work.

@mccrea-cobb
Copy link

mccrea-cobb commented Sep 24, 2024

I am having the same issue trying to get NLCD data for Alaska (2016).

get_refuge <- function(orgname){
  orgname <- toupper(orgname)
  message(paste("Downloading boundary layer for", orgname))
  url <- httr::parse_url("https://services.arcgis.com/QVENGdaPbd4LUkLV/arcgis/rest/services")
  url$path <- paste(url$path, "National_Wildlife_Refuge_System_Boundaries/FeatureServer/0/query", sep = "/")
  url$query <- list(where = paste("ORGNAME =", paste0("'",orgname,"'")),
                    outFields = "*",
                    returnGeometry = "true",
                    f = "pgeojson"
  )
  request <- httr::build_url(url)
  prop <- sf::st_read(request)
  message("Done.")
  return(prop)
}

tetlin <- get_refuge("Tetlin National Wildlife Refuge")

NLCD <- FedData::get_nlcd(template = tetlin,
                 landmass = "AK",
                 year = 2016,
                 label = "tetlin_nlcd")

@khurley-usgs
Copy link

@mccrea-cobb I think there may be issues with a dependency. What has worked for me is to install v4.0.0.

devtools::install_version(
  "FedData", 
  version = "4.0.0", 
  repos = "http://cran.us.r-project.org"
)
library(FedData)

@mccrea-cobb
Copy link

@khurley-usgs I've been using FedData 4.0.0. I'm getting the same error message as @tungttnguyen. I'm able to get data for the lower 48.

@tungttnguyen
Copy link

@khurley-usgs I've been using FedData 4.0.0. I'm getting the same error message as @tungttnguyen. I'm able to get data for the lower 48.

So you were able to get the 2021 data for the lower 48 using FedData 4.0.0? Thanks!

@khurley-usgs
Copy link

khurley-usgs commented Oct 30, 2024

@tungttnguyen I have been using v4.0.0 with success to download 2019 (still errors for 2021) NLCD for the Maryland area. However, MRLC just released their new LULC product that includes annual NLCD from 1985-2023 and I suspect there will be new changes to the API which would affect the FedData package.

Edit: At the moment FedData has been removed from CRAN because a dependency was removed. See issue #120

@bocinsky
Copy link
Collaborator

bocinsky commented Nov 5, 2024

Hi all. No clue what's going on with the 2021 legacy data. However, I've implemented the new annual NLCD product! See ?get_nlcd_annual(). Closing this now!

@bocinsky bocinsky closed this as completed Nov 5, 2024
@tungttnguyen
Copy link

Hi all. No clue what's going on with the 2021 legacy data. However, I've implemented the new annual NLCD product! See ?get_nlcd_annual(). Closing this now!

Thanks @bocinsky ! Can you update this page with the new function?
https://docs.ropensci.org/FedData/articles/FedData.html#usgs-national-land-cover-dataset

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

6 participants