Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Feret Jean-Baptiste
biodivMapR
Commits
cc836494
Commit
cc836494
authored
Jul 06, 2019
by
De Boissieu Florian
Browse files
change main functions name to respect standard
parent
2e8d757b
Changes
14
Hide whitespace changes
Inline
Side-by-side
NAMESPACE
View file @
cc836494
# 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)
...
...
R/Lib_CheckConvertData.R
View file @
cc836494
...
...
@@ -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.R
aster2BIL"
)
print
(
"
r
aster2BIL"
)
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.R
aster2BIL"
)
print
(
"
r
aster2BIL"
)
message
(
"in order to convert your raster data"
)
message
(
"*********************************************************"
)
message
(
""
)
...
...
R/Lib_MapAlphaDiversity.R
View file @
cc836494
...
...
@@ -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
,
...
...
R/Lib_MapBetaDiversity.R
View file @
cc836494
...
...
@@ -29,7 +29,7 @@
#' @param pcelim numeric. Minimum contribution (in \%) required for a spectral species
#'
#' @export
M
ap
.B
eta
.Diversity
<-
function
(
Input.Image.File
,
Output.Dir
,
Spatial.Unit
,
m
ap
_b
eta
_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
,
...
...
R/Lib_Validation_biodivMapR.R
View file @
cc836494
...
...
@@ -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.P
rojection
(
File.Vector
,
'vector'
)
Projection.Plot
=
p
rojection
.file
(
File.Vector
,
'vector'
)
# if not, convert vector file
if
(
!
Projection.Raster
==
Projection.Plot
){
if
(
!
file.exists
(
File.Vector.reproject
)){
...
...
examples/example_script.R
View file @
cc836494
...
...
@@ -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'
)
C
heck
.D
ata
.Format
(
Input.Image.File
)
c
heck
_d
ata
(
Input.Image.File
)
# convert the image using Convert.Raster2BIL if not in the proper format
Input.Image.File
=
Convert.R
aster2BIL
(
Raster.Path
=
Input.Image.File
,
Input.Image.File
=
r
aster2BIL
(
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) ##
################################################################################
C
heck
.D
ata
.Format
(
Input.Image.File
)
c
heck
_d
ata
(
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'
)
M
ap
.A
lpha
.Diversity
(
Input.Image.File
,
Output.Dir
,
Spatial.Res
,
nbCPU
=
nbCPU
,
MaxRAM
=
MaxRAM
,
Index.Alpha
=
Index.Alpha
)
m
ap
_a
lpha
_div
(
Input.Image.File
,
Output.Dir
,
Spatial.Res
,
nbCPU
=
nbCPU
,
MaxRAM
=
MaxRAM
,
Index.Alpha
=
Index.Alpha
)
print
(
"MAP BETA DIVERSITY"
)
M
ap
.B
eta
.Diversity
(
Input.Image.File
,
Output.Dir
,
Spatial.Res
,
nbCPU
=
nbCPU
,
MaxRAM
=
MaxRAM
)
m
ap
_b
eta
_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.L
ist.
S
hp
(
vect
)
Path.Vector
=
l
ist.
s
hp
(
vect
)
Name.Vector
=
tools
::
file_path_sans_ext
(
basename
(
Path.Vector
))
# read raster data including projection
RasterStack
=
stack
(
Path.Raster
)
Projection.Raster
=
Get.P
rojection
(
Path.Raster
,
'raster'
)
Projection.Raster
=
p
rojection
.file
(
Path.Raster
,
'raster'
)
# get alpha and beta diversity indicators corresponding to shapefiles
Biodiv.Indicators
=
Get.D
iversity
.F
rom
.P
lots
(
Raster
=
Path.Raster
,
Plots
=
Path.Vector
,
NbClusters
=
nbclusters
)
Biodiv.Indicators
=
d
iversity
_f
rom
_p
lots
(
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
]]
...
...
man/
C
heck
.D
ata.
Format.
Rd
→
man/
c
heck
_d
ata.Rd
View file @
cc836494
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_CheckConvertData.R
\name{
C
heck
.D
ata
.Format
}
\alias{
C
heck
.D
ata
.Format
}
\name{
c
heck
_d
ata}
\alias{
c
heck
_d
ata}
\title{Checks if the data to be processed has the format type expected}
\usage{
C
heck
.D
ata
.Format
(Raster.Path, Mask = FALSE)
c
heck
_d
ata(Raster.Path, Mask = FALSE)
}
\arguments{
\item{Raster.Path}{full path for the raster to be converted}
...
...
man/
Get.D
iversity
.F
rom
.P
lots.Rd
→
man/
d
iversity
_f
rom
_p
lots.Rd
View file @
cc836494
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_Validation_biodivMapR.R
\name{
Get.D
iversity
.F
rom
.P
lots}
\alias{
Get.D
iversity
.F
rom
.P
lots}
\name{
d
iversity
_f
rom
_p
lots}
\alias{
d
iversity
_f
rom
_p
lots}
\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}
...
...
man/
Get.L
ist.
S
hp.Rd
→
man/
l
ist.
s
hp.Rd
View file @
cc836494
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_Validation_biodivMapR.R
\name{
Get.L
ist.
S
hp}
\alias{
Get.L
ist.
S
hp}
\name{
l
ist.
s
hp}
\alias{
l
ist.
s
hp}
\title{Get list of shapefiles in a directory}
\usage{
Get.L
ist.
S
hp(
Path.Shp
)
l
ist.
s
hp(
x
)
}
\arguments{
\item{
Path.Shp}{path of the d
irectory containing shapefiles}
\item{
x}{character or list. D
irectory containing shapefiles}
}
\value{
list of shapefiles names
...
...
man/
M
ap
.A
lpha
.Diversity
.Rd
→
man/
m
ap
_a
lpha
_div
.Rd
View file @
cc836494
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_MapAlphaDiversity.R
\name{
M
ap
.A
lpha
.Diversity
}
\alias{
M
ap
.A
lpha
.Diversity
}
\name{
m
ap
_a
lpha
_div
}
\alias{
m
ap
_a
lpha
_div
}
\title{maps alpha diversity indicators based on prior selection of PCs}
\usage{
M
ap
.A
lpha
.Diversity
(Input.Image.File, Output.Dir, Spatial.Unit,
m
ap
_a
lpha
_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)
...
...
man/
M
ap
.B
eta
.Diversity
.Rd
→
man/
m
ap
_b
eta
_div
.Rd
View file @
cc836494
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_MapBetaDiversity.R
\name{
M
ap
.B
eta
.Diversity
}
\alias{
M
ap
.B
eta
.Diversity
}
\name{
m
ap
_b
eta
_div
}
\alias{
m
ap
_b
eta
_div
}
\title{maps beta diversity indicator based on spectral species distribution}
\usage{
M
ap
.B
eta
.Diversity
(Input.Image.File, Output.Dir, Spatial.Unit,
m
ap
_b
eta
_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)
...
...
man/
Get.P
rojection.Rd
→
man/
p
rojection.
file.
Rd
View file @
cc836494
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_Validation_biodivMapR.R
\name{
Get.P
rojection}
\alias{
Get.P
rojection}
\name{
p
rojection
.file
}
\alias{
p
rojection
.file
}
\title{get projection of a raster or a vector}
\usage{
Get.P
rojection
(Path.F
ile,
T
ype = "raster")
p
rojection
.file(f
ile,
t
ype = "raster")
}
\arguments{
\item{
Path.F
ile}{path for a raster or vector (shapefile)}
\item{
f
ile}{path for a raster or vector (shapefile)}
\item{
T
ype}{'raster' or 'vector'}
\item{
t
ype}{'raster' or 'vector'}
}
\value{
projection
...
...
man/
Convert.R
aster2BIL.Rd
→
man/
r
aster2BIL.Rd
View file @
cc836494
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Lib_CheckConvertData.R
\name{
Convert.R
aster2BIL}
\alias{
Convert.R
aster2BIL}
\name{
r
aster2BIL}
\alias{
r
aster2BIL}
\title{converts a raster into BIL format as expected by DivMapping codes}
\usage{
Convert.R
aster2BIL(Raster.Path, Sensor = "unknown",
Output.Directory = FALSE, Convert.Integer = TRUE
,
Multiplying.Factor = 1,
Multiplying.Factor.Last = 1)
r
aster2BIL(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}
...
...
vignettes/tutorial.Rmd
View file @
cc836494
...
...
@@ -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')
C
heck
.D
ata
.Format
(Input.Image.File)
c
heck
_d
ata(Input.Image.File)
Input.Image.File =
Convert.R
aster2BIL(Raster.Path = Input.Image.File,
Input.Image.File =
r
aster2BIL(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')
M
ap
.A
lpha
.Diversity
(Input.Image.File, Output.Dir, Spatial.Res,
m
ap
_a
lpha
_div
(Input.Image.File, Output.Dir, Spatial.Res,
nbCPU = nbCPU, MaxRAM = MaxRAM, Index.Alpha = Index.Alpha)
print("MAP BETA DIVERSITY")
M
ap
.B
eta
.Diversity
(Input.Image.File, Output.Dir, Spatial.Res,
m
ap
_b
eta
_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.L
ist.
S
hp(vect)
Path.Vector =
l
ist.
s
hp(vect)
Name.Vector = tools::file_path_sans_ext(basename(Path.Vector))
# read raster data including projection
RasterStack = stack(Path.Raster)
Projection.Raster =
Get.P
rojection(Path.Raster,'raster')
Projection.Raster =
p
rojection
.file
(Path.Raster,'raster')
# get alpha and beta diversity indicators corresponding to shapefiles
Biodiv.Indicators =
Get.D
iversity
.F
rom
.P
lots(Raster = Path.Raster, Plots = Path.Vector,NbClusters = nbclusters)
Biodiv.Indicators =
d
iversity
_f
rom
_p
lots(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]]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment