Commit 52e75f99 authored by Alison Beamish's avatar Alison Beamish
Browse files

Ali is working on incorporating Marie's comments

parent 27f173a2
Pipeline #22031 failed with stage
in 14 seconds
......@@ -52,7 +52,6 @@ install.packages("https://cran.r-project.org/src/contrib/Archive/rgdal/rgdal_1.4
```
## 2.2 Install HaSa
HaSa is not yet available as a CRAN package. The user needs to install it directly from its repository. Since versions of certain packages were pinned (c.f., Section 2.1), the user should use `upgrade = FALSE` when calling `remotes::install_git`. In the following example the user can install the `HaSa` R package, build its manual and its vignettes.
```{r install hasa, eval = FALSE, echo = TRUE, results= "hide", message = FALSE}
remotes::install_git("https://git.gfz-potsdam.de/habitat-sampler/HabitatSampler.git",
......@@ -109,7 +108,6 @@ raster::plotRGB(timeseries_stack,r = r,g = g,b = b,stretch = "lin", axes = T)
```
### 3.2.2 - Not-clipped
The following example loads a Sentinel-2 timeseries stack without clipping it to the study area. `TODO`
```{r handling image data, eval = TRUE, results= "hide", message = FALSE}
satellite_series_path <- paste(dataPath,"SentinelStack_2018.tif", sep = "")
......@@ -122,18 +120,19 @@ raster::plotRGB(timeseries_stack,r = r,g = g,b = b,stretch = "lin", axes = T)
```
## 3.3 Selecting reference samples
Reference data from which the spectra of defined classes is extracted and classifiers are trained, can be either passed as a table **3.3.1** or a shapefile **3.3.2**. In the latter the user defines point locations on the extent of the satellite timeseries stack from where the wavelength information should be extracted. Reference data are available in `dataPath`.
Reference samples include spectral information of the defined classes as chosen by the user. Reference data can be either passed as a table **3.3.1** or a shapefile **3.3.2**. Reference samples passed as a table can either be pre-extracted spectral information from an image or spectral information imported from a spectral library. Reference samples passed as a shapefile are point locations defined by the user on the satellite timeseries stack from where the spectral information should be extracted for each class. Sample reference data are available in `dataPath`.
### 3.2.1 Reference table
The table includes spectral information from each class type (rows = classes, columns = spectral wavebands). The first row must contain the spectral wavebands' names, the same names as the ones used in the input Satellite time series stack.
The table includes spectral information from each class type (rows = classes, columns = spectral refelctance). The first row must contain the spectral wavebands, the same names as the ones used in the input satellite time series stack.
```{r reference table, eval = TRUE, results= "hide", message = FALSE}
#load reference table. Each row represents a unique target class.
table_data_path <- paste(dataPath,"Example_Reference_table.txt", sep = "")
ref <- HaSa::load_reference_as_table(table_data_path)
```
Snapshot of the table of reference samples (rows = 7, columns = 54)
```{r ref table header, echo = FALSE, eval = TRUE}
ref[1:5,1:3]
ref[,c(1:3)]
```
### 3.2.2 Reference points
......@@ -182,6 +181,7 @@ HaSa::plot_configuration(
```
### 4.1.2 Define color palette for probability plot
Light grey indicates a low probability and forest green a high probability.
```{r color vector, eval = TRUE}
col <- colorRampPalette(c("lightgrey","orange","yellow","limegreen","forestgreen"))
```
......@@ -191,8 +191,8 @@ Habitat sampling input
```r
HaSa::multi_Class_Sampling(
in.raster = raster_stk, # clipped satellite time series stack [raster brick] (a1)
init.samples = 50, # starting number of spatial samples (recommended value: 30)
in.raster = raster_stk, # clipped satellite time series stack [raster brick]
init.samples = 30, # starting number of spatial samples (recommended value: 30)
sample_type = "regular", # distribution of spatial samples ("random" or "regular";
# suggest: "regular") *See note 1
nb_models = 200, # number of models to collect (recommended value: 200)
......@@ -204,9 +204,9 @@ HaSa::multi_Class_Sampling(
model = "rf", # which machine learning algorithm to use ("rf" random
# forest or "svm" support vector machine;
# recommended input: rf)
mtry = 10, # number of predictor used at random forest splitting nodes
mtry = 10, # number of predictors used at random forest splitting nodes
# (recommended input: mtry << n predictors)
last = F, # only FALSE for one class classifier ("FALSE" or "FALSE";
last = F, # only FALSE for one class classifier ("TRUE" or "FALSE";
# recommended input: "F") *See note 2
seed = 3, # set seed for reproducible results (recommended value: 3)
init.seed = "sample", # "sample" for new or use Run@seeds to reproduce previous
......@@ -218,10 +218,10 @@ HaSa::multi_Class_Sampling(
n_classes = 7, # total number of classes (habitat types) to be separated
multiTest = 1, # number of test runs to compare different probability
# output *See note 4
RGB = c(19,20,21), # pallet colors for the interactive plots
RGB = c(19,20,21), # pallette colors for the interactive plots
overwrite = TRUE, # overwrite the KML and raster files from previous runs
save_runs = FALSE, # an Habitat object is saved into disk for each run (default TRUE)
parallel_mode = FALSE, # run loops using all available cores
parallel_mode = TRUE, # run loops using all available cores
max_num_cores = 4, # maximum number of cores for parallelism (default 5)
plot_on_browser = FALSE # plot on the browser or inline in a notebook (default TRUE)
)
......@@ -230,7 +230,7 @@ HaSa::multi_Class_Sampling(
* **Note 1**: Regular sampling is faster than random
* **Note 2**: The argument `last = T` can be set when only one class should be separated from the background pixels
* **Note 3**: The results from previous steps are reproducible when using the same seed value and `int.seed=Run@seeds` (e.g. Run02@seeds) in consequence, `init.sample` for regular sampling determines an invariant sample distribution, use `random` sampling or vary `init.sample` to get varying sample distributions.
* **Note 4**: If `multiTest > 1` the user will get multiple maps and will be ask to enter the number of the probability distribution that is appropriate.
* **Note 4**: If `multiTest > 1` the user will get multiple maps and will be asked to enter the number of the probability distribution that is appropriate.
Habitat sampling output. R object that contains:
```{r HaSa output, eval = FALSE}
......@@ -260,7 +260,7 @@ If the user chooses to extract the habitat, a user defined threshold is entered
After habitat extraction is done the user can proceed automatically to the next habitat by entering 0 into the R console
2. Sample the habitat type again to produce a better probability map
2. Sample the habitat type again to produce a better probability map. If after visual inspection, the user is not satisfied they can adjust the number of samples and models. It is recommended to first increase the number of models (+50).
If the user chooses to adjust starting number of samples and number of models, the user must enter the sample/model adjustment (../..) into the R console and evaluate the interactive probability maps again.
......
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