FedData
FedData copied to clipboard
Obey MAXSIZE limits on NASS CDL mapserver
I get the below, and that looks like a bug to me (it would be more practical if you example data did not rely on another package, by the way).
library(raster)
library(FedData)
ap <- as(extent(-110, -109, 33.5, 37), "SpatialPolygons")
crs(ap) <- "+proj=longlat"
cdl <- get_nass(ap , "test")
#Error in UseMethod("as_list") :
# no applicable method for 'as_list' applied to an object of class "raw"
traceback()
#5: xml2::as_list(.)
#4: base::with(., ExceptionReport$Exception$ExceptionText[[1]])
#3: response %>% httr::content(encoding = "UTF-8") %>% xml2::as_list() %$%
# ExceptionReport$Exception$ExceptionText[[1]]
#2: stop(response %>% httr::content(encoding = "UTF-8") %>% xml2::as_list() %$%
# ExceptionReport$Exception$ExceptionText[[1]])
#1: get_nass(ap, "test")
Also, get_cdl
would be a better name than get_nass
because NASS is a organization that provides a lots of different data sets
Thanks @rhijmans. I've gone ahead and made get_nass_cdl
the primary function name, with get_cdl
as an alias and get_nass
soft deprecated.
That large of an AOI definitely causes an error, but now I see (after switching to use WCS v2.0.1):
library(raster)
#> Loading required package: sp
library(FedData)
ap <- as(extent(-110, -109, 33.5, 37), "SpatialPolygons")
crs(ap) <- "+proj=longlat"
cdl <- get_nass_cdl(ap , "test")
#> Error in get_nass_cdl(ap, "test"): msWCSGetCoverage20(): WCS server error.
#> Raster size out of range, width and height of resulting coverage must be no more than MAXSIZE=4096.
Looks like I need to break the request into 4096 x 4096 chunks and then mosaic them back together.