forked from NewGraphEnvironment/fpr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated fpr_dbq_clip NewGraphEnvironment#58, updated fpr_create_hydro…
…graph NewGraphEnvironment#60
- Loading branch information
1 parent
fbe62fc
commit 97f9cb6
Showing
6 changed files
with
64 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Clips a point layer by a polygon layer, and returns the clipped point layer containing user specified columns. | ||
#' | ||
#' @param schtab_pnt String (quoted) name of point layer schema.table. | ||
#' @param schtab_pol String (quoted) name of polygon layer schema.table. | ||
#' @param join_column String (quoted) name of column to join tables on from polygon. See column names of any table with \link{fpr_dbq_lscols}. | ||
#' @param schtab_pol_filter String (quoted) or quoted comma seperated vector that defines how the polygon table is filtered, example c("FRAN", "NECR"). | ||
#' @param cols_schtab_pnt String (quoted) or list of column names to select from point layer, default is all columns (*). Must include the geom column if user wants an sf object. | ||
#' | ||
#' @importFrom glue glue | ||
#' @importFrom chk chk_string | ||
#' @family database postgres | ||
#' @return Sf of clipped point layer | ||
#' @export | ||
#' | ||
#' @examples \dontrun{fpr_db_query(query = fpr_dbq_clip('whse_environmental_monitoring.envcan_hydrometric_stn_sp', | ||
#''whse_basemapping.fwa_watershed_groups_poly', 'watershed_group_code', c("FRAN", "NECR")))} | ||
|
||
|
||
fpr_dbq_clip <- function( | ||
schtab_pnt = NULL, | ||
schtab_pol = NULL, | ||
join_column = NULL, | ||
schtab_pol_filter = NULL, | ||
cols_schtab_pnt = '*') { | ||
|
||
chk::chk_string(schtab_pnt) | ||
chk::chk_string(schtab_pol) | ||
chk::chk_string(join_column) | ||
|
||
join_on_str <- paste0("'", schtab_pol_filter, "'", collapse = ", ") | ||
cols_schtab_pnt_str <- paste0("point.", cols_schtab_pnt, collapse = ", ") | ||
|
||
glue::glue("SELECT {cols_schtab_pnt_str}, poly.{join_column} | ||
FROM {schtab_pnt} point | ||
INNER JOIN {schtab_pol} poly | ||
ON ST_Intersects(poly.geom, point.geom) | ||
WHERE poly.{join_column} IN ({join_on_str});") | ||
|
||
} | ||
|
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
man/fpr_create_hydrograph_local.Rd → man/fpr_create_hydrograph.Rd
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.