Wrapper to get FIA plots within the boundary population (area of interest) - Intersect with state boundary - Get FIA plots for intersected states, including tree, and spatial - Clip spatial coordinates and other tables to boundary (spClipPoint)
spGetPlots(
bnd = NULL,
bnd_dsn = NULL,
bnd.filter = NULL,
states = NULL,
RS = NULL,
pltids = NULL,
xy_datsource = NULL,
xy_dsn = NULL,
xy = "PLOT",
xy_opts = xy_options(),
datsource = NULL,
data_dsn = NULL,
dbTabs = dbTables(),
eval = "FIA",
eval_opts = NULL,
puniqueid = "CN",
invtype = "ANNUAL",
intensity1 = FALSE,
clipxy = TRUE,
pjoinid = NULL,
showsteps = FALSE,
returnxy = TRUE,
returndata = TRUE,
savedata = FALSE,
savexy = FALSE,
savebnd = FALSE,
exportsp = FALSE,
savedata_opts = NULL,
spXYdat = NULL,
gui = FALSE,
...
)
sf R object, Area of Interest (AOI) boundary. Can be a spatial sf object, full pathname to a shapefile, or name of a layer within a database.
String. Data source name (dsn; e.g., SQLite database or shapefile pathname) of bnd. The dsn varies by driver. See gdal OGR vector formats (https://www.gdal.org/ogr_formats.html). Optional if bnd is an R object.
String. Filter to subset bnd spatial layer.
String. The name of state(s) for tables (e.g., "Vermont", "Utah").
String. Name of FIA research station to restrict states to ('RMRS','SRS','NCRS','NERS','PNWRS'). If NULL, all research stations are included.
Data frame. Non-spatial plot identifiers within bnd).
String. Source of XY data ("obj", "csv", "datamart", "sqlite"). If datsource=NULL, checks extension of xy_dsn or xy to identify datsource.
String. Data source name (dsn; i.e., pathname or database name) of xy. The dsn varies by driver. See gdal OGR vector formats (https://www.gdal.org/ogr_formats.html). Optional if bnd_layer is an R object.
sf R object or String. Table with xy coordinates. Can be a spatial polygon object, data frame, full pathname to a shapefile, or name of a layer within a database.
List of xy data options to specify if xy is NOT NULL. See xy_options (e.g., xy_opts = list(xvar='LON', yvar='LAT').
String. Source of FIA data ("obj", "csv", "datamart", "sqlite"). If datsource="sqlite", specify database name in data_dsn and layers in *_layer arguments. If datsource="datamart", files are downloaded and extracted from FIA DataMart (http://apps.fs.usda.gov/fia/datamart/datamart.html). See details for more information about plot coordinates. If datsource="csv", specify *.csv file names in *_layer arguments.
String. Name of database where *_layers reside.
List of database tables the user would like returned. See help(dbTables) for a list of options.
String. Type of evaluation time frame for data extraction ('FIA', 'custom'). See eval_opts for more further options.
List of evaluation options for 'FIA' or 'custom' evaluations to determine the set of data returned. See help(eval_options) for a list of options.
String. Name of unique identifier of plt.
String. Type of FIA inventory to extract ('PERIODIC', 'ANNUAL'). Only one inventory type (PERIODIC/ANNUAL) at a time.
Logical. If TRUE, includes only XY coordinates where INTENSITY = 1 (FIA base grid).
Logical. If TRUE, clips xy data to bnd.
String. Variable in plt to join to XY data. Not necessary to be unique. If using most current XY coordinates, use identifier for a plot (e.g., PLOT_ID).
Logical. If TRUE, display data in device window.
Logical. If TRUE, save xy coordinates to outfolder.
Logical. If TRUE, returns data objects.
Logical. If TRUE, saves data to outfolder.
Logical. If TRUE, saves XY data to outfolder.
Logical. If TRUE, and savedata=TRUE, saves bnd. If out_fmt='sqlite', saves to a SpatiaLite database.
Logical. If TRUE, and savexy=TRUE, saves xy data as spatial data. If FALSE, saves xy data as table.
List. See help(savedata_options()) for a list of options. Only used when savedata = TRUE.
R list object. Output from spGetXY().
Logical. If TRUE, uses gui interface.
parameters passed to DBgetPlots().
sf object. Input xy data clipped to boundary.
sf object. Input bnd.
list object. List of input layers clipped to boundary (pltx,condx,etc.).
String. Name of unique identifier of xy.
String. Name of unique identifier of plot in plt.
String. Name of unique identifier of plot in plt.
If savedata=TRUE, outdat data frame is saved to outfolder.
datsource
Plots are extracted from 3 different data sources:
1) CSV - data have
previously been extracted from the FIA database and stored as CSV files.
2) datamart - data are extracted from FIA's publically-available
datamart.
3) sqlite - data have previously been extracted from the FIA
database and stored within a SQLite database.
Selection parameters
FIA plots are selected based on the following parameters:
evalid - the FIA evaluation identifier | |
evalCur - the most current FIA evaluation in database | |
evalEndyr - the FIA evaluation ending in evalEndyr | |
evalType - the FIA evaluation type ('ALL', 'AREAVOL', 'GRM', 'P2VEG', 'DWM', 'INV', 'REGEN', 'CRWN') | |
measCur - the most current measurement of each plot in database | |
measEndyr - the most current measuremtn of each plot in database in or prior to measEndyr | |
Endyr.filter - a filter for bnd that specifies the boundary where measEndyr should be applied |
If savebnd=TRUE:
If out_fmt=c('csv','shp'), the st_write (sf) function
is called. The ArcGIS driver truncates variable names to 10 characters or
less. Variable names are changed before export using an internal function
(trunc10shp). If Spatial object has more than 1 record, it will be returned
but not exported.
If datsource="datmart", data are imported from FIA DataMart. The plot coordinates have been altered for privacy (See https://www.fia.fs.fed.us/tools-data/spatial/Policy/index.php for details). The zip files are extracted on-the-fly from the online website. Web server connections will affect download speeds.
if (FALSE) {
# Get polygon vector layer from FIESTA external data
WYbhfn <- system.file("extdata",
"sp_data/WYbighorn_adminbnd.shp",
package = "FIESTA")
# Extract data from FIA datamart for measurement years 2013 thru 2015
dat <- spGetPlots(bnd = WYbhfn,
datsource = "datamart",
eval = "custom",
eval_opts = list(measyrs = 2013:2015))
names(dat)
tabs <- dat$tabs
names(tabs)
head(tabs$plt)
table(tabs$plt$MEASYEAR)
# Extract data from FIA datamart for most current evaluation
datCur <- spGetPlots(bnd = WYbhfn,
datsource = "datamart",
eval = "FIA",
eval_opts = list(Cur = TRUE))
names(datCur)
tabsCur <- datCur$tabs
names(tabsCur)
head(tabsCur$plt)
table(tabsCur$plt$MEASYEAR)
}