From f9c28e325889fcb6d45fbb6df3d66d4dc4509732 Mon Sep 17 00:00:00 2001 From: David Blodgett Date: Tue, 23 Apr 2024 13:17:39 -0500 Subject: [PATCH] fix up nldi output --- R/write_out.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/write_out.R b/R/write_out.R index e0f710c..f1b95fc 100644 --- a/R/write_out.R +++ b/R/write_out.R @@ -5,8 +5,8 @@ write_reference <- function(dam_locations, registry, providers, reference_file, if(is.na(x)) NA_character_ else paste0("https://geoconnex.us/nhdplusv2/comid/", x) }, FUN.VALUE = c("")) - if(all(!grepl("https", dam_locations$nhdpv2_REACHCODE))) { - dam_locations$nhdpv2_REACHCODE <- + if(all(is.na(dam_locations$nhdpv2_REACHCODE) | !grepl("https", dam_locations$nhdpv2_REACHCODE))) { + dam_locations$nhdpv2_REACHCODE_uri <- vapply(dam_locations$nhdpv2_REACHCODE, \(x) { if(is.na(x)) NA_character_ else paste0("https://geoconnex.us/nhdplusv2/reachcode/", x) }, FUN.VALUE = c("")) @@ -18,7 +18,7 @@ write_reference <- function(dam_locations, registry, providers, reference_file, uri, identifier, id), by = "identifier") %>% select(id, uri, name, description, subjectOf, provider, provider_id, - nhdpv2_COMID, nhdpv2_REACHCODE, nhdpv2_REACH_measure, + nhdpv2_COMID, nhdpv2_REACHCODE_uri, nhdpv2_REACHCODE, nhdpv2_REACH_measure, drainage_area_sqkm, drainage_area_sqkm_nhdpv2, index_type, mainstem_uri, feature_data_source) %>% mutate(id = as.integer(id))