FedData icon indicating copy to clipboard operation
FedData copied to clipboard

Obey MAXSIZE limits on NASS CDL mapserver

Open rhijmans opened this issue 3 years ago • 1 comments

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

rhijmans avatar May 26 '21 22:05 rhijmans

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.

bocinsky avatar May 27 '21 05:05 bocinsky