Skip to content

Commit

Permalink
and update removing ggsn package dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
eldarrak committed Nov 7, 2023
1 parent b74b3b5 commit e22fa2a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 30 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Depends:
Imports:
bit,
geosphere,
ggsn,
ggmap,
ggplot2,
CircStats,
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ver 0.5.5 Oct 2023
Small (and not affecting the results) bug was corrected in the summary function
# ver 0.5.5 Nov 2023
Small (and not affecting the results) bug was corrected in the summary function; removed dependcy on ggsn, as the package was archived (so scalebar cannot be plotted anymore)

# ver 0.5.4 Sept 2023
Removed dependencies from sp, maptools, rgeos and rgdal
Expand Down
22 changes: 2 additions & 20 deletions R/new_plotting_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,6 @@ get_time_spent_buffer<-function(Result, dates=NULL, percentile=0.5, r=NULL) {
#' @param background if provided will be used as a background. Must be created by \code{link[ggmap]{get_map}}
#' @param plot should function produce a plot?
#' @param save should function save results with \code{\link[ggplot2]{ggsave}}?
#' @param add.scale.bar will add scalebar with the \code{\link[ggsn]{scalebar}}
#' @param scalebar.options options passed to \code{\link[ggsn]{scalebar}}
#' @return list with two parts
#' \item{res_buffers}{spatial buffers for defined probability values}
#' \item{p}{\code{\link[ggplot2]{ggplot}} object}
Expand Down Expand Up @@ -474,7 +472,7 @@ get_time_spent_buffer<-function(Result, dates=NULL, percentile=0.5, r=NULL) {
#'
#' @author Eldar Rakhimberdiev
#' @export plot_util_distr
plot_util_distr<-function(Result, dates=NULL, map.options=NULL, percentiles=c(0.4, 0.6, 0.8), zoom="auto", geom_polygon.options=NULL, save.options=NULL, color.palette=NULL, use.palette=TRUE, background=NULL, plot=TRUE, save=TRUE, add.scale.bar=FALSE, scalebar.options=NULL) {
plot_util_distr<-function(Result, dates=NULL, map.options=NULL, percentiles=c(0.4, 0.6, 0.8), zoom="auto", geom_polygon.options=NULL, save.options=NULL, color.palette=NULL, use.palette=TRUE, background=NULL, plot=TRUE, save=TRUE) {

if (utils::packageVersion('ggmap')[1]<2.7) {stop('plot_util_distr function works only with ggmap >= 2.7.x')}

Expand Down Expand Up @@ -609,22 +607,6 @@ for (percentile in percentiles) {

}
if (plot) print(p)
if (add.scale.bar) {
if (is.null(scalebar.options)) scalebar.options=list()
BB<-attr(background, 'bb')

if (is.null(scalebar.options$dist)) scalebar.options$dist=max(((abs(as.numeric(BB[1, 4])-as.numeric(BB[1, 2]))*100*0.1)%/%25)*25, 25)

scalebar.options$dd2km <- TRUE
scalebar.options$model <- 'WGS84'
if (is.null(scalebar.options$location)) scalebar.options$location <- 'topright'
scalebar.options$y.min=as.numeric(BB[1, 1])+(as.numeric(BB[1, 3])-as.numeric(BB[1, 1]))*0.05
scalebar.options$y.max=as.numeric(BB[1, 3])-(as.numeric(BB[1, 3])-as.numeric(BB[1, 1]))*0.05
scalebar.options$x.min=as.numeric(BB[1, 2])-(as.numeric(BB[1, 2])-as.numeric(BB[1, 4]))*0.05
scalebar.options$x.max=as.numeric(BB[1, 4])+(as.numeric(BB[1, 2])-as.numeric(BB[1, 4]))*0.05

p=p+do.call(ggsn::scalebar, scalebar.options)
}

if (save) {
if (is.null(save.options)) save.options=list()
Expand Down Expand Up @@ -746,4 +728,4 @@ get_utilisation_points<-function(Result, twilights.index, percentile) {
Points_selected<-(1:length(All.Points))[Points]
return(Points_selected)
}


8 changes: 1 addition & 7 deletions man/plot_util_distr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e22fa2a

Please sign in to comment.