diff --git a/modules/data.atmosphere/NAMESPACE b/modules/data.atmosphere/NAMESPACE index ad08797ea15..4b5e9c9b34e 100644 --- a/modules/data.atmosphere/NAMESPACE +++ b/modules/data.atmosphere/NAMESPACE @@ -14,7 +14,6 @@ export(cfmet.downscale.time) export(check_met_input_file) export(closest_xy) export(cos_solar_zenith_angle) -export(db.site.lat.lon) export(debias.met) export(debias.met.regression) export(download.Ameriflux) diff --git a/modules/data.atmosphere/NEWS.md b/modules/data.atmosphere/NEWS.md index dcfb553cb25..c9410bb86e8 100644 --- a/modules/data.atmosphere/NEWS.md +++ b/modules/data.atmosphere/NEWS.md @@ -24,6 +24,7 @@ ## Removed * Helper function `robustly` has moved to package PEcAn.utils [@meetagrawal, #3096] +* Helper function `db.site.lat.lon` has been removed. Users should use `PEcAn.DB::query.site(id, con)[c("lat", "lon")]` instead [@Sweetdevil144, #3308] # PEcAn.data.atmosphere 1.7.1 diff --git a/modules/data.atmosphere/R/met.process.R b/modules/data.atmosphere/R/met.process.R index c2e253586d9..8e1408b3887 100644 --- a/modules/data.atmosphere/R/met.process.R +++ b/modules/data.atmosphere/R/met.process.R @@ -159,9 +159,10 @@ met.process <- function(site, input_met, start_date, end_date, model, } # setup site database number, lat, lon and name and copy for format.vars if new input + latlon <- PEcAn.DB::query.site(site$id, con = con)[c("lat", "lon")] new.site <- data.frame(id = as.numeric(site$id), - lat = db.site.lat.lon(site$id, con = con)$lat, - lon = db.site.lat.lon(site$id, con = con)$lon) + lat = latlon$lat, + lon = latlon$lon) str_ns <- paste0(new.site$id %/% 1e+09, "-", new.site$id %% 1e+09) if (is.null(format.vars$lat)) { @@ -401,27 +402,6 @@ met.process <- function(site, input_met, start_date, end_date, model, return(input_met) # Returns an updated $met entry for the settings object. } # met.process -################################################################################################################################# - -##' Look up lat/lon from siteid -##' -##' @export -##' @param site.id BeTY ID of site to look up -##' @param con database connection -##' @author Betsy Cowdery -db.site.lat.lon <- function(site.id, con) { - site <- PEcAn.DB::db.query(paste("SELECT id, ST_X(ST_CENTROID(geometry)) AS lon, ST_Y(ST_CENTROID(geometry)) AS lat FROM sites WHERE id =", - site.id), con) - if (nrow(site) == 0) { - PEcAn.logger::logger.error("Site not found") - return(NULL) - } - if (!(is.na(site$lat)) && !(is.na(site$lat))) { - return(list(lat = site$lat, lon = site$lon)) - } else { - PEcAn.logger::logger.severe("We should not be here!") - } -} # db.site.lat.lon ################################################################################################################################# diff --git a/modules/data.atmosphere/man/db.site.lat.lon.Rd b/modules/data.atmosphere/man/db.site.lat.lon.Rd deleted file mode 100644 index 9a2cfed78f9..00000000000 --- a/modules/data.atmosphere/man/db.site.lat.lon.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/met.process.R -\name{db.site.lat.lon} -\alias{db.site.lat.lon} -\title{Look up lat/lon from siteid} -\usage{ -db.site.lat.lon(site.id, con) -} -\arguments{ -\item{site.id}{BeTY ID of site to look up} - -\item{con}{database connection} -} -\description{ -Look up lat/lon from siteid -} -\author{ -Betsy Cowdery -} diff --git a/modules/data.land/inst/LoadPalEONsites.R b/modules/data.land/inst/LoadPalEONsites.R index 9cb07162aab..3c010bc7ccc 100644 --- a/modules/data.land/inst/LoadPalEONsites.R +++ b/modules/data.land/inst/LoadPalEONsites.R @@ -164,10 +164,10 @@ for(i in seq_along(paleon.sitegroups)){ sitename <- db.query(paste0("SELECT sitename from sites where id =",site_id),con) str_ns <- paste0(site_id %/% 1e+09, "-", site_id %% 1e+09) outfile <- paste0("PalEONregional_CF_site_", str_ns) - + latlon <- PEcAn.DB::query.site(site$id, con = con)[c("lat", "lon")] site.info <- rbind(site.info,data.frame(id = site_id, - lat = db.site.lat.lon(site_id, con = con)$lat, - lon = db.site.lat.lon(site_id, con = con)$lon, + lat = latlon$lat, + lon = latlon$lon, str_ns = str_ns, outfile = outfile)) }