Skip to content

Commit

Permalink
updates for utm zone
Browse files Browse the repository at this point in the history
  • Loading branch information
NewGraphEnvironment committed Sep 20, 2024
1 parent 7e8358c commit dce5eeb
Showing 1 changed file with 39 additions and 20 deletions.
59 changes: 39 additions & 20 deletions scripts/monitoring_build_form.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,39 @@ source('scripts/packages.R')
# import a populated pscis template (habitat_confirmations.xls)
form_prep1 <- fpr::fpr_import_pscis()

# path_write <- 'data/qgis/form_pscis.gpkg'
path_write <- '~/Projects/gis/sern_peace_fwcp_2023/form_monitoring.gpkg'

# import the pscis template with custom test function
form_prep1 <- tfpr_import_pscis_all() |>
bind_rows()

# see the names of the columns
names(form_prep1)

#---------------------------------------define your utm zone ------------------------------------------
utm_zone <- form_prep1 |>
dplyr::filter(!is.na(utm_zone)) |>
pull(utm_zone)

# see the names of the columns
names(form_prep1)

# which utm zone do all the coordinates fall into?
unique(form_prep1$utm_zone)

# name the project directory we are burning to
dir_project <- 'bcfishpass_20230517'
#dir_project <- 'bcfishpass_cown_vict'

# name the form using the date and time
# we should be able to name the form the same in the active project but the files can be versioned
# seems safer...
file_name <- paste0('form_monitor_', format(lubridate::now(), "%Y%m%d"))
# # name the project directory we are burning to
# dir_project <- 'bcfishpass_20230517'
# #dir_project <- 'bcfishpass_cown_vict'
#
# # name the form using the date and time
# # we should be able to name the form the same in the active project but the files can be versioned
# # seems safer...
# file_name <- paste0('form_monitor_', format(lubridate::now(), "%Y%m%d"))

#' define your utm zone. This can cause errors if you use the form in more than
#' one zone!!!!! beware
utm_zone <- 11
#' #' define your utm zone. This can cause errors if you use the form in more than
#' #' one zone!!!!! beware
#' utm_zone <- 11

form_prep2 <- form_prep1 %>%
# example - drop columns that we don't need - there are more
Expand Down Expand Up @@ -113,7 +128,9 @@ form_prep2 <- form_prep1 %>%
photo_extra3_tag = NA_character_,
photo_extra4_tag = NA_character_,

) %>%
) |>
# slice it down so it has only 1 row
dplyr::slice(1) %>%
# make it a spatial file so we can burn it as a geopackage right into our mergin file of choice
# !!!!!this won't work until you rename 'lon' and 'lat' so they are our x and y columns for this dataset (hint: look at the column names)
# don't forget to put it in the right crs too!! - google the crs id for utm zone 9
Expand Down Expand Up @@ -154,14 +171,16 @@ form_prep2 %>%
sf::st_transform(crs = 3005) %>%
# slice it down so it doesn't have any rows
dplyr::slice(1) %>%
# make this filepath whatever - this just backs out two directories and then walks into `gis`.
sf::st_write(paste0('../../gis/',
dir_project,
'/',
file_name,
'.gpkg'),
# turned this T now that we have time in name
delete_layer = T)
# # make this filepath whatever - this just backs out two directories and then walks into `gis`.
# sf::st_write(paste0('../../gis/',
# dir_project,
# '/',
# file_name,
# '.gpkg'),
# # turned this T now that we have time in name
# delete_layer = T)
sf::st_write(path_write, delete_layer = T)




0 comments on commit dce5eeb

Please sign in to comment.