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.

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:

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)

Input variables

The following information is accepted as input information:

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.

output variable

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.



floriandeboissieu/biodivMapR documentation built on March 11, 2021, 8:46 a.m.