knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval=FALSE )
**if you are running version 1.3.0 or more recent version of __biodivMapR__ this tutorial is not needed**
biodivMapR was expecting a specific raster file format as input file before version 1.3.0.
.bil
file extension, or no file extension..hdr
file extension, and should be located in the same directory. 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.
raster2BIL
raster2BIL
can be run as follows:
library(biodivMapR) # define input variables for raster2BIL: # full path or relative path for the raster file to convert Path_Raster_File <- 'Where/is/your/raster/file/?' # you also need to define a template for the .hdr file corresponding to your sensor. # locate the install directory for biodivMapR # system.file(package = "biodivMapR")` # and write a file with description corresponding to your image (in terms of spectral bands, band name, etc) Name_Template_HDR <- 'Name_of_hdr_template' # you may want to convert reflectance from [0-1] real32 values to [0-10000] integer16 # see explanation below Convert_Integer <- TRUE Multiplying_Factor <- 10000 Multiplying_Factor_Last <- 1.0 Input_Image_File = raster2BIL(Raster_Path = Path_Raster_File, Sensor = Name_Template_HDR, Output_Dir = Path_Output_Directory, Convert_Integer = Convert_Integer, Multiplying_Factor = Multiplying_Factor, Multiplying_Factor_Last=Multiplying_Factor_Last, Mask = FALSE)
The following information is accepted 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. Output_Dir
[optional]: a string defining the path for the output directory where converted file will be stored.Convert_Integer
[optional]: a boolean stating if the raster data should be converted into integerMultiplying_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.Multiplying_Factor_Last
[optional]: a multiplying factor for last band. This option is useful only 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. You do not need to use this option most of the time, unless you want to enhance teh sensitivity to different types of dry vegetation.Mask
[optional]: a boolean stating if the raster data corresponds to a mask (TRUE) or not (FALSE). If it is a mask, masked pixels should have a value of 0
, and pixels to keep for the analysis should have a value of 1
. raster2BIL converts image information into unsigned 8 bits integer.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 (32 bits 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.
raster2BIL
returns a string containing the full path for the raster once converted.
You can directly use this output variable as input for the next steps of the process.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.