hunter-stanke / rFIA

rFIA
https://rfia.netlify.com/
47 stars 23 forks source link

Difficulty using huc watersheds as polygons #30

Open MalakoffE opened 2 years ago

MalakoffE commented 2 years ago

Hello!

I am running into trouble using VT HUC_12_watershed polygons in a tpa function. The code runs, but outputs a table with 26 variables and no observations. The polygons are stored in a SpatialPolygonsDataFrame. Maybe they are too geographically small? My code (which is super straightforward) is below.

set wd

setwd("/Users/Liza/OneDrive - Dartmouth College/BigDataHydrology/Final_Project")

Clear environment

rm(list = ls())

Libraries

library(rFIA) library(RSQLite) library(data.table) library(sf) library(rgdal) library(here)

READ FIA DATA

Downloaded from FIA datahub SQL file using fix from Github

And keep only most recent data from each plot

fiaVT = readFIA("/Users/Liza/OneDrive - Dartmouth College/BigDataHydrology/Final_Project/VT_FIA_data", common = TRUE) fiaVT = fiaVT_recent <- clipFIA(fiaVT, mostRecent = TRUE)

GET WATERSHED POLY

Downloaded from https://geodata.vermont.gov/datasets/vt-subwatershed-boundaries-huc12/explore

huc12_vt <- readOGR(dsn = '/Users/Liza/Library/CloudStorage/OneDrive-DartmouthCollege/BigDataHydrology/Final_Project/Watershed_shapefiles/VT_SubwatershedBoundaries-_HUC12', layer = 'VT_SubwatershedBoundaries-_HUC12')

Calculate tpa for each watershed

tpaHUC <- tpa(fiaVT, polys = huc12_vt, returnSpatial = TRUE)

whalend commented 2 years ago

You’re likely right that the HUC12 watersheds are too small, particularly for Vermont with such a small area already. My suggestion is create a spatial points object with the FIA data (tpa( byPlot=T, returnSpatial=T) and overlay those on the HUC12 polygons to see how many FIA plots are in each watershed. Likely not enough to make an aggregate estimate.

More generally, a rule of thumb with FIA data is the smallest unit of aggregation recommended is the county. And in some cases even that is too small depending on tolerance for sample error.

MalakoffE commented 2 years ago

This is a great suggestion. Thanks!

On Sun, May 29, 2022 at 1:09 PM Whalen @.***> wrote:

You’re likely right that the HUC12 watersheds are too small, particularly for Vermont with such a small area already. My suggestion is create a spatial points object with the FIA data (tpa( byPlot=T, returnSpatial=T) and overlay those on the HUC12 polygons to see how many FIA plots are in each watershed. Likely not enough to make an aggregate estimate.

More generally, a rule of thumb with FIA data is the smallest unit of aggregation recommended is the county. And in some cases even that is too small depending on tolerance for sample error.

— Reply to this email directly, view it on GitHub https://github.com/hunter-stanke/rFIA/issues/30#issuecomment-1140488786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMFW75SDORCWM3TS4H6QOTVMOQEXANCNFSM5XHISQPA . You are receiving this because you authored the thread.Message ID: @.***>