ropensci / FedData

Functions to Automate Downloading Geospatial Data Available from Several Federated Data Sources
https://docs.ropensci.org/FedData
Other
97 stars 22 forks source link

get_nass() returns error #54

Closed kevinwolz closed 4 years ago

kevinwolz commented 4 years ago

I used get_ssurgo() to download soil data for one county in Wisconsin, extracted the spatial extent, and then used this to try to pull the NASS data:

SSURGO.areas <- get_ssurgo(template = "WI025", 
                           label = "WI_TEST")

SSURGO.areas.WI025 <- SSURGO.areas$spatial[SSURGO.areas$spatial$AREASYMBOL=="WI025",]

NASS <- get_nass(template = SSURGO.areas.WI025,
                 year = 2018,
                 label = "SSURGO_WI025")

get_nass() produces the following error: "Error in get_nass(template = SSURGO.areas.WI025, year = 2017, label = "SSURGO_WI025") : object 'nass' not found"

I've tried this for a few different years and get the same thing.

bocinsky commented 4 years ago

Hi again! I just pushed a patch for this. The nass object, which is just a table of the landcover categories, had incidentally gotten stripped from the package. I've added it back in. Reinstall from the dev (Github) version, and you should be cooking with fire.

Using your example:

library(FedData)
#> Loading required package: magrittr
#> Loading required package: sf
#> Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
#> Loading required package: sp

SSURGO.areas <- get_ssurgo(template = "WI025", 
                           label = "WI_TEST")
#> (Down)Loading SSURGO data for survey area 1 of 1: WI025
#> Downloading file: http://websoilsurvey.sc.egov.usda.gov/DSD/Download/Cache/SSA/wss_SSA_WI025_[2019-09-10].zip
#> Merging all SSURGO Map Unit polygons
#> Merging all SSURGO data tables

SSURGO.areas.WI025 <- SSURGO.areas$spatial[SSURGO.areas$spatial$AREASYMBOL=="WI025",]

NASS <- get_nass(template = SSURGO.areas.WI025,
                 year = 2018,
                 label = "SSURGO_WI025")

NASS
#> class      : RasterLayer 
#> dimensions : 1744, 2317, 4040848  (nrow, ncol, ncell)
#> resolution : 30, 30  (x, y)
#> extent     : 497805, 567315, 2222955, 2275275  (xmin, xmax, ymin, ymax)
#> crs        : +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs 
#> source     : /private/var/folders/hy/bbl6mk8j7c19_q80nb27_rzm0000gn/T/RtmpsOGg6W/FedData/extractions/nass/SSURGO_WI025/cdl_2018.tif 
#> names      : cdl_2018 
#> values     : 0, 255  (min, max)
#> attributes :
#>         ID   category
#>  from:   0 Background
#>   to : 255

Created on 2020-04-27 by the reprex package (v0.3.0)