Error when running get_nlcd function: Area of interest includes 1 NLCD tile(s). (Down)Loading NLCD tile: N36W108 Downloading file (if necessary): https://prd-tnm.s3.amazonaws.com/StagedProducts/NLCD/data/2011/impervious/3x3/NLCD2011_IMP_N36W108.zip Error in value[[3L]](cond) : nlcd file /home/vikumar/NY/Rochester/RAW/NLCD/NLCD2011_IMP_N36W108.zip corrupt or incomplete. Please delete the file and try again.
Closed this issue · 6 comments
Does it mean that there is no data?
This sometimes happens when a download gets stopped midway through. Have you tried deleting that file on your machine and downloading it again, or else using “force.redo= TRUE”?
Yes, I did try both things. But still facing the same issue, however, for all other functions like NED it is working.
Hi @vijaykumar18. Would you mind sharing your code that you used, and perhaps your area of interest? I need a reproducible example in order to get this figured out. Thank you!
Hi @bocinsky , Thak you for the help!
Here is the exact example I was following to start with:
https://mbjoseph.github.io/posts/2018-12-27-categorical-spatial-data-extraction-around-buffered-points-in-r/
Ah. It looks like you are using the CRAN version of FedData. get_nlcd from that version has known bugs, and I've vastly improved it in the dev version. Do this:
# install.packages("devtools")
# devtools::install_github("ropensci/FedData")
library(FedData)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1
library(raster)
#> Loading required package: sp
site_df <- data.frame(city = c('Denver', 'Boulder'),
lat = c(39.7392, 40.0150),
lon = c(-104.9903, -105.2705))
site_df <- st_as_sf(site_df,
coords = c("lon","lat"),
crs = 4326)
nlcd_raster <- get_nlcd(template = site_df,
label = 'categorial-extraction',
year = 2011)
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
#> = prefer_proj): Discarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137
#> +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null
#> +wktext +no_defs +type=crs
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
#> prefer_proj): Discarded datum World Geodetic System 1984 in CRS definition
plot(nlcd_raster)
Created on 2020-10-20 by the reprex package (v0.3.0)
Got it. Thank you so much.