[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rrsc1234 opened this issue Sep 16, 2021 · 3 comments
Closed

Comments

@rrsc1234
Copy link
rrsc1234 commented Sep 16, 2021

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
Copy link
Owner
jbferet commented Sep 27, 2021

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
Copy link
Author
rrsc1234 commented Sep 28, 2021

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
Copy link
Author

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.

@jbferet jbferet closed this as completed Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants