R package for the Estuary MPA (EMPA) Level 3 Dashboard data analysis.
git clone https://github.com/your-org/empa-l3-data-analysis.git
cd empa-l3-data-analysisdevtools::load_all(".")vegetativecover_data <- read.csv(
"https://nexus.sccwrp.org/empachecker/export?tablename=tbl_vegetativecover_data"
)
vegetation_sample_metadata <- read.csv(
"https://nexus.sccwrp.org/empachecker/export?tablename=tbl_vegetation_sample_metadata"
)cram <- read.csv("inst/extdata/empa_cram.csv")
gis_data <- read.csv("inst/extdata/BufferLandCover_251203.csv")
wetland_extents <- read.csv("inst/extdata/HabitatZones_260224.csv")
ruggedness <- read.csv("inst/extdata/Ruggedness_250702.csv")all_scores <- score_all_metrics(
vegetation_sample_metadata = vegetation_sample_metadata,
vegetativecover_data = vegetativecover_data,
cram = cram,
gis_data = gis_data,
wetland = wetland_extents,
rugged = ruggedness,
year = c(2023, 2024, 2025)
)Example for CRAM index:
cram_scores <- score_cram_index(
cram = cram,
vegetativecover_data = vegetativecover_data
)Example for native cover:
native_scores <- score_native_cover(
vegetativecover_data = vegetativecover_data,
year = c(2023)
)All metric functions return a data frame with columns:
estuaryname, siteid, year, function_name, indicator_name, metric_name, metric_score
Static metrics (GIS/wetland inputs) do not include a year column, except score_ruggedness() which does.
| function_name | indicator_name | metric_name | R_function_name |
|---|---|---|---|
| Plant | alliances | plant_alliances | metric-plant-alliances.Rscore_plant_alliances() |
| Plant | elevation | ruggedness | metric-ruggedness.Rscore_ruggedness() |
| Plant | habitat | cram_index | metric-cram-index.Rscore_cram_index() |
| Plant | inundation | marsh_plain_inundation | metric-marsh-plain-inundation.Rscore_marsh_plain_inundation() |
| Plant | vegetation | invasive_severity | metric-invasive-severity.Rscore_invasive_severity() |
| Plant | vegetation | native_cover | metric-native-cover.Rscore_native_cover() |
| Plant | vegetation | veg_cover | metric-veg-cover.Rscore_veg_cover() |
| SLR | accretion | sediment_supply | metric-sediment-supply.Rscore_sediment_supply() |
| SLR | habitat | cram_index | metric-cram-index.Rscore_cram_index() |
| SLR | resiliency | buffer_cover | metric-buffer-cover.Rscore_buffer_cover() |
| SLR | resiliency | current_habitat_distribution | metric-current-habitat-distribution.Rscore_current_habitat_distribution() |
| SLR | resiliency | future_habitat_distribution | metric-future-habitat-distribution.Rscore_future_habitat_distribution() |
| SLR | resiliency | perimeter_contiguity | metric-perimeter_contiguity.Rscore_perimeter_contiguity() |
| SLR | resiliency | perimeter_land_cover | metric-perimeter-land-cover.Rscore_perimeter_land_cover() |
| SLR | vegetation | veg_cover | metric-veg-cover.Rscore_veg_cover() |
Function: score_cram_index()
Calculation: Filters vegetation data by year (from samplecollectiondate) or do all years. Filters CRAM data by year (from Year_assessment), groups by Site, and averages the index column to produce one site-level score per year. Left-joins averaged CRAM scores onto the vegetation site list. Sites with no CRAM data receive NA. Normalizes using ((empa_index - cram_min) / cram_range) * 100, rounded to 1 decimal place.
Inputs:
cram: CRAM data frame columnsSite,Year_assessment,indexvegetativecover_data: Raw vegetation cover data frame columnsestuaryname,siteid,samplecollectiondate
Outputs: One row per site per year. metric_score is NA for sites with no CRAM assessment in the selected year.
Function: score_ruggedness()
Calculation: Passes the pre-computed surface ruggedness index directly through with no transformation. Higher values indicate greater topographic complexity.
Inputs:
rugged: Ruggedness data frame columnsestuaryname,siteid,Year,ruggedness
Outputs: One row per site per year.
Function: score_marsh_plain_inundation()
Calculation: Details to be added.
Inputs:
vegetativecover_data: Raw vegetation cover data frame columnsestuaryname,siteid,samplecollectiondate
Outputs: One row per site per year. Currently returns NA for all sites.
Function: score_invasive_severity()
Calculation: Extracts year from samplecollectiondate and filters to the requested year(s). Gets distinct invasive species per site and year using the Cal-IPC rating column. Starts at 100 and subtracts penalty points for each unique invasive species: Limited = 5 pts, Moderate = 10 pts, High = 15 pts. Score is floored at 0. Sites with no invasive species score 100.
Inputs:
vegetativecover_data: Raw vegetation cover data frame columnsestuaryname,siteid,samplecollectiondate,scientificname,rating
Outputs: One row per site per year.
Function: score_native_cover()
Calculation: Extracts year from samplecollectiondate and filters to the requested year(s). Removes records with excluded statuses ("Not recorded", "naturalized"), missing data sentinel (-88), and unknown species (scientificname starting with "unknown"). Sums estimatedcover by site, year, and status, then calculates native species as a percentage of total cover across all statuses. metric_score = percent native.
Inputs:
vegetativecover_data: Raw vegetation cover data frame columnsestuaryname,siteid,samplecollectiondate,status,scientificname,estimatedcover
Outputs: One row per site per year.
Function: score_veg_cover()
Calculation: Extracts year from samplecollectiondate and filters to the requested year(s). Removes missing data sentinel (-88). Sums vegetated_cover and non_vegetated_cover across all plots per site and year, then calculates vegetated cover as a percentage of total. metric_score = percent vegetated.
Inputs:
vegetation_sample_metadata: Raw vegetation sample metadata data frame columnsestuaryname,siteid,samplecollectiondate,vegetated_cover,non_vegetated_cover
Outputs: One row per site per year.
Function: score_plant_alliances()
Calculation: Details to be added.
Inputs:
vegetativecover_data: Raw vegetation cover data frame columnsestuaryname,siteid,samplecollectiondate
Outputs: One row per site per year. Currently returns NA for all sites.
Same function and calculation as Plant > habitat > cram_index. Pass function_name = "SLR".
Function: score_sediment_supply()
Calculation: Details to be added.
Inputs:
cram: CRAM data frame used only to obtain the site list
Outputs: One row per site. Static (no year variation). Currently returns NA for all sites.
Function: score_buffer_cover(buffer_size = "500 m", metric_name = "buffer_cover")
Calculation: Filters GIS buffer data to the 500 m buffer. Groups landcover into "natural" (Ag + Natural) vs "Developed". Sums the percent column for natural classes per site. metric_score = percent natural landcover within the 500 m buffer.
Inputs:
gis_data: GIS buffer land cover data frame columnsestuaryname,siteid,buffer,landcover,percent
Outputs: One row per site. Static (no year variation).
Function: score_perimeter_land_cover()
Calculation: Same as buffer_cover but using the 30 m buffer captures the immediate perimeter of the site.
Inputs:
gis_data: GIS buffer land cover data frame columnsestuaryname,siteid,buffer,landcover,percent
Outputs: One row per site. Static (no year variation).
Function: score_perimeter_contiguity()
Calculation: Filters GIS data to the "Largest Contiguous" and "Total Open" landcover rows, pivots to wide format, then computes (Largest Contiguous / Total Open) * 100. A higher score means the open space surrounding the site is less fragmented better for wetland migration.
Inputs:
gis_data: GIS buffer land cover data frame columnsestuaryname,siteid,landcover,rastercount
Outputs: One row per site. Static (no year variation).
Function: score_current_habitat_distribution()
Calculation: Filters wetland extents data to the "Current Wetland Footprint" extent. Pivots cover classes to wide format, sums the Low, Mid, and High marsh zone proportions, and multiplies by 100. metric_score = percent of current footprint that is vegetated marsh.
Inputs:
wetland: Wetland extents data frame columnsestuaryname,siteid,extent,cover_class,percent_cover
Outputs: One row per site. Static (no year variation).
Function: score_future_habitat_distribution()
Calculation: Same as current_habitat_distribution but filtered to the "Wetland Migration/Avoid Developed (1.2 ft)" extent a modeled scenario showing where the wetland could shift under 1.2 ft of sea level rise while avoiding developed land.
Inputs:
wetland: Wetland extents data frame columnsestuaryname,siteid,extent,cover_class,percent_cover
Outputs: One row per site. Static (no year variation).
Same function and calculation as Plant > vegetation > veg_cover. Pass function_name = "SLR".