2

I'm downloading data from the National Land Cover database using the get_nlcd tool from the FedData package. Here is an example for documentation for this package

library(FedData)

vepPolygon <- polygon_from_extent(raster::extent(672800,740000,4102000,4170000), 
                              proj4string='+proj=utm +datum=NAD83 +zone=12')

# Get the NLCD (USA ONLY)
# Returns a raster
Veg <- get_nlcd(template=vepPolygon, label='VEPIIN',force.redo=TRUE)

#Get Land Use Stats

LandUseStats<-as.data.frame(Veg@data@attributes)
LandUseStats<-LandUseStats[!LandUseStats$Count == 0,]

LandUseStats

  ID OID Value      Count Red Green Blue    NLCD.2011.Land.Cover.Class Opacity
1   0   0     0 7854240512   0     0    0                  Unclassified       1
12 11  11    11  469012527   0     0    0                    Open Water       1
13 12  12    12    1599206   0     0    0            Perennial Snow/Ice       1
22 21  21    21  292251633   0     0    0         Developed, Open Space       1
23 22  22    22  131633826   0     0    0      Developed, Low Intensity       1
24 23  23    23   59456652   0     0    0   Developed, Medium Intensity       1
25 24  24    24   21426522   0     0    0     Developed, High Intensity       1
32 31  31    31  110507264   0     0    0                   Barren Land       1
42 41  41    41  973617734   0     0    0              Deciduous Forest       1
43 42  42    42 1037912310   0     0    0              Evergreen Forest       1
44 43  43    43  179845520   0     0    0                  Mixed Forest       1
53 52  52    52 1940362409   0     0    0                   Shrub/Scrub       1
72 71  71    71 1306961628   0     0    0                   Herbaceuous       1
82 81  81    81  597234572   0     0    0                   Hay/Pasture       1
83 82  82    82 1392218141   0     0    0              Cultivated Crops       1
91 90  90    90  347144473   0     0    0                Woody Wetlands       1
96 95  95    95  116679631   0     0    0 Emergent Herbaceuous Wetlands       1

#Compare to plot
plot(Veg)

If I understand the "Count" to be the number of pixels represented in the associated plot, then when comparing the plot to the Stats, the two don't seem to match. Nor do I understand why close to half the data is "unclassified".

Is there a better way to extract the land use data used in the plot?

1 Answer 1

3

It looks like the @data@attributes element is metadata about the data set as a whole, not the particular extract. I tried get_nlcd with a smaller polygon region and the table in @data@attributes was identical.

The actual pixel class counts in the data are:

> table(Veg[])

     11      21      22      23      24      31      41      42      43      52 
  24691   68988   22099    2810     272   35671  459772 1929928    3474 3129873 
     71      81      82      90      95 
 305054  306191  327458   41239     530 

You can look these up in the data attributes, and it seems you need to add 1 to get the OID value:

> Veg@data@attributes[[1]][1+unique(Veg[]),]
   ID OID Value      Count Red Green Blue    NLCD.2011.Land.Cover.Class Opacity
43 42  42    42 1037912310   0     0    0              Evergreen Forest       1
53 52  52    52 1940362409   0     0    0                   Shrub/Scrub       1
83 82  82    82 1392218141   0     0    0              Cultivated Crops       1
82 81  81    81  597234572   0     0    0                   Hay/Pasture       1
22 21  21    21  292251633   0     0    0         Developed, Open Space       1
72 71  71    71 1306961628   0     0    0                   Herbaceuous       1
23 22  22    22  131633826   0     0    0      Developed, Low Intensity       1
91 90  90    90  347144473   0     0    0                Woody Wetlands       1
42 41  41    41  973617734   0     0    0              Deciduous Forest       1
32 31  31    31  110507264   0     0    0                   Barren Land       1
12 11  11    11  469012527   0     0    0                    Open Water       1
24 23  23    23   59456652   0     0    0   Developed, Medium Intensity       1
44 43  43    43  179845520   0     0    0                  Mixed Forest       1
25 24  24    24   21426522   0     0    0     Developed, High Intensity       1
96 95  95    95  116679631   0     0    0 Emergent Herbaceuous Wetlands       1

Most of those columns, including the Count, seem a bit useless.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.