Skip to content

Commit

Permalink
locate_site par
Browse files Browse the repository at this point in the history
  • Loading branch information
lucarraro committed Jul 11, 2024
1 parent 47b7c85 commit 8f07de1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Minor changes

- `extract_river`: argument `n_processes` cannot be greater than the number of available cores.
- `locate_site`: call to graphical parameters removed. Exported value `par` is now deprecated (because useless).

# rivnet 0.4.2

Expand Down
7 changes: 3 additions & 4 deletions R/locate_site.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ locate_site <- function(X,Y=NULL,river,
Xnew <- river$RN$X[RNnode]; Ynew <- river$RN$Y[RNnode]

if (showPlot){
oldpar <- par(no.readonly = TRUE)
on.exit(par(oldpar))
#oldpar <- par(no.readonly = TRUE)
#on.exit(par(oldpar))

Xmin <- min(X,Xnew)-20*river$cellsize; Xmax <- max(X,Xnew)+20*river$cellsize;
Ymin <- min(Y,Ynew)-20*river$cellsize; Ymax <- max(Y,Ynew)+20*river$cellsize
Expand All @@ -69,15 +69,14 @@ locate_site <- function(X,Y=NULL,river,
plot(river,theme, discreteLevels = T,
colPalette = colorRampPalette(c("blue2","orange")),
xlim=xlim, ylim=ylim)

xy_lim <- par("usr")

legend(x=xy_lim[1]+river$cellsize, y=xy_lim[4], legend=c("Original site","RN node","AG reach"),
col=c("red","black","orange"), pch=c(15,20,NA),lty=c(0,0,1))
points(X,Y,pch=15,col="red")
points(Xnew,Ynew,pch=20,col="black")

parfig <- par()
parfig <- par() # useless?
}

explist <- vector("list")
Expand Down
7 changes: 3 additions & 4 deletions man/locate_site.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
\alias{locate_site}
\title{Locate site in a river}
\usage{
locate_site(X, Y=NULL, river, euclidean = TRUE, showPlot = FALSE,
locate_site(X, Y = NULL, river, euclidean = TRUE, showPlot = FALSE,
xlim = NULL, ylim = NULL)
}
\description{
Expand All @@ -18,7 +18,7 @@ the longitudinal coordinate of the site. Coordinate values must be given in the
\item{euclidean}{Logical. Should the location of the site in the \code{river} be attributed "as the crow flies"?
If \code{FALSE}, the downstream path from (\code{X}, \code{Y}) is followed until the river network is met.}
\item{showPlot}{Logical. Should a close-up of the relocated site be shown?}
\item{xlim, ylim}{Ranges of x- and y-axis limits for the plot. Only active if \code{showPlots = TRUE}.}
\item{xlim, ylim}{Ranges of x- and y-axis limits for the plot. Only active if \code{showPlot = TRUE}.}
}

\value{
Expand All @@ -30,7 +30,7 @@ that belongs to the river network.}
\item{RNode}{index at the RN level of the relocated site.}
\item{AGode}{index at the AG level of the relocated site.}
\item{par}{List of graphical parameters as produced by a call to \code{\link{par}}
(only if \code{showPlot = TRUE}). This can be used to add features to the existing plot.}
(only if \code{showPlot = TRUE}). This can be used to add features to the existing plot. Deprecated.}
}

\details{
Expand Down Expand Up @@ -60,7 +60,6 @@ and argument \code{breakpoints}).
out1 <- locate_site(X, Y, r, showPlot = TRUE) # as the crow flies
out2 <- locate_site(X, Y, r, showPlot = TRUE, euclidean = FALSE) # follow downstream path

# par(out2$par) # reset graphical parameters before adding new features to the current plot
}

# define X, Y by clicking on the map
Expand Down
Binary file modified src/rivnet.dll
Binary file not shown.

0 comments on commit 8f07de1

Please sign in to comment.