Commit fdbabf2b authored by Monnet Jean-Matthieu's avatar Monnet Jean-Matthieu

Minor modifications in description, changed add argument in plotTreeInventory

parent 09ba727e
Package: lidaRtRee
Type: Package
Version: 3.0.0
Version: 3.0.1
Title: Forest Analysis with Airborne Laser Scanning (Lidar) Data
Date: 2021-01-26
Date: 2021-02-10
Author: Jean-Matthieu Monnet [aut, cre]
Maintainer: Jean-Matthieu Monnet <jean-matthieu.monnet@inrae.fr>
Description: Provides functions for forest analysis using airborne laser scanning data: tree segmentation and area-based approach. It includes complementary steps for foret mapping: extraction of both physical and statistical features from lidar data, model calibration with ground reference, and maps export.
Description: Provides functions for forest analysis using airborne laser scanning (lidar remote sensing) data: tree detection / segmentation and area-based approach. It includes complementary steps for forest mapping: extraction of both physical (gaps, edges, trees) and statistical features from lidar data, model calibration with ground reference, and maps export.
URL: https://gitlab.irstea.fr/jean-matthieu.monnet/lidaRtRee
BugReports: https://gitlab.irstea.fr/jean-matthieu.monnet/lidaRtRee/issues
Depends: R (>= 3.5.0)
......
......@@ -295,8 +295,7 @@ speciesColor <- function()
#' @param xy data.frame. contains two columns with the X, Y coordinates of tree centers
#' @param height vector. tree heights in meters
#' @param diam vector. tree diameters in centimeters
#' @param species vector. species abreviation as in \code{\link{speciesColor}} for display with corresponding color
#' @param add boolean. wether display should be added to an existing plot
#' @param species vector. species abbreviation as in \code{\link{speciesColor}} for display with corresponding color
#' @param ... Arguments to be passed to methods, as in \code{\link[graphics]{plot}}
#' @seealso \code{\link{speciesColor}} for a table of species and associated colors
#' @examples
......@@ -311,10 +310,11 @@ speciesColor <- function()
#' @return no return
#' @export
#'
plotTreeInventory <-function(xy, height=NULL, diam=NULL, species=NULL, add=FALSE, ...)
plotTreeInventory <-function(xy, height=NULL, diam=NULL, species=NULL, ...)
{
# retrieve dots
dots <- list(...)
if (!methods::hasArg("add")) dots$add <- FALSE
# set size of symbol
# proportional to height if present
if(!is.null(height))
......@@ -343,12 +343,13 @@ plotTreeInventory <-function(xy, height=NULL, diam=NULL, species=NULL, add=FALSE
}
}
#
if (add==FALSE)
if (dots$add==FALSE)
{
#grDevices::dev.new(height=2.5,width=2.5)
graphics::par(mar=c(2.5,2.5,0.5,0.5))
args <- list(x = xy[,1], y = xy[,2],cex=size,xlab="NA",ylab="NA",yaxt="n",xaxt="n",asp=1)
# call plot with those arguments and those in dots
# call plot with those arguments and those in dots except "add"
dots$add <- NULL
do.call(plot, c(args, dots))
graphics::axis(2,mgp=c(0.5,0.5,0))
graphics::axis(1,mgp=c(0.5,0.5,0))
......@@ -356,7 +357,8 @@ plotTreeInventory <-function(xy, height=NULL, diam=NULL, species=NULL, add=FALSE
graphics:: mtext(side=1,text="Northing (m)",line=1.3)
} else {
args <- list(x = xy[,1], y = xy[,2],cex=size)
# call plot with those arguments and those in dots
# call plot with those arguments and those in dots except "add"
dots$add <- NULL
do.call(graphics::points, c(args, dots))
}
# add color legend
......@@ -578,3 +580,30 @@ pointList2SPDF <- function(points.list, df=NULL, crs.info=sp::CRS(as.character(N
sp.H
}
}
##########################################################
# # plot tree inventory with ggplot2
# # # charger donnees chablais3
# data(treeinventorychablais3, package = "lidaRtRee")
# ggplot(treeinventorychablais3, aes(x = x, y = y, group = s)) +
# geom_point(aes(color = s, size = d / 20)) +
# coord_sf(datum = 2154)
# #
# # avec couleur personnalisée
# # charger la table de reference
# table.especes <- lidaRtRee::speciesColor()
# # extraire de la table les couleurs
# # correspondant aux especes presentes sur la placette
# table.placette <-
# table.especes[levels(treeinventorychablais3$s), "col"]
#
# ggplot(treeinventorychablais3, aes(x = x, y = y, group = s)) +
# geom_point(aes(color = s, size = d)) +
# coord_sf(datum = 2154) +
# scale_color_manual(values = table.placette) +
# scale_radius(name="Diamètre") + # taille de symbole proportionnelle au diamètre
# geom_text(aes(label=n, size=20), hjust=0, vjust=1) +
# labs(color = "Essence") # titre de la légende
# # table.especes[levels(treeinventorychablais3$s), "col"]
#
# # comparer le résultat avec ceci (éviter les surprises de permutation des lignes)
# lidaRtRee::plotTreeInventory(treeinventorychablais3[,1:2], diam = treeinventorychablais3$d, species=treeinventorychablais3$s)
\ No newline at end of file
......@@ -4,8 +4,8 @@
#'
#' @details Additional information about the data
#' \itemize{
#' \item{Sensor: RIEGL LMS-Q560) \code{lidR::sensor(laschablais3, h = TRUE)}}
#' \item{EPSG code of coordinates system: 2154 \code{sp::proj4string(laschablais3) <- sp::CRS(SRS_string = "EPSG:2154")}}
#' \item{Sensor: RIEGL LMS-Q560)}
#' \item{EPSG code of coordinates system: 2154}
#'}
#'
#' @docType data
......
......@@ -187,7 +187,7 @@ stdTreeMetrics <- function(x, area.ha = NA)
#' }
#' values are computed after fitting a plane to the points. It supposes a homogeneous sampling of the plot by points
#'
#' @param p matrix or data.frame. point coordinates (X, Y , Z)
#' @param p matrix, data.frame or \code{\link[lidR]{LAS}} object with ground point coordinates (X, Y , Z)
#' @param centre vector. x y coordinates of center to extract points inside a disc
#' @param r numeric. radius of disc
#' @return a data.frame with altitude, exposition (gr), slope (gr) and adjR2 of plane fitting
......@@ -202,9 +202,10 @@ stdTreeMetrics <- function(x, area.ha = NA)
#'
points2terrainStats <- function(p, centre=NULL, r=NULL)
{
# rename columns
names(p) <- c("X", "Y", "Z")
# extract points inside disc information is provided
# if LAS object, extract coordinates
if (inherits(p,"LAS")) p <- p@data[,c("X", "Y", "Z")]
else names(p) <- c("X", "Y", "Z") # rename columns
# extract points inside disc if information is provided
if (!is.null(r) & !is.null(centre))
{
p <- p[(p$X-as.numeric(centre[1]))^2+(p$Y-as.numeric(centre[2]))^2<=r^2,]
......@@ -221,7 +222,7 @@ points2terrainStats <- function(p, centre=NULL, r=NULL)
c <- modlin$coefficients[3]
# compute slope
slope <- atan(sqrt(b^2+c^2))*400/(2*pi)
# compute azimut if slope is not zero
# compute azimuth if slope is not zero
if (abs(slope)>0)
{
azimut <- ((pi/2-atan2(c,b))*400/(2*pi)+200)%%400
......
......@@ -226,10 +226,11 @@ histDetection <- function(lr, ld, matched, plot=TRUE)
#' @param breaks vector. breaks for histogram bins
#' @param col vector. colors for each category
#' @param breaksFun function for breaks display
#' @param ... arguments to be passed to methods, as in \code{\link[graphics]{plot}}
#' @return no return
#' @export
#'
histStack <- function(x, breaks, col=NULL, breaksFun=paste)
histStack <- function(x, breaks, col=NULL, breaksFun=paste, ...)
{
if(!is.list(x))
stop("'x' must be a list.")
......@@ -299,7 +300,7 @@ heightRegression <-function(lr, ld, matched, plot=T, species=NULL, limits=NULL)
# grDevices::dev.new(height=2.5,width=2.5)
graphics::par(mar=c(2.5,2.5,0.5,0.5))
if (is.null(limits)) {limits <- c(0,40)}#range(c(app$Hm,app$Hl)).*c(0.9,1.1)
graphics::plot(app$Hl,app$Hm,xlim=limits,ylim=limits,pch=4,cex=0.6,col=col1$col,xlab="NA",ylab="NA",yaxt="n",xaxt="n")
graphics::plot(app$Hl,app$Hm,xlim=limits,ylim=limits,pch=4,cex=0.6,col=col1$col,xlab="NA",ylab="NA",yaxt="n",xaxt="n", asp=1)
graphics::axis(2,mgp=c(0.5,0.5,0))
graphics::axis(1,mgp=c(0.5,0.5,0))
graphics::mtext(side=2,text="Reference height (m)",line=1.3)
......
......@@ -4,7 +4,7 @@
\alias{histStack}
\title{Stacked histogramm}
\usage{
histStack(x, breaks, col = NULL, breaksFun = paste)
histStack(x, breaks, col = NULL, breaksFun = paste, ...)
}
\arguments{
\item{x}{list of vectors. values for each category}
......@@ -14,6 +14,8 @@ histStack(x, breaks, col = NULL, breaksFun = paste)
\item{col}{vector. colors for each category}
\item{breaksFun}{function for breaks display}
\item{...}{arguments to be passed to methods, as in \code{\link[graphics]{plot}}}
}
\value{
no return
......
......@@ -19,8 +19,8 @@ Airborne laser scanning data over the Chablais 3 plot, acquired in 2009 by Sinte
\details{
Additional information about the data
\itemize{
\item{Sensor: RIEGL LMS-Q560) \code{lidR::sensor(laschablais3, h = TRUE)}}
\item{EPSG code of coordinates system: 2154 \code{sp::proj4string(laschablais3) <- sp::CRS(SRS_string = "EPSG:2154")}}
\item{Sensor: RIEGL LMS-Q560)}
\item{EPSG code of coordinates system: 2154}
}
}
\examples{
......
......@@ -4,14 +4,7 @@
\alias{plotTreeInventory}
\title{Displays a map of tree inventory data}
\usage{
plotTreeInventory(
xy,
height = NULL,
diam = NULL,
species = NULL,
add = FALSE,
...
)
plotTreeInventory(xy, height = NULL, diam = NULL, species = NULL, ...)
}
\arguments{
\item{xy}{data.frame. contains two columns with the X, Y coordinates of tree centers}
......@@ -20,9 +13,7 @@ plotTreeInventory(
\item{diam}{vector. tree diameters in centimeters}
\item{species}{vector. species abreviation as in \code{\link{speciesColor}} for display with corresponding color}
\item{add}{boolean. wether display should be added to an existing plot}
\item{species}{vector. species abbreviation as in \code{\link{speciesColor}} for display with corresponding color}
\item{...}{Arguments to be passed to methods, as in \code{\link[graphics]{plot}}}
}
......
......@@ -7,7 +7,7 @@
points2terrainStats(p, centre = NULL, r = NULL)
}
\arguments{
\item{p}{matrix or data.frame. point coordinates (X, Y , Z)}
\item{p}{matrix, data.frame or \code{\link[lidR]{LAS}} object with ground point coordinates (X, Y , Z)}
\item{centre}{vector. x y coordinates of center to extract points inside a disc}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment