jbferet / biodivMapR

biodivMapR: an R package for α- and β-diversity mapping using remotely-sensed images
https://jbferet.github.io/biodivMapR/index.html
GNU General Public License v3.0
47 stars 13 forks source link

Unable to read .hdr file generated after using raster2BIL function #11

Closed rrsc1234 closed 3 years ago

rrsc1234 commented 3 years ago

Hi. I am trying to go through your Tutorial for biodivMapR. I have a multiband (6 bands) sentinel-2 image (Ras_tif11.tif) which I have converted to ENVI HDR format using raster2BIL function. I have used the following code:

library(biodivMapR)

raster2BIL(
  "D:\\Data\\Ras_tif11.tif",
  Sensor = "unknown",
  Output_Dir = FALSE,
  Convert_Integer = TRUE,
  Multiplying_Factor = 1,
  Multiplying_Factor_Last = 1,
  Mask = FALSE
)

After running the above command I am getting following message in the console:

The converted file will be written in the following location:
[1] "D:\\Data\\biodivMapR_Convert_BIL\\Ras_tif11"
reading initial file
writing converted file
please make sure that the following header file contains information required
[1] "D:\\Data\\biodivMapR_Convert_BIL\\Ras_tif11.hdr"
or manually add wavelength location in HDR file, if relevant
[1] "D:\\Data\\biodivMapR_Convert_BIL\\Ras_tif11"

Post this when we are trying to "PERFORM RADIOMETRIC FILTERING" we are getting following error:

*********************************************************
No wavelength is associated to the image in the .hdr file
Please add wavelengths to the .hdr file
if you are processing multi or hyperspectral optical data
 Otherwise, make sure Continuum_Removal is set to FALSE  
*********************************************************
[1] "Create mask based on NDVI, NIR and Blue threshold"
wavelength units not provided in the header of the image
assuming wavelengths are expressed in micrometers
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 't': Cannot create a RasterLayer object from this file.
In addition: Warning message:
In max(HDR$wavelength) : no non-missing arguments to max; returning -Inf

Kindly help us out in resolving this issue.

jbferet commented 3 years ago

Dear @rrsc1234 ,

I just updated the package, as well as the tutorial and example. https://jbferet.github.io/biodivMapR/articles/biodivMapR_1.html

Here, the messages are telling you that the header of your inage file does not contain information about spectral bands in use. These spectral bands need to be identified in the header file if you want to run continuum removal for example.

Please check the chunk of code related to the call of the function "create_hdr", which should do the job for you, as long as you provide the spectral bands for your image (please write your image with bands ranked in ascending order, otherwise this will raise an error).

Let me know if you manage to make it work with the current version. Please make sure that you follow the instructions from the tutorial, as a few parameters from package functions may have changed since previous version.

Best regards,

jb

rrsc1234 commented 3 years ago

Dear @rrsc1234 ,

I just updated the package, as well as the tutorial and example. https://jbferet.github.io/biodivMapR/articles/biodivMapR_1.html

Here, the messages are telling you that the header of your inage file does not contain information about spectral bands in use. These spectral bands need to be identified in the header file if you want to run continuum removal for example.

Please check the chunk of code related to the call of the function "create_hdr", which should do the job for you, as long as you provide the spectral bands for your image (please write your image with bands ranked in ascending order, otherwise this will raise an error).

Let me know if you manage to make it work with the current version. Please make sure that you follow the instructions from the tutorial, as a few parameters from package functions may have changed since previous version.

Best regards,

jb

Hi. Thanks for the update. I am trying to go through your updated version. In the section "Download a Sentinel-2 image sample" I am not able to download header file for S2 Subset using the command "get_HDR_name(destfile,showWarnings = FALSE)". But when I am removing "showWarnings = FALSE" from the command, I am able to download the header file.

Subsequently when I am trying the section "Add a header file to Tiff images", I am successfully able to generate the TIFF file. But when I am trying to create header file using "create_hdr(ImPath = destfiletiff, Sensor = 'SENTINEL_2A', SpectralBands = NULL, BandName = NULL, WLunits = NULL)", I am getting following error "Error in create_hdr(ImPath = destfiletiff, Sensor = "SENTINEL_2A", SpectralBands = NULL, : could not find function "create_hdr".

My RStudio version is "R-4.0.3" and biodivMapR package version installed is 1.6.2.

Kindly suggest.

rrsc1234 commented 3 years ago

Dear @rrsc1234 , I just updated the package, as well as the tutorial and example. https://jbferet.github.io/biodivMapR/articles/biodivMapR_1.html Here, the messages are telling you that the header of your inage file does not contain information about spectral bands in use. These spectral bands need to be identified in the header file if you want to run continuum removal for example. Please check the chunk of code related to the call of the function "create_hdr", which should do the job for you, as long as you provide the spectral bands for your image (please write your image with bands ranked in ascending order, otherwise this will raise an error). Let me know if you manage to make it work with the current version. Please make sure that you follow the instructions from the tutorial, as a few parameters from package functions may have changed since previous version. Best regards, jb

Hi. Thanks for the update. I am trying to go through your updated version. In the section "Download a Sentinel-2 image sample" I am not able to download header file for S2 Subset using the command "get_HDR_name(destfile,showWarnings = FALSE)". But when I am removing "showWarnings = FALSE" from the command, I am able to download the header file.

Subsequently when I am trying the section "Add a header file to Tiff images", I am successfully able to generate the TIFF file. But when I am trying to create header file using "create_hdr(ImPath = destfiletiff, Sensor = 'SENTINEL_2A', SpectralBands = NULL, BandName = NULL, WLunits = NULL)", I am getting following error "Error in create_hdr(ImPath = destfiletiff, Sensor = "SENTINEL_2A", SpectralBands = NULL, : could not find function "create_hdr".

My RStudio version is "R-4.0.3" and biodivMapR package version installed is 1.6.2.

Kindly suggest.

Hi. I updated my biodivMapR package to 1.8.0 and the issue is resolved.