Demonstration of using the NABatR library to query and display GRTS cells.

# if(!require(devtools)){install.packages(devtools)}
# devtools::install_github("talbertc-usgs/nabatr")
# library(nabatr)
# OR
source('../R/get_nabat_grts.R')
if(!require(devtools)){install.packages(devtools)}
devtools::install_github("ennsk/nabatr")
print ('test for dev branch')
library(sp)

Let's take a look at the amount of US Forest Service land in each GRTS cell in Colorado

colorado = get_grts_data('conus', query="state_n_1='Colorado'")
ylgn <- colorRampPalette(c('palegoldenrod', 'forestgreen'))
spplot(colorado, zcol='own_USFS', col.regions = ylgn(100))
dim(colorado)
grts_id  = 381
current_site = subset(colorado, colorado$GRTS_ID == grts_id)
lat          = current_site$lat
lon          = current_site$long

print (paste0('GRTS ID:   ', grts_id))
print (paste0('Latitude:  ', lat))
print (paste0('Longitude: ', lon))

Where do the high priority cells(top 5%) overlap these US Forest Service lands?

colorado_priority = get_grts_data('Conus', query="state_n_1='Colorado'", only_priority = T)

If you want to query a subset smaller than the entire frame (all the cells in a single county) or a cutoff different than 5% run the following selection

Note these priority cells can vary slightly different than the national selection, especially at smaller extents.

cutoff_pcnt = 3

usfs_cells = colorado[colorado$own_USFS >= 50, ]

usfs_priority_cells = usfs_cells[usfs_cells$GRTS_ID <= quantile(colorado$GRTS_ID, prob=cutoff_pcnt/100),]

Map these two high priority cells

library(ggplot2)
library(ggmap)
library(maps)
library(mapdata)
states <- map_data("state")
counties <- map_data("county")
co_df <- subset(states, region == "colorado")
co_county <- subset(counties, region == "colorado")
co_base <- ggplot(data = co_df, mapping = aes(x = long, y = lat, group = group)) + 
  coord_fixed(1.3) + 
  geom_polygon(color = "black", fill = "gray")
library(repr)
options(repr.plot.width=10, repr.plot.height=8)

co_base +
    geom_polygon(data=spTransform(usfs_cells, CRS("+proj=longlat +datum=WGS84")), color='grey30', fill='red', alpha=0.0) +
    geom_polygon(data=spTransform(colorado_priority, CRS("+proj=longlat +datum=WGS84")), color='red', fill='red', alpha=0.5) + 
    geom_polygon(data=spTransform(usfs_priority_cells, CRS("+proj=longlat +datum=WGS84")), color='forestgreen', fill='green', alpha=0.0, size=1) + 
    geom_polygon(data = co_county, fill = NA, color = "white") +
    geom_polygon(color = "black", fill = NA) +
    ggtitle("Colorado USFS GRTS Priority Cells in Colorado")


talbertc-usgs/NABatR documentation built on April 22, 2020, 8:23 p.m.