-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
187 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
title: "Converting a raster file to the proper file format" | ||
author: "Jean-Baptiste Féret, Florian de Boissieu" | ||
date: "`r Sys.Date()`" | ||
output: | ||
html_vignette: | ||
number_sections: true | ||
vignette: > | ||
%\VignetteIndexEntry{Tutorial} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
\usepackage[utf8]{inputenc} | ||
--- | ||
|
||
```{r setup, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
eval=FALSE | ||
) | ||
``` | ||
|
||
|
||
__biodivMapR__ expects a specific raster file format as input file, as the package includes dedicated readers and writers. | ||
|
||
* Raster files are expected to be raw flat-binary files. They should not contain any header, which are stored in a separate .hdr file. Hence format such as TIFF are not accepted. | ||
* This binary file should be written following a [Band-interleaved-by-line storage format](https://www.harrisgeospatial.com/docs/enviimagefiles.html "BIL definition"). | ||
* This file should have either `.bil` file extension, or no file extension. | ||
* The header file should be named the same as the binary image file, but with `.hdr` file extension, and should be located in teh same directory. | ||
* the header file should be an ASCII file and follow the [__ENVI file format__](https://www.harrisgeospatial.com/docs/ENVIHeaderFiles.html "HDR description"). | ||
|
||
A function is dedicated to conversion of a raster file into appropriate image format, named `raster2BIL`. This function is relatively straightforward to run, but users should make sure prerequisites are met before running the function. | ||
|
||
# How to produce raster data with proper format using `raster2BIL` | ||
|
||
`raster2BIL` can be run as follows: | ||
|
||
```{r raster2BIL} | ||
library(biodivMapR) | ||
Input_Image_File = raster2BIL(Raster_Path = Path_Raster_File, | ||
Sensor = Path_Template_HDR, | ||
Convert_Integer = TRUE, | ||
Output_Dir = Path_Output_Directory) | ||
``` | ||
|
||
## Input variables | ||
|
||
The following information is expected as input information: | ||
|
||
* `Raster_Path`: a string containing the full path for the raster to be converted. | ||
* `Sensor`: a string containing the name of the sensor, which should actually be linked to a template for the corresponding header file. | ||
* `Convert_Integer` [optional]: a boolean stating if the raster data should be converted into integer | ||
* `Multiplying_Factor` [optional]: a multiplying factor for the raster data. This is useful when converting real reflectance values between 0 and 1 into integer between 0 and 10000. Set `Multiplying_Factor =10000` in this case. | ||
* `Output_Dir` [optional]: a string defining the path for the output directory where converted file will be stored. | ||
* `Multiplying_Factor_Last` [optional]: a multiplying factor for last band. This option is useful if working with dry vegetation acquired with Sentinel-2 images, in order to artifically increase the reflectance of the B12 band (SWIR 2, centered at 2200 nm), so that SWIR 1 band remains below the convex hull defined during Continuum removal. | ||
|
||
Please note that | ||
i) the coordinate system and minimal metadata (spatial resolution, geographic information...) are expected to be provided in the original image or image + header defined in `Raster_Path` if user want them to be included in the final image products. | ||
|
||
ii) `Sensor` should refer to the name of a `.hdr` file stored in the installation directory of `biodivMapR` | ||
Please type `system.file(package = "biodivMapR")` in order to get the location of the install directory and create a proper `.hdr` file to be stored in `extdata/HDR/`, containing proper spectral bands __defined in nanometers__ if using optical data and using `perform_radiometric_filtering` and/or `Continuum_Removal = TRUE` in your process. Make sure that the __spectral bands in the binary file are stored with wavelengths following ascending order__. | ||
|
||
iii) `Convert_Integer=TRUE` saves 50% space if original image is stored in real values (32bits per value). However, user need to make sure hat their original data are compatible with conversion: if reflectance values are stored as real value between 0 and 1, the final image file will be unusable, unless proper multiplying factor is applied to the full image data (for example `Multiplying_Factor =10000`). Sentinel-2 reflectance data downloaded from ESA hub are stored as integer (16 bits) values between 0 and 10 000 instead of real (32 bits) values between 0 and 1, so integer conversion is unnecessary. | ||
|
||
## output variable | ||
|
||
`raster2BIL` returns a string containing the full path for the raster once converted. |