Appendix B — EPA CDX Upload and Data Management Procedures
C EPA CDX Upload and Data Management Procedures
This chapter documents the annual step-by-step procedures for submitting Kenai River baseline water quality data to the EPA Central Data Exchange (CDX) / Water Quality Exchange (WQX), and for removing or correcting previously submitted data.
Note: This chapter was developed and tested during the 2021 data submission (completed March 31, 2026). Where a step has not been personally verified, it is noted.
CDX login URL: https://cdx.epa.gov/
KWF Organization ID in EPA WQX: KENAI_WQX
EPA WQX support contact: wqx@epa.gov / 800-424-9067
The three output files ready for upload are generated by appendix_a.qmd and written to other/output/wqx_formatted/:
| File | Contents |
|---|---|
results_activities.csv |
All sample results and associated activity metadata |
project.csv |
Project description and QAPP approval status |
station.csv |
Monitoring location metadata |
Upload these files together in the same CDX session. Also have the QAPP PDF on hand for the project upload:
KenaiWatershedForum_QAPP_v3_2023_with_Addendum_April_2024.pdf
C.1 Uploading Data to EPA CDX
The general sequence below is confirmed correct. Exact button labels should be verified against the WQX Web interface at time of upload — the UI may change between annual submissions.
C.1.1 Step 1: Log in to CDX
- Navigate to https://cdx.epa.gov/.
- Log in with your CDX username and password. Create an account if this is your first time using it.
- From the My CDX dashboard, locate WQX Web under “My Programs” and click Go to WQX Web.
C.1.2 Step 2: Upload the Station file
The station file registers monitoring location metadata (coordinates, location descriptions, etc.). Upload this before results, as results reference station IDs.
- In WQX Web, navigate to Import & Submit.
- Select import type: Monitoring Location.
- Select the KWF station import configuration (or create one - see the WQX Web User Guide).
- Browse to and select
other/output/wqx_formatted/station.csv. - Submit and wait for Completed status.
C.1.3 Step 3: Upload the Project file
- In WQX Web, navigate to Import & Submit.
- Select import type: Project.
- Select the KWF project import configuration.
- Browse to and select
other/output/wqx_formatted/project.csv. - Attach the QAPP PDF (
KenaiWatershedForum_QAPP_v3_2023_with_Addendum_April_2024.pdf) and set attachment type to QAPP. - Submit and wait for Completed status.
C.1.4 Step 4: Upload the Results and Activities file
- In WQX Web, navigate to Import & Submit.
- Select import type: Activity (results are nested under activities in WQX).
- Select the KWF results/activities import configuration,
KWF_Results_Baseline_Template_v2(see Section C.2). - Browse to and select
other/output/wqx_formatted/results_activities.csv. - Submit and wait for Completed status. This is the largest file and may take several minutes.
C.1.5 Step 5: Verify the upload
- Allow 24–48 hours for data to propagate, then search for KWF data in How’s My Waterway or the Water Quality Portal.
- Confirm that results are visible and that values, units, and site names look correct.
C.1.6 Rule: New vs. existing data option
Each import screen asks whether the file contains new data, existing data, or both. Choose by whether the records already exist in WQX, not by file type:
| File | Option | Notes |
|---|---|---|
project.csv |
Existing data only | The project is already in WQX; the import updates it. |
station.csv |
Existing data only | Applies while no new stations are being added. If any station ID is not yet in WQX, use “new and/or existing” for that file. |
results_activities.csv |
New data only | Use when the Activity IDs are not in WQX (e.g., a new year, or after a delete has cleared on WQP). If they are in WQX, see Section C.5. |
Existing-data imports overwrite stored values with the file’s values. Keep “Let me review my dataset in the staging area before submitting” selected. For station.csv, confirm the staging counts show the expected number of existing records and 0 new; a nonzero new count means the IDs did not match (see Section C.4).
C.2 Results Import Configuration in WQX Web
The results file is imported with a saved configuration, KWF_Results_Baseline_Template_v2 (Uid 9481), rebuilt in September and October 2026 as a copy of the older configuration Uid 8515. It has 53 columns that must match, in order, the columns that functions/appendix_a_scripts/generate_cdx_export.R writes. If that script’s column order or column set changes, the configuration must change with it. The finished configuration has not yet been downloaded into the repo for version control.
C.2.1 How a configuration works
Each column in the file is mapped to one WQX element, marked Ignore Column, or replaced by a constant Generated Value that has no file column at all. WQX Web checks the file position of every column against the configuration, so one extra or missing column shifts everything after it and produces misleading errors on many rows.
C.2.2 Building or editing columns
- Open the configuration under Import & Submit and use the small page icon on a row to open the Elements dialog. The dialog is scoped to the table it was opened from: opened from Columns, checked elements become file-mapped columns; opened from Generated Values, they become constant values that consume no column letter.
- New columns land in an unlettered bundle. Only the top row of the bundle shows the column-letter dropdown. Assigning it a letter inserts it at that absolute position and shifts the rest down by one; repeat until the sequence matches the file. Find rows by element name, never by current number, because the numbers move.
- Save, then import a small subset (5 to 10 rows) before the full file.
C.2.3 The “Ignore Column” pattern
Some columns exist in the export for human readability but have no WQX element, or are always blank. Keep them in the file so positions stay aligned, and map them with the Ignore Column button of the Elements dialog (it works with no boxes checked and inserts a placeholder row that is excluded from mapping). Columns currently ignored:
| Column | Position | Reason |
|---|---|---|
| Monitoring Location Name | C | Station-level attribute, already supplied by station.csv; no results-level element |
| Activity End Date | I | Always blank (see the rule below) |
| Activity End Time | J | Always blank (see the rule below) |
| Laboratory Sample ID | AU | No live WQX element |
C.2.4 Generated values
| Element | Value |
|---|---|
| Organization ID | KENAI_WQX |
| Activity Start Time Zone | AKDT |
| Analysis Start Time Zone | AKDT |
| Activity Horizontal Collection Method | GPS-Unspecified |
| Activity Horizontal Reference Datum | NAD83 |
The horizontal method and datum are required whenever latitude and longitude are present. Their values were taken from the already-accepted station.csv, where they are identical for all 22 stations.
C.2.5 Rule: a mapped element needs a value on every row
WQX Web requires the parent element of a Generated Value whenever that element has any column mapping, even if the mapped column is empty. In October 2026 the time zone Generated Value for Activity End Time combined with mapped but always-blank Activity End Date and Activity End Time columns produced an “Activity End Time required” error on all 830 rows. Switching those two columns to Ignore Column removed the error. If an always-blank column triggers a blanket required-value error, check for a related Generated Value and ignore the column instead of mapping it.
C.2.6 Typical data-level errors found at the first import
These are fixed in functions/appendix_a_scripts/format_wqx.R and generate_cdx_export.R, but they show what the validator checks:
- Domain values must match WQX exactly, for example
Cold Packs (4 deg C),Practical Quantitation Limit, and container colorAmber. - Characteristic names that WQX maps through synonyms need a matching
Method Speciation(for exampleas Pfor total phosphorus,as Nfor nitrate plus nitrite). - A Result Unit with a blank Result Value is an error, so blank the unit on non-detects.
- A Detection Limit Type needs a Detection Limit Value; only populate type 2 and unit 2 when the value exists.
- Coordinates must use an ASCII hyphen. A Unicode hyphen (U+2010) in one site’s longitude broke 29 rows.
- Units must use WQX capitalization (
mg/L); this is standardized at ingestion.
C.3 Deleting Previously Submitted Data
Deletion is necessary when Activity IDs change between submissions (e.g., due to corrected analyte naming conventions). Re-uploading alone only overwrites records with exactly matching Activity IDs - records with changed IDs remain as orphans in WQX. See Section C.5 for when re-upload without deletion is sufficient.
Important: Deletion in WQX is permanent. Always confirm the scope before proceeding and keep local copies of all submission files.
C.3.1 Generating a delete file
The delete file is a single-column CSV listing the Activity IDs to remove. Activity IDs must be provided without the organization prefix - WQX resolves them against the organization associated with the logged-in account.
Activity IDs as downloaded from the Water Quality Portal include the org prefix (e.g., KENAI_WQX-KBL_t_30.0-2021-07-27-P). Strip the prefix before using them in a delete file:
library(tidyverse)
# Load WQP download and extract 2021 Activity IDs
wqp <- read_csv("other/input/WQX_downloads/wqp_download_YYYYMMDD/narrowresult.csv")
delete_file <- wqp |>
filter(year(ActivityStartDate) == 2021) |>
select(ActivityIdentifier) |>
distinct() |>
mutate(ActivityIdentifier = sub("^KENAI_WQX-", "", ActivityIdentifier))
write_csv(delete_file, "other/output/epa_wqp_uploads/corrected_epa_wqp_uploads/resultphyschem_DELETE.csv")The resulting file should have a single column named ActivityIdentifier with one ID per row (no org prefix).
C.3.3 Verifying the delete
After the import completes, download a fresh results file from the Water Quality Portal for organization KENAI_WQX and the relevant date range. Confirm zero records are returned before proceeding with the re-upload.
C.4 Never Include the Org Prefix in Any ID Column
WQX Web prepends KENAI_WQX- to IDs on import. IDs copied from WQP downloads already carry the prefix, so they must be stripped in every ID column of an upload file: Activity ID, Monitoring Location ID (results file), and MonitoringLocationIdentifier (station file). On 2026-10-14 the 2021 files were uploaded with the prefix still in the two location columns, which created 22 duplicate stations named like KENAI_WQX-KENAI_WQX-10000002 that held all 830 results. Cleanup is documented in other/output/epa_wqp_uploads/2026-10-20_doubled_station_cleanup/README.md. The prefix is now stripped in functions/appendix_a_scripts/generate_cdx_export.R.
C.5 Updating Data Without Full Deletion
If the Activity IDs in the corrected file exactly match what is already in WQX (i.e., only values are changing, not the IDs themselves), a full delete is not necessary. Re-uploading a file with matching Activity IDs will overwrite the existing records for those IDs.
Use this approach only when you are confident no Activity IDs have changed. If analyte naming conventions, site codes, or sample type suffixes have been revised, the ID structure may have changed — use the full delete approach instead.
To check for ID mismatches between your corrected file and WQX before deciding:
# Load WQP download and strip prefix
wqx_ids <- read_csv("other/input/WQX_downloads/wqp_download_YYYYMMDD/narrowresult.csv") |>
filter(year(ActivityStartDate) == 2021) |>
distinct(ActivityIdentifier) |>
mutate(ID_stripped = sub("^KENAI_WQX-", "", ActivityIdentifier))
# Load corrected upload file
new_ids <- read_csv("other/output/wqx_formatted/results_activities.csv") |>
distinct(`Activity ID`)
cat("WQX records not matched by new file (would become orphans):",
sum(!wqx_ids$ID_stripped %in% new_ids$`Activity ID`), "\n")If this count is zero, re-upload without deletion. If nonzero, use the full delete approach.
C.6 WQX Data Structure Note
As of March 2026, KWF’s WQX data is organized at the Activity level: each Activity record contains one result. EPA WQX support (Kevin Christian, wqx@epa.gov) recommends organizing data at the Results level instead, where each Activity represents one sampling event (unique location + date) and multiple Results are nested under it.
The current structure is not invalid, but performance may degrade as the total record count grows. Restructuring involves using the Review function in WQX Web to re-define existing records. This is a lower-priority task best addressed at a later time and incorporated into future annual submission pipelines.
C.7 Removing the Existing 2021 KWF Submission (Reference — Completed 3/31/2026)
The 2021 KWF dataset was fully deleted on 3/31/2026 and replaced with a corrected version. The corrected files are:
other/output/wqx_formatted/results_activities.csv(843 records)other/output/wqx_formatted/project.csvother/output/wqx_formatted/station.csv
Corrections addressed: Ca/Mg/Fe unit errors (summer 2021 SGS EDD reported dissolved metals as µg/L when values were on mg/L scale); RM 1.5 site ID mismatch; renamed Activity IDs (Nitrate_Nitrite-N → Total Nitrate/Nitrite-N, Total xylenes → individual xylene names). See (appendix_a?) for full QA/QC details.
C.8 Troubleshooting Common Issues
| Issue | Likely Cause | Resolution |
|---|---|---|
| Delete import fails: “Domain Value Invalid” for all rows | Activity IDs include the KENAI_WQX- org prefix |
Strip the prefix; WQX resolves IDs against the logged-in org |
| Import fails: “invalid monitoring location” | Station not yet registered | Upload station.csv before results_activities.csv |
| Records submitted but not visible in WQP | Propagation delay, or status is “Accepted” not “Completed” | Wait 24–48 hours; recheck submission status |
Results appear on stations named KENAI_WQX-KENAI_WQX-... |
Location IDs in the upload files included the org prefix | Strip the prefix from all ID columns (Section C.4); delete the misplaced results and stations, then re-upload |
| Same required-value error on every row (e.g. “Activity End Time required”) | An always-blank column is mapped to an element that a Generated Value depends on | Set the column to Ignore Column (Section C.2) |
| Results import halts at Row 2: “More columns than expected. Import Configuration does not match the import file” | Wrong import configuration selected (the older KWF_Results_Baseline_Template, Uid 8515, instead of _v2, Uid 9481) |
Re-run the import with KWF_Results_Baseline_Template_v2; the failed dataset holds no records |
| Many unrelated errors after one column | File and configuration columns are out of step | Compare file header to the configuration column order, position by position |
| Re-upload leaves stale records | Activity IDs changed between versions | Use full delete approach; do not rely on overwrite alone |
C.9 EPA and WQX Resources
- CDX login: https://cdx.epa.gov/
- WQX Web user guide: https://www.epa.gov/waterdata/water-quality-exchange-web-wqx-web-user-guide
- WQX domain values: https://www.epa.gov/waterdata/wqx-domain-files
- Water Quality Portal: https://www.waterqualitydata.us/
- How’s My Waterway: https://mywaterway.epa.gov/
- EPA WQX support: Kevin Christian — wqx@epa.gov / storet@epa.gov / 800-424-9067
