diff --git a/.Rbuildignore b/.Rbuildignore index 2227617..305ab98 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,4 +1,6 @@ ^\.git$ ^\.travis\.yml$ ^shiny$ -^examples$ \ No newline at end of file +^examples$ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.gitignore b/.gitignore index ad8f404..f7d30e3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ *.so shiny/database/ shiny/testing/ -shiny/global_coverage.png \ No newline at end of file +shiny/global_coverage.png +.Rproj.user +*.Rproj \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8258d9d..21d4885 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,6 +45,43 @@ r_packages: - mapdata - TMB +cache: packages + +sudo: required + +dist: trusty + +addons: + postgresql: "9.6" + +before_install: + - sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes + - sudo apt-get --yes --force-yes update -qq + - sudo apt-get install --yes libudunits2-dev libproj-dev libgeos-dev libgdal-dev + - # install postgis from source: + - sudo apt-get --yes install libjson-c-dev postgresql-server-dev-9.6 + - wget http://download.osgeo.org/postgis/source/postgis-2.3.2.tar.gz + - (mv postgis* /tmp; cd /tmp; tar xzf postgis-2.3.2.tar.gz) + - (cd /tmp/postgis-2.3.2 ; ./configure; make; sudo make install) + - # activate liblwgeom: + - sudo ldconfig + - # create postgis databases: + - sudo service postgresql restart + - createdb postgis + - psql -d postgis -c "CREATE EXTENSION postgis;" + - psql -d postgis -c "GRANT CREATE ON DATABASE postgis TO travis" + - createdb empty + - psql -d empty -c "CREATE EXTENSION postgis;" + +warnings_are_errors: true + +after_success: + - dropdb postgis + - createdb postgis + - psql -d postgis -c "CREATE EXTENSION postgis;" + - psql -d postgis -c "GRANT CREATE ON DATABASE postgis TO travis" + - Rscript -e 'covr::codecov()' + r_github_packages: - kaskr/TMB_contrib_R/TMBhelper diff --git a/DESCRIPTION b/DESCRIPTION index e4c2c98..f91e1f9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,7 +12,7 @@ Description: SpatialDeltaGLMM is an R package for implementing a spatial delta- functions and model-comparison tools, and (3) is intended to improve analysis speed, replicability, peer-review, and interpretation of index standardization. methods -Imports: +Imports: graphics, utils, mapproj, @@ -31,17 +31,21 @@ Imports: maps, mapdata, TMB, - MatrixModels -Depends: + MatrixModels , + dplyr, + purrr, + sf, + rgdal +Depends: R (>= 3.1.0), -Suggests: +Suggests: INLA, testthat -Additional_repositories: +Additional_repositories: https://www.math.ntnu.no/inla/R/stable License: GPL-2 LazyData: yes BuildVignettes: yes -RoxygenNote: 5.0.1 +RoxygenNote: 6.0.1 URL: http://github.com/nwfsc-assess/geostatistical_delta-GLMM BugReports: http://github.com/nwfsc-assess/geostatistical_delta-GLMM/issues diff --git a/NAMESPACE b/NAMESPACE index 129773f..412f725 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -36,6 +36,7 @@ export(Spatial_Information_Fn) export(Summarize) export(Vessel_Fn) export(bilinear_interp) +export(convert_utm_to_ll_fn) export(match_strata_fn) export(plot_residuals) export(summary_nwfsc) diff --git a/R/Spatial_Information_Fn.R b/R/Spatial_Information_Fn.R index a1cea41..1382b3c 100644 --- a/R/Spatial_Information_Fn.R +++ b/R/Spatial_Information_Fn.R @@ -1,4 +1,6 @@ + + #' Build objects related to spatial information #' #' \code{Spatial_Information_Fn} builds a tagged list with all the spatial information needed for \code{Data_Fn} @@ -17,78 +19,174 @@ #' \item{MeshList}{A tagged list with inputs related to the SPDE mesh} #' \item{GridList}{A tagged list with inputs related to the 2D AR1 grid} #' \item{a_xl}{A data frame with areas for each knot and each strattum} -#' \item{loc_UTM}{A data frame with the converted UTM coordinates for each sample} +#' \item{loc_x}{The UTM location for each knot} +#' \item{loc_x_lat_long}{A data frame with the corrected lat long for each knot} #' \item{Kmeans}{Output from \code{Calc_Kmeans} with knots for a triangulated mesh} #' \item{knot_i}{The knot associated with each sample} #' \item{Method}{The Method input (for archival purposes)} -#' \item{loc_x}{The UTM location for each knot} #' } #' @export -Spatial_Information_Fn = function( n_x, Lon, Lat, Extrapolation_List, Method="Mesh", grid_size_km=50, grid_size_LL=1, ... ){ - +Spatial_Information_Fn = function(n_x, + Lon, + Lat, + Extrapolation_List, + Method = "Mesh", + grid_size_km = 50, + grid_size_LL = 1, + ...) { # Convert to an Eastings-Northings coordinate system - if( Method=="Spherical_mesh" ){ - loc_i = data.frame( 'Lon'=Lon, 'Lat'=Lat ) + if (Method == "Spherical_mesh") { + loc_i = data.frame('Lon' = Lon, 'Lat' = Lat) # Bounds for 2D AR1 grid - Grid_bounds = (grid_size_km/110) * apply(Extrapolation_List$Data_Extrap[,c('Lon','Lat')]/(grid_size_km/110), MARGIN=2, FUN=function(vec){trunc(range(vec))+c(0,1)}) + Grid_bounds = (grid_size_km / 110) * apply( + Extrapolation_List$Data_Extrap[, c('Lon', 'Lat')] / (grid_size_km / 110), + MARGIN = 2, + FUN = function(vec) { + trunc(range(vec)) + c(0, 1) + } + ) # Calculate k-means centroids - Kmeans = SpatialDeltaGLMM::Calc_Kmeans(n_x=n_x, loc_orig=loc_i[,c("Lon", "Lat")], ... ) + Kmeans = SpatialDeltaGLMM::Calc_Kmeans(n_x = n_x, loc_orig = loc_i[, c("Lon", "Lat")], ...) # Calculate grid for 2D AR1 process - loc_grid = expand.grid( 'Lon'=seq(Grid_bounds[1,1],Grid_bounds[2,1],by=grid_size_LL), 'Lat'=seq(Grid_bounds[1,2],Grid_bounds[2,2],by=grid_size_LL) ) - Which = sort(unique(RANN::nn2(data=loc_grid, query=Extrapolation_List$Data_Extrap[which(Extrapolation_List$Area_km2_x>0),c('Lon','Lat')], k=1)$nn.idx[,1])) + loc_grid = expand.grid( + 'Lon' = seq(Grid_bounds[1, 1], Grid_bounds[2, 1], by = grid_size_LL), + 'Lat' = seq(Grid_bounds[1, 2], Grid_bounds[2, 2], by = grid_size_LL) + ) + Which = sort(unique( + RANN::nn2( + data = loc_grid, + query = Extrapolation_List$Data_Extrap[which(Extrapolation_List$Area_km2_x > + 0), c('Lon', 'Lat')], + k = 1 + )$nn.idx[, 1] + )) loc_grid = loc_grid[Which,] - grid_num = RANN::nn2( data=loc_grid, query=loc_i, k=1)$nn.idx[,1] + grid_num = RANN::nn2(data = loc_grid, + query = loc_i, + k = 1)$nn.idx[, 1] } - if( Method %in% c("Mesh","Grid") ){ - loc_i = SpatialDeltaGLMM::Convert_LL_to_UTM_Fn( Lon=Lon, Lat=Lat, zone=Extrapolation_List$zone, flip_around_dateline=Extrapolation_List$flip_around_dateline ) #$ - loc_i = cbind( 'E_km'=loc_i[,'X'], 'N_km'=loc_i[,'Y']) + + + if (Method %in% c("Mesh", "Grid")) { + loc_i = SpatialDeltaGLMM::Convert_LL_to_UTM_Fn( + Lon = Lon, + Lat = Lat, + zone = Extrapolation_List$zone, + flip_around_dateline = Extrapolation_List$flip_around_dateline + ) #$ + loc_i = cbind('E_km' = loc_i[, 'X'], 'N_km' = loc_i[, 'Y']) # Bounds for 2D AR1 grid - Grid_bounds = grid_size_km * apply(Extrapolation_List$Data_Extrap[,c('E_km','N_km')]/grid_size_km, MARGIN=2, FUN=function(vec){trunc(range(vec))+c(0,1)}) + Grid_bounds = grid_size_km * apply( + Extrapolation_List$Data_Extrap[, c('E_km', 'N_km')] / grid_size_km, + MARGIN = 2, + FUN = function(vec) { + trunc(range(vec)) + c(0, 1) + } + ) # Calculate k-means centroids - Kmeans = SpatialDeltaGLMM::Calc_Kmeans(n_x=n_x, loc_orig=loc_i[,c("E_km", "N_km")], ... ) + Kmeans = SpatialDeltaGLMM::Calc_Kmeans(n_x = n_x, loc_orig = loc_i[, c("E_km", "N_km")], ...) # Calculate grid for 2D AR1 process - loc_grid = expand.grid( 'E_km'=seq(Grid_bounds[1,1],Grid_bounds[2,1],by=grid_size_km), 'N_km'=seq(Grid_bounds[1,2],Grid_bounds[2,2],by=grid_size_km) ) - Which = sort(unique(RANN::nn2(data=loc_grid, query=Extrapolation_List$Data_Extrap[which(Extrapolation_List$Area_km2_x>0),c('E_km','N_km')], k=1)$nn.idx[,1])) + loc_grid = expand.grid( + 'E_km' = seq(Grid_bounds[1, 1], Grid_bounds[2, 1], by = grid_size_km), + 'N_km' = seq(Grid_bounds[1, 2], Grid_bounds[2, 2], by = grid_size_km) + ) + Which = sort(unique( + RANN::nn2( + data = loc_grid, + query = Extrapolation_List$Data_Extrap[which(Extrapolation_List$Area_km2_x > + 0), c('E_km', 'N_km')], + k = 1 + )$nn.idx[, 1] + )) loc_grid = loc_grid[Which,] - grid_num = RANN::nn2( data=loc_grid, query=loc_i, k=1)$nn.idx[,1] + grid_num = RANN::nn2(data = loc_grid, + query = loc_i, + k = 1)$nn.idx[, 1] } # Calc design matrix and areas - if( Method=="Grid" ){ + if (Method == "Grid") { knot_i = grid_num loc_x = loc_grid } - if( Method %in% c("Mesh","Spherical_mesh") ){ + if (Method %in% c("Mesh", "Spherical_mesh")) { knot_i = Kmeans$cluster loc_x = Kmeans$centers } - PolygonList = Calc_Polygon_Areas_and_Polygons_Fn( loc_x=loc_x, Data_Extrap=Extrapolation_List[["Data_Extrap"]], a_el=Extrapolation_List[["a_el"]]) - a_xl = PolygonList[["a_xl"]] + eastings <- loc_x[, 'E_km'] + + northings <- loc_x[, 'N_km'] + + zone <- Extrapolation_List$zone + + flip_around_dateline <- Extrapolation_List$flip_around_dateline + loc_x_lat_long <- + convert_utm_to_ll_fn( + eastings = eastings, + northings = northings, + zone = zone, + flip_around_dateline = flip_around_dateline + ) + + loc_x_lat_long$knot <- 1:nrow(loc_x_lat_long) + + if (flip_around_dateline == T){ + warning("knots have been flipped around dateline; eastings locations and UTM zone are transformed - see loc_x_lat_long for corrected locations") + } + + PolygonList = Calc_Polygon_Areas_and_Polygons_Fn(loc_x = loc_x, + Data_Extrap = Extrapolation_List[["Data_Extrap"]], + a_el = Extrapolation_List[["a_el"]]) + a_xl = PolygonList[["a_xl"]] # Convert loc_x back to location in lat-long coordinates loc_x_LL # if zone=NA or NULL, then it automatically detects appropriate zone - #tmpUTM = cbind('PID'=1,'POS'=1:nrow(loc_x),'X'=loc_x[,'E_km'],'Y'=loc_x[,'N_km']) - #attr(tmpUTM,"projection") = "UTM" - #attr(tmpUTM,"zone") = Extrapolation_List$zone - #loc_x_LL = PBSmapping::convUL(tmpUTM) #$ + # tmpUTM = cbind('PID'=1,'POS'=1:nrow(loc_x),'X'=loc_x[,'E_km'],'Y'=loc_x[,'N_km']) + # attr(tmpUTM,"projection") = "UTM" + # attr(tmpUTM,"zone") = Extrapolation_List$zone + # loc_x_LL = PBSmapping::convUL(tmpUTM) #$ # Make mesh and info for anisotropy SpatialDeltaGLMM:: - MeshList = Calc_Anisotropic_Mesh( Method=Method, loc_x=Kmeans$centers ) + MeshList = Calc_Anisotropic_Mesh(Method = Method, loc_x = Kmeans$centers) # Make matrices for 2D AR1 process - Dist_grid = dist(loc_grid, diag=TRUE, upper=TRUE) - M0 = as( ifelse(as.matrix(Dist_grid)==0, 1, 0), "dgTMatrix" ) - M1 = as( ifelse(as.matrix(Dist_grid)==grid_size_km, 1, 0), "dgTMatrix" ) - M2 = as( ifelse(as.matrix(Dist_grid)==sqrt(2)*grid_size_km, 1, 0), "dgTMatrix" ) - if( Method=="Spherical_mesh" ) GridList = list("M0"=M0, "M1"=M1, "M2"=M2, "grid_size_km"=grid_size_LL) - if( Method %in% c("Mesh","Grid") ) GridList = list("M0"=M0, "M1"=M1, "M2"=M2, "grid_size_km"=grid_size_km) + Dist_grid = dist(loc_grid, diag = TRUE, upper = TRUE) + M0 = as(ifelse(as.matrix(Dist_grid) == 0, 1, 0), "dgTMatrix") + M1 = as(ifelse(as.matrix(Dist_grid) == grid_size_km, 1, 0), "dgTMatrix") + M2 = as(ifelse(as.matrix(Dist_grid) == sqrt(2) * grid_size_km, 1, 0), "dgTMatrix") + if (Method == "Spherical_mesh") + GridList = list( + "M0" = M0, + "M1" = M1, + "M2" = M2, + "grid_size_km" = grid_size_LL + ) + if (Method %in% c("Mesh", "Grid")) + GridList = list( + "M0" = M0, + "M1" = M1, + "M2" = M2, + "grid_size_km" = grid_size_km + ) # Return - Return = list("MeshList"=MeshList, "GridList"=GridList, "a_xl"=a_xl, "loc_i"=loc_i, "Kmeans"=Kmeans, "knot_i"=knot_i, "Method"=Method, "loc_x"=loc_x, "PolygonList"=PolygonList, "NN_Extrap"=PolygonList$NN_Extrap) - return( Return ) + Return = list( + "MeshList" = MeshList, + "GridList" = GridList, + "a_xl" = a_xl, + "loc_i" = loc_i, + "Kmeans" = Kmeans, + "knot_i" = knot_i, + "Method" = Method, + "loc_x" = loc_x, + "loc_x_lat_long" = loc_x_lat_long, + "PolygonList" = PolygonList, + "NN_Extrap" = PolygonList$NN_Extrap + ) + return(Return) } diff --git a/R/convert_utm_to_ll_fn.R b/R/convert_utm_to_ll_fn.R new file mode 100644 index 0000000..31a5283 --- /dev/null +++ b/R/convert_utm_to_ll_fn.R @@ -0,0 +1,75 @@ +#' Convert from UTM to Lat-long +#' +#' If eastings and northings have been flipped +#' around dateline, will convert back and provide estimtes of "original" lat lon +#' Values should be viewed as estimates for plotting and general pairing +#' +#' @param eastings eastings of points, paired to northings +#' @param northings northings of points, paired to eastings +#' @param zone UTM zone of points +#' @param flip_around_dateline logical stating if points have been flipped around the dateline +#' @param meters_per_utm_unit meters per easting/northing +#' +#' @return a data.frame with +#' \describe{ +#' \item{approx_long}{the approximate transformed longitude of each UTM point} +#' \item{approx_lat}{the approximate transformed latitude of each UTM point} +#' } +#' @export +#' +#' @examples +#' \dontrun{ +#' eastings <- Spatial_List$loc_x[,'E_km'] +#' +#' northings <- Spatial_List$loc_x[,'N_km'] +#' +#' zone <- Extrapolation_List$zone +#' +#' flip_around_dateline <- Extrapolation_List$flip_around_dateline +#' +#' latlongs <- convert_utm_to_ll_fn(eastings = eastings, northings = northings, zone = zone, flip_around_dateline = flip_around_dateline) +#' +#' ggmap::qmplot(x = approx_long, y = approx_lat, data = latlongs, color = 'red') +#' } +convert_utm_to_ll_fn <- + function(eastings, + northings, + zone, + flip_around_dateline = T, + meters_per_utm_unit = 1000) { + require(dplyr) + # on.exit(detach('package:dplyr')) + +if (length(eastings) != length(northings)){ + stop('eastings and northings are not same length, make sure that they represent paired coordinates') +} + + utm_coords <- + data.frame(easting = eastings, northing = northings) %>% + dplyr::mutate(geometry = purrr::map2(eastings, northing, ~ sf::st_point( + x = c(.x * meters_per_utm_unit, .y * meters_per_utm_unit), dim = 'XY' + ))) %>% # assign a spatial geometry to each knot + ungroup() %>% + mutate(geometry = sf::st_sfc(geometry, crs = paste0( + "+proj=utm +zone=", zone + ))) %>% + sf::st_sf() # convert to a sf object in UTM projection for supplied zone + + + ll_coords <- + sf::st_transform(utm_coords, crs = "+proj=longlat") #convert to long-lat projection + + ll_geometry <- sf::st_geometry(ll_coords) + + extract_ll <- function(x) { + data.frame(approx_long = x[1], approx_lat = x[2]) + } + ll_coords <- purrr::map_df(ll_geometry, extract_ll) # extract transformed long/lat for knots + + if (flip_around_dateline == T) { # if UTM coordinates were flipped around deadline, reverse flip + ll_coords <- + dplyr::mutate(ll_coords, approx_long = purrr::map_dbl(approx_long, ~ ifelse(.x > 0, .x - 180, .x + 180))) + } + return(ll_coords) + + } \ No newline at end of file diff --git a/man/Build_TMB_Fn.Rd b/man/Build_TMB_Fn.Rd index 9283058..8ba1e2f 100644 --- a/man/Build_TMB_Fn.Rd +++ b/man/Build_TMB_Fn.Rd @@ -61,4 +61,3 @@ Tagged list containing objects for running a VAST model \description{ \code{Build_TMB_Fn} builds a tagged list with everything necessary to run or interpret inputs to a geostatistical delta-GLMM } - diff --git a/man/Calc_Anisotropic_Mesh.Rd b/man/Calc_Anisotropic_Mesh.Rd index cc434a7..06278d8 100644 --- a/man/Calc_Anisotropic_Mesh.Rd +++ b/man/Calc_Anisotropic_Mesh.Rd @@ -24,4 +24,3 @@ Tagged list containing distance metrics \description{ \code{Calc_Anistropic_Mesh} builds a tagged list representing distances for isotropic or geometric anisotropic triangulated mesh } - diff --git a/man/Calc_Kmeans.Rd b/man/Calc_Kmeans.Rd index 9b65031..028a231 100644 --- a/man/Calc_Kmeans.Rd +++ b/man/Calc_Kmeans.Rd @@ -32,4 +32,3 @@ Tagged list containing outputs \description{ \code{Calc_Kmeans} determines the location for a set of knots for approximating spatial variation } - diff --git a/man/Calc_Polygon_Areas_and_Polygons_Fn.Rd b/man/Calc_Polygon_Areas_and_Polygons_Fn.Rd index 3227591..bc415a9 100644 --- a/man/Calc_Polygon_Areas_and_Polygons_Fn.Rd +++ b/man/Calc_Polygon_Areas_and_Polygons_Fn.Rd @@ -25,4 +25,3 @@ Tagged list containing distance metrics \description{ \code{Calc_Polygon_Areas_and_Polygons_Fn} builds outputs for a given triangulated mesh used for approximating spatial variation } - diff --git a/man/Check_encounter_prob.Rd b/man/Check_encounter_prob.Rd index 6339b7b..73f0dd4 100644 --- a/man/Check_encounter_prob.Rd +++ b/man/Check_encounter_prob.Rd @@ -29,4 +29,3 @@ Return Tagged list of output \description{ \code{Check_encounter_prob} is a diagnostic function for checking validity of the encounter-probability component of a spatio-temporal model } - diff --git a/man/Convert_LL_to_UTM_Fn.Rd b/man/Convert_LL_to_UTM_Fn.Rd index 10e40fc..ffaf360 100644 --- a/man/Convert_LL_to_UTM_Fn.Rd +++ b/man/Convert_LL_to_UTM_Fn.Rd @@ -25,4 +25,3 @@ A data frame with the following columns \description{ \code{Convert_LL_to_UTM_Fn} converts from Latitude-Longitude to Universal Transverse Mercator projections for a given location } - diff --git a/man/Data_Fn.Rd b/man/Data_Fn.Rd index d527f64..6603a6f 100644 --- a/man/Data_Fn.Rd +++ b/man/Data_Fn.Rd @@ -71,4 +71,3 @@ Tagged list containing inputs to function Build_TMB_Fn() \description{ \code{Data_Fn} builds a tagged list of data inputs used by TMB for running the model } - diff --git a/man/Geostat_Sim.Rd b/man/Geostat_Sim.Rd index 2b69abf..33aa82e 100644 --- a/man/Geostat_Sim.Rd +++ b/man/Geostat_Sim.Rd @@ -39,4 +39,3 @@ Return Tagged list of output ## SimList = SpatialDeltaGLMM::Geostat_Sim(Sim_Settings=list(), Extrapolation_List, Data_Geostat=Data_Geostat ) ## Data_Sim = SimList$Data_Geostat } - diff --git a/man/Param_Fn.Rd b/man/Param_Fn.Rd index 8ec293a..085bf9a 100644 --- a/man/Param_Fn.Rd +++ b/man/Param_Fn.Rd @@ -59,4 +59,3 @@ Tagged list containing starting values for all fixed effects (parameters) and ra \description{ \code{Param_Fn} generates the \code{parameters} input for \code{TMB::MakeADFun} } - diff --git a/man/PlotIndex_Fn.Rd b/man/PlotIndex_Fn.Rd index 3eb1b33..8633d5f 100644 --- a/man/PlotIndex_Fn.Rd +++ b/man/PlotIndex_Fn.Rd @@ -8,7 +8,8 @@ PlotIndex_Fn(TmbData, Sdreport, Year_Set = NULL, Years2Include = NULL, DirName = paste0(getwd(), "/"), PlotName = "Index.png", interval_width = 1, strata_names = NULL, category_names = NULL, use_biascorr = FALSE, plot_legend = TRUE, total_area_km2 = NULL, - plot_log = FALSE, width = 4, height = 4, ...) + plot_log = FALSE, width = 4, height = 4, treat_missing_as_zero = TRUE, + ...) } \arguments{ \item{TmbData}{Formatted data inputs, from `SpatialDeltaGLMM::Data_Fn(...)`} @@ -41,6 +42,8 @@ PlotIndex_Fn(TmbData, Sdreport, Year_Set = NULL, Years2Include = NULL, \item{height}{plot height in inches} +\item{treat_missing_as_zero}{Boolean whether to treat years and species with no (or only NA) data as instances where the index should be zero} + \item{...}{Other inputs to `par()`} } \value{ @@ -52,4 +55,3 @@ Return Tagged list of output \description{ \code{PlotIndex_Fn} plots an index proportion to population abundance } - diff --git a/man/PlotMap_Fn.Rd b/man/PlotMap_Fn.Rd index 8303856..ae682d7 100644 --- a/man/PlotMap_Fn.Rd +++ b/man/PlotMap_Fn.Rd @@ -47,4 +47,3 @@ truncating the cocuntry boundaries within the plotting region (which \code{mappr so that the post-projection is often missing boundaries that are within the plotting rectangle). I use rectangular projections by default, but Lamberts or Albers conformal projections would also be useful for many cases. } - diff --git a/man/PlotResultsOnMap_Fn.Rd b/man/PlotResultsOnMap_Fn.Rd index ff82e06..3c33c41 100644 --- a/man/PlotResultsOnMap_Fn.Rd +++ b/man/PlotResultsOnMap_Fn.Rd @@ -65,4 +65,3 @@ Mat_xt a matrix (rows: modeled knots; column: modeled year) for plotted output o \description{ \code{PlotResultsOnMap_Fn} plots a standard set of diagnostic maps } - diff --git a/man/Plot_data_and_knots.Rd b/man/Plot_data_and_knots.Rd index a8a62f2..ff3e503 100644 --- a/man/Plot_data_and_knots.Rd +++ b/man/Plot_data_and_knots.Rd @@ -23,4 +23,3 @@ Plot_data_and_knots(Extrapolation_List, Spatial_List, Data_Geostat, \description{ \code{Plot_data_and_knots} produces diagnostics plots for the spatial distribution of data and knots } - diff --git a/man/Plot_range_shifts.Rd b/man/Plot_range_shifts.Rd index ac4f964..c3f64e6 100644 --- a/man/Plot_range_shifts.Rd +++ b/man/Plot_range_shifts.Rd @@ -49,4 +49,3 @@ Return Tagged list of output \description{ \code{Plot_range_shifts} plots center-of-gravity, kernel-area occupied, and effective-area occupied } - diff --git a/man/Prepare_Extrapolation_Data_Fn.Rd b/man/Prepare_Extrapolation_Data_Fn.Rd index a2737d4..6745574 100644 --- a/man/Prepare_Extrapolation_Data_Fn.Rd +++ b/man/Prepare_Extrapolation_Data_Fn.Rd @@ -29,4 +29,3 @@ Tagged list used in other functions \description{ \code{Prepare_Extrapolation_Data_Fn} builds an object used to determine areas to extrapolation densities to when calculating indices } - diff --git a/man/SpatialDeltaGLMM.Rd b/man/SpatialDeltaGLMM.Rd index 39b0e37..b9c1680 100644 --- a/man/SpatialDeltaGLMM.Rd +++ b/man/SpatialDeltaGLMM.Rd @@ -11,4 +11,3 @@ Spatial delta-generalized linear mixed model (`SpatialDeltaGLMM`) is used for es \details{ Please see examples folder on github \url{http://github.com/nwfsc-assess/geostatistical_delta-GLMM/tree/master/examples} for up-to-date examples } - diff --git a/man/Spatial_Information_Fn.Rd b/man/Spatial_Information_Fn.Rd index a64fab1..d035137 100644 --- a/man/Spatial_Information_Fn.Rd +++ b/man/Spatial_Information_Fn.Rd @@ -30,14 +30,13 @@ Tagged list containing objects for running a VAST model \item{MeshList}{A tagged list with inputs related to the SPDE mesh} \item{GridList}{A tagged list with inputs related to the 2D AR1 grid} \item{a_xl}{A data frame with areas for each knot and each strattum} - \item{loc_UTM}{A data frame with the converted UTM coordinates for each sample} + \item{loc_x}{The UTM location for each knot} + \item{loc_x_lat_long}{A data frame with the corrected lat long for each knot} \item{Kmeans}{Output from \code{Calc_Kmeans} with knots for a triangulated mesh} \item{knot_i}{The knot associated with each sample} \item{Method}{The Method input (for archival purposes)} - \item{loc_x}{The UTM location for each knot} } } \description{ \code{Spatial_Information_Fn} builds a tagged list with all the spatial information needed for \code{Data_Fn} } - diff --git a/man/Summarize.Rd b/man/Summarize.Rd index 14d480c..cbe9915 100644 --- a/man/Summarize.Rd +++ b/man/Summarize.Rd @@ -22,4 +22,3 @@ Tagged list of useful output \details{ Please post on the GitHub issue tracker if you'd like for another specific output to be added and documented here } - diff --git a/man/Vessel_Fn.Rd b/man/Vessel_Fn.Rd index 2a2f3e3..42640df 100644 --- a/man/Vessel_Fn.Rd +++ b/man/Vessel_Fn.Rd @@ -19,4 +19,3 @@ Return Tagged list of output \description{ \code{Vessel_Fn} plots estimated vessel effects for model components } - diff --git a/man/bilinear_interp.Rd b/man/bilinear_interp.Rd index 90c1c59..16dbfcc 100644 --- a/man/bilinear_interp.Rd +++ b/man/bilinear_interp.Rd @@ -32,4 +32,3 @@ Tagged list of useful output # Should equal 1.7 } } - diff --git a/man/convert_utm_to_ll_fn.Rd b/man/convert_utm_to_ll_fn.Rd new file mode 100644 index 0000000..5e7204f --- /dev/null +++ b/man/convert_utm_to_ll_fn.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/convert_utm_to_ll_fn.R +\name{convert_utm_to_ll_fn} +\alias{convert_utm_to_ll_fn} +\title{Convert from UTM to Lat-long} +\usage{ +convert_utm_to_ll_fn(eastings, northings, zone, flip_around_dateline = T, + meters_per_utm_unit = 1000) +} +\arguments{ +\item{eastings}{eastings of points, paired to northings} + +\item{northings}{northings of points, paired to eastings} + +\item{zone}{UTM zone of points} + +\item{flip_around_dateline}{logical stating if points have been flipped around the dateline} + +\item{meters_per_utm_unit}{meters per easting/northing} +} +\value{ +a data.frame with +\describe{ +\item{approx_long}{the approximate transformed longitude of each UTM point} +\item{approx_lat}{the approximate transformed latitude of each UTM point} +} +} +\description{ +If eastings and northings have been flipped +around dateline, will convert back and provide estimtes of "original" lat lon +Values should be viewed as estimates for plotting and general pairing +} +\examples{ +\dontrun{ +eastings <- Spatial_List$loc_x[,'E_km'] + +northings <- Spatial_List$loc_x[,'N_km'] + +zone <- Extrapolation_List$zone + +flip_around_dateline <- Extrapolation_List$flip_around_dateline + +latlongs <- convert_utm_to_ll_fn(eastings = eastings, northings = northings, zone = zone, flip_around_dateline = flip_around_dateline) + +ggmap::qmplot(x = approx_long, y = approx_lat, data = latlongs, color = 'red') +} +} diff --git a/man/plot_residuals.Rd b/man/plot_residuals.Rd index 4fdc00e..4ca47e7 100644 --- a/man/plot_residuals.Rd +++ b/man/plot_residuals.Rd @@ -58,4 +58,3 @@ A tagged list of Pearson residuals \description{ \code{plot_residuals} shows average Pearson residual for every knot for encounter probability and positive catch rate components } - diff --git a/man/smallPlot.Rd b/man/smallPlot.Rd index a691c2b..64bb51d 100644 --- a/man/smallPlot.Rd +++ b/man/smallPlot.Rd @@ -14,4 +14,3 @@ parameters of small plot, invisible. \description{ Inset plot with margins, background and border (based on: https://github.com/cran/berryFunctions/blob/master/R/smallPlot.R) } - diff --git a/man/summary_nwfsc.Rd b/man/summary_nwfsc.Rd index 4f1cae0..66e86b8 100644 --- a/man/summary_nwfsc.Rd +++ b/man/summary_nwfsc.Rd @@ -24,4 +24,3 @@ Tagged list containing objects for running a VAST model \description{ \code{summary_nwfsc} generates output tables requested by the PFMC SSC } -