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