Commit cc836494 authored by De Boissieu Florian's avatar De Boissieu Florian
Browse files

change main functions name to respect standard

parent 2e8d757b
# Generated by roxygen2: do not edit by hand
S3method(split,line)
export(Check.Data.Format)
export(Convert.Raster2BIL)
export(Get.Diversity.From.Plots)
export(Get.List.Shp)
export(Get.Projection)
export(Map.Alpha.Diversity)
export(Map.Beta.Diversity)
export(Map.Spectral.Species)
export(Perform.PCA.Image)
export(Perform.Radiometric.Filtering)
export(Select.Components)
export(check_data)
export(diversity_from_plots)
export(list.shp)
export(map_alpha_div)
export(map_beta_div)
export(projection.file)
export(raster2BIL)
import(raster)
import(tools)
importFrom(dissUtils,diss)
......@@ -23,6 +23,9 @@ importFrom(future.apply,future_lapply)
importFrom(labdsv,pco)
importFrom(matlab,padarray)
importFrom(matrixStats,rowSds)
importFrom(raster,projection)
importFrom(raster,raster)
importFrom(raster,shapefile)
importFrom(raster,writeRaster)
importFrom(rgdal,readOGR)
importFrom(snow,splitRows)
......
......@@ -174,7 +174,7 @@ check_data <- function(Raster.Path, Mask = FALSE) {
message("Current Image format")
print(HDR$interleave)
message("Please run the function named ")
print("Convert.Raster2BIL")
print("raster2BIL")
message("in order to convert your raster data")
message("or use appropriate software")
message("*********************************************************")
......@@ -223,7 +223,7 @@ check_data <- function(Raster.Path, Mask = FALSE) {
message("ENVI hdr file with band interleaved by line (BIL) file format")
message("")
message("Please run the function named ")
print("Convert.Raster2BIL")
print("raster2BIL")
message("in order to convert your raster data")
message("*********************************************************")
message("")
......
......@@ -26,7 +26,7 @@
#' @param Index.Alpha character. Either 'Shannon', 'Simpson' or 'Fisher'.
#'
#' @export
alpha_div <- function(Input.Image.File, Output.Dir, Spatial.Unit,
map_alpha_div <- function(Input.Image.File, Output.Dir, Spatial.Unit,
TypePCA = "SPCA", nbclusters = 50,
MinSun = 0.25, pcelim = 0.02,
Index.Alpha = "Shannon", FullRes = TRUE,
......
......@@ -29,7 +29,7 @@
#' @param pcelim numeric. Minimum contribution (in \%) required for a spectral species
#'
#' @export
Map.Beta.Diversity <- function(Input.Image.File, Output.Dir, Spatial.Unit,
map_beta_div <- function(Input.Image.File, Output.Dir, Spatial.Unit,
TypePCA = "SPCA", nbclusters = 50,
Nb.Units.Ordin = 2000, MinSun = 0.25,
pcelim = 0.02, scaling = "PCO", FullRes = TRUE,
......
......@@ -192,7 +192,7 @@ diversity_from_plots = function(Raster, Plots,NbClusters = 50,Name.Plot = FALSE)
if (file.exists(paste(file_path_sans_ext(File.Vector),'.shp',sep=''))){
Plot = readOGR(Dir.Vector,Name.Vector[[ip]],verbose = FALSE)
# check if vector and rasters are in teh same referential
Projection.Plot = Get.Projection(File.Vector,'vector')
Projection.Plot = projection.file(File.Vector,'vector')
# if not, convert vector file
if (!Projection.Raster==Projection.Plot){
if (!file.exists(File.Vector.reproject)){
......
......@@ -28,10 +28,10 @@
# path (absolute or relative) for the image to process
# expected to be in ENVI HDR format, BIL interleaved
Input.Image.File = system.file('extdata', 'RASTER', 'S2A_T33NUD_20180104_Subset', package = 'biodivMapR')
Check.Data.Format(Input.Image.File)
check_data(Input.Image.File)
# convert the image using Convert.Raster2BIL if not in the proper format
Input.Image.File = Convert.Raster2BIL(Raster.Path = Input.Image.File,
Input.Image.File = raster2BIL(Raster.Path = Input.Image.File,
Sensor = 'SENTINEL_2A',
Convert.Integer = TRUE,
Output.Directory = '~/test')
......@@ -59,7 +59,7 @@ FilterPCA = TRUE
################################################################################
## Check if the image format is compatible with codes (ENVI BIL) ##
################################################################################
Check.Data.Format(Input.Image.File)
check_data(Input.Image.File)
################################################################################
## DEFINE PARAMETERS FOR METHOD ##
......@@ -98,10 +98,10 @@ Map.Spectral.Species(Input.Image.File,Output.Dir,PCA.Files,nbCPU=nbCPU,MaxRAM=Ma
print("MAP ALPHA DIVERSITY")
# Index.Alpha = c('Shannon','Simpson')
Index.Alpha = c('Shannon')
Map.Alpha.Diversity(Input.Image.File,Output.Dir,Spatial.Res,nbCPU=nbCPU,MaxRAM=MaxRAM,Index.Alpha = Index.Alpha)
map_alpha_div(Input.Image.File,Output.Dir,Spatial.Res,nbCPU=nbCPU,MaxRAM=MaxRAM,Index.Alpha = Index.Alpha)
print("MAP BETA DIVERSITY")
Map.Beta.Diversity(Input.Image.File,Output.Dir,Spatial.Res,nbCPU=nbCPU,MaxRAM=MaxRAM)
map_beta_div(Input.Image.File,Output.Dir,Spatial.Res,nbCPU=nbCPU,MaxRAM=MaxRAM)
################################################################################
## COMPUTE ALPHA AND BETA DIVERSITY FROM FIELD PLOTS ##
......@@ -118,15 +118,15 @@ vect = system.file('extdata', 'VECTOR', package = 'biodivMapR')
Shannon.All = list()
# list vector data
Path.Vector = Get.List.Shp(vect)
Path.Vector = list.shp(vect)
Name.Vector = tools::file_path_sans_ext(basename(Path.Vector))
# read raster data including projection
RasterStack = stack(Path.Raster)
Projection.Raster = Get.Projection(Path.Raster,'raster')
Projection.Raster = projection.file(Path.Raster,'raster')
# get alpha and beta diversity indicators corresponding to shapefiles
Biodiv.Indicators = Get.Diversity.From.Plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters)
Biodiv.Indicators = diversity_from_plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters)
# if no name
Biodiv.Indicators$Name.Plot = seq(1,length(Biodiv.Indicators$Shannon[[1]]),by = 1)
Shannon.RS = c(Biodiv.Indicators$Shannon)[[1]]
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_CheckConvertData.R
\name{Check.Data.Format}
\alias{Check.Data.Format}
\name{check_data}
\alias{check_data}
\title{Checks if the data to be processed has the format type expected}
\usage{
Check.Data.Format(Raster.Path, Mask = FALSE)
check_data(Raster.Path, Mask = FALSE)
}
\arguments{
\item{Raster.Path}{full path for the raster to be converted}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_Validation_biodivMapR.R
\name{Get.Diversity.From.Plots}
\alias{Get.Diversity.From.Plots}
\name{diversity_from_plots}
\alias{diversity_from_plots}
\title{gets alpha diversity indicators from plot}
\usage{
Get.Diversity.From.Plots(Raster, Plots, NbClusters = 50,
Name.Plot = FALSE)
diversity_from_plots(Raster, Plots, NbClusters = 50, Name.Plot = FALSE)
}
\arguments{
\item{Raster}{SpectralSpecies file computed from DiverstyMapping method}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_Validation_biodivMapR.R
\name{Get.List.Shp}
\alias{Get.List.Shp}
\name{list.shp}
\alias{list.shp}
\title{Get list of shapefiles in a directory}
\usage{
Get.List.Shp(Path.Shp)
list.shp(x)
}
\arguments{
\item{Path.Shp}{path of the directory containing shapefiles}
\item{x}{character or list. Directory containing shapefiles}
}
\value{
list of shapefiles names
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_MapAlphaDiversity.R
\name{Map.Alpha.Diversity}
\alias{Map.Alpha.Diversity}
\name{map_alpha_div}
\alias{map_alpha_div}
\title{maps alpha diversity indicators based on prior selection of PCs}
\usage{
Map.Alpha.Diversity(Input.Image.File, Output.Dir, Spatial.Unit,
map_alpha_div(Input.Image.File, Output.Dir, Spatial.Unit,
TypePCA = "SPCA", nbclusters = 50, MinSun = 0.25, pcelim = 0.02,
Index.Alpha = "Shannon", FullRes = TRUE, LowRes = FALSE,
MapSTD = FALSE, nbCPU = FALSE, MaxRAM = FALSE)
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_MapBetaDiversity.R
\name{Map.Beta.Diversity}
\alias{Map.Beta.Diversity}
\name{map_beta_div}
\alias{map_beta_div}
\title{maps beta diversity indicator based on spectral species distribution}
\usage{
Map.Beta.Diversity(Input.Image.File, Output.Dir, Spatial.Unit,
map_beta_div(Input.Image.File, Output.Dir, Spatial.Unit,
TypePCA = "SPCA", nbclusters = 50, Nb.Units.Ordin = 2000,
MinSun = 0.25, pcelim = 0.02, scaling = "PCO", FullRes = TRUE,
LowRes = FALSE, nbCPU = 1, MaxRAM = 0.25)
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_Validation_biodivMapR.R
\name{Get.Projection}
\alias{Get.Projection}
\name{projection.file}
\alias{projection.file}
\title{get projection of a raster or a vector}
\usage{
Get.Projection(Path.File, Type = "raster")
projection.file(file, type = "raster")
}
\arguments{
\item{Path.File}{path for a raster or vector (shapefile)}
\item{file}{path for a raster or vector (shapefile)}
\item{Type}{'raster' or 'vector'}
\item{type}{'raster' or 'vector'}
}
\value{
projection
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_CheckConvertData.R
\name{Convert.Raster2BIL}
\alias{Convert.Raster2BIL}
\name{raster2BIL}
\alias{raster2BIL}
\title{converts a raster into BIL format as expected by DivMapping codes}
\usage{
Convert.Raster2BIL(Raster.Path, Sensor = "unknown",
Output.Directory = FALSE, Convert.Integer = TRUE,
Multiplying.Factor = 1, Multiplying.Factor.Last = 1)
raster2BIL(Raster.Path, Sensor = "unknown", Output.Directory = FALSE,
Convert.Integer = TRUE, Multiplying.Factor = 1,
Multiplying.Factor.Last = 1)
}
\arguments{
\item{Raster.Path}{character. Full path for the raster to be converted}
......
......@@ -49,9 +49,9 @@ The output directory defined with `Output.Dir` will contain all the results. For
```{r Input / Output files}
Input.Image.File = system.file('extdata', 'RASTER', 'S2A_T33NUD_20180104_Subset', package = 'biodivMapR')
Check.Data.Format(Input.Image.File)
check_data(Input.Image.File)
Input.Image.File = Convert.Raster2BIL(Raster.Path = Input.Image.File,
Input.Image.File = raster2BIL(Raster.Path = Input.Image.File,
Sensor = 'SENTINEL_2A',
Convert.Integer = TRUE,
Output.Directory = '~/test')
......@@ -136,11 +136,11 @@ Map.Spectral.Species(Input.Image.File, Output.Dir, PCA.Files,
print("MAP ALPHA DIVERSITY")
# Index.Alpha = c('Shannon','Simpson')
Index.Alpha = c('Shannon')
Map.Alpha.Diversity(Input.Image.File, Output.Dir, Spatial.Res,
map_alpha_div(Input.Image.File, Output.Dir, Spatial.Res,
nbCPU = nbCPU, MaxRAM = MaxRAM, Index.Alpha = Index.Alpha)
print("MAP BETA DIVERSITY")
Map.Beta.Diversity(Input.Image.File, Output.Dir, Spatial.Res,
map_beta_div(Input.Image.File, Output.Dir, Spatial.Res,
nbCPU = nbCPU, MaxRAM = MaxRAM)
```
......@@ -159,15 +159,15 @@ vect = system.file('extdata', 'VECTOR', package = 'biodivMapR')
Shannon.All = list() # ??
# list vector data
Path.Vector = Get.List.Shp(vect)
Path.Vector = list.shp(vect)
Name.Vector = tools::file_path_sans_ext(basename(Path.Vector))
# read raster data including projection
RasterStack = stack(Path.Raster)
Projection.Raster = Get.Projection(Path.Raster,'raster')
Projection.Raster = projection.file(Path.Raster,'raster')
# get alpha and beta diversity indicators corresponding to shapefiles
Biodiv.Indicators = Get.Diversity.From.Plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters)
Biodiv.Indicators = diversity_from_plots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters)
# if no name
Biodiv.Indicators$Name.Plot = seq(1,length(Biodiv.Indicators$Shannon[[1]]),by = 1)
Shannon.RS = c(Biodiv.Indicators$Shannon)[[1]]
......
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