Skip to content

Commit

Permalink
move functions to data-raw folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlondon committed Aug 6, 2024
1 parent aeb8210 commit deb0f02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions R/get_data.R → data-raw/get_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ library(dbplyr)
library(dplyr)
library(RPostgres)
library(sf)
library(arrow)
library(geoarrow)
library(arrow)
library(arcgis)

get_deployments <- function() {
tryCatch(
Expand Down Expand Up @@ -33,7 +34,7 @@ get_deployments <- function() {
dplyr::left_join(tbl_speno, by = c("speno", "species")) |>
dplyr::collect()

dbDisconnect(con)
DBI::dbDisconnect(con)

return(tbl_deploy)
}
Expand Down Expand Up @@ -66,7 +67,7 @@ get_locations <- function(tbl_deploy = NULL) {
) |>
dplyr::filter(species == "Harbor seal")

dbDisconnect(con)
DBI::dbDisconnect(con)

return(locs_obs)
}
Expand Down Expand Up @@ -97,8 +98,17 @@ get_timelines <- function(tbl_deploy = NULL) {
.default = NA
))

dbDisconnect(con)
DBI::dbDisconnect(con)

return(tbl_timelines)
}

get_survey_units <- function() {
feature_url <- 'https://services2.arcgis.com/C8EMgrsFcRFL6LrL/arcgis/rest/services/pv_cst_polys/FeatureServer'

ssu_sf <- arcgislayers::arc_open(feature_url) |>
arcgislayers::get_layer(0) |>
arcgislayers::arc_select()

return(ssu_sf)
}
2 changes: 2 additions & 0 deletions R/publish_data.R → data-raw/publish_data.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
source('get_data.R')

publish_data <- function() {
deploy <- get_deployments()
locations <- get_locations(deploy)
timelines <- get_timelines(deploy)
ssu <- get_survey_units()

bucket <- gs_bucket("pep_storage", anonymous = FALSE)
fs <- GcsFileSystem$create(anonymous = FALSE)
Expand Down

0 comments on commit deb0f02

Please sign in to comment.