Skip to content

DRAFT: ycx_build_rasters.R emits AGC values (unblocks carbon-by-ecoregion)#85

Draft
holoros wants to merge 1 commit into
mainfrom
feat/rasterbuild-value-outputs-draft
Draft

DRAFT: ycx_build_rasters.R emits AGC values (unblocks carbon-by-ecoregion)#85
holoros wants to merge 1 commit into
mainfrom
feat/rasterbuild-value-outputs-draft

Conversation

@holoros

@holoros holoros commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Status: DRAFT — unrun, needs verification. Do not merge as-is.

What

Makes ycx_build_rasters.R emit the values behind the carbon overlay, not just the display PNG, so carbon (and the 100-yr change) can be summarized by EPA L3 ecoregion the same way harvest / structure / CSPI already are. Added after the existing PNG render block:

  1. hybrid_agc_perplot.csv — per-plot AGC density (Mg C/ha) with lon/lat/state. Enables dependency-free point-in-polygon zonal stats by ecoregion (the same approach used for the other ecoregion layers), no GDAL needed.
  2. conus_hybrid_agc2022.tif + conus_hybrid_dagc100.tif — georeferenced GeoTIFFs of the binned grids, written only when terra is available (guarded so the no-terra path is unchanged).

It is faithful to the existing agc0/dagc computation — it saves the same numbers the deployed PNG already draws. Nothing is fabricated and no public/api/ data changes.

Why it's a draft (two things to resolve before running/merging)

  1. Blocked input: the script reads membership_slim.csv (the per-plot FIA/TreeMap table), which is not currently present anywhere in yield_curves_conus on Cardinal. hybrid_carbon_fits.csv and product_fractions_by_cell_age.csv are present; membership_slim.csv must be regenerated before the script can run.
  2. CRS caveat: this grid uses the explorer's spherical Albers (lat_0 = 38, +R sphere), which differs ~0.5° from the lat_0 = 37.5 ellipsoidal grid of the TreeMap-derived ph_*/structure rasters. The GeoTIFF CRS is set to match the script's own projection; verify alignment against a state outline before trusting any spatial join, and keep each raster in its own CRS when zonal-summarizing.

Verification done / not done

  • R parses clean (parse() check). Not executed (blocked on membership_slim.csv and terra/GDAL on a compute node).

Next steps for whoever picks this up

Regenerate membership_slim.csv → run Rscript ycx_build_rasters.R <build_dir> <product_fractions_csv> <out_dir> on Cardinal with the geo modules loaded → confirm the AGC tif aligns to a state outline → zonal-average hybrid_agc_perplot.csv (or the tif) by EPA L3 → add agc_2022/dagc_100 fields to ecoregion_harvest_summary.json via the existing generator.

So carbon can be summarized by ecoregion downstream instead of only
shown as a PNG. Adds, after the existing PNG render: a per-plot AGC table
(lon/lat/state/agc) for dependency-free point-in-polygon zonal stats, and
georeferenced GeoTIFFs of the binned agc2022/dagc100 grids when terra is
available. Faithful to the existing agc0/dagc computation — no new data.

UNRUN: the script still depends on membership_slim.csv, which is not
currently present in yield_curves_conus; regenerate it before running.
CRS caveat documented (this grid is lat_0=38 spherical vs the 37.5
ellipsoidal grid of the ph_*/structure rasters). R parses clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant