OSGeo / grass-addons

GRASS GIS Addons Repository
https://grass.osgeo.org/grass-stable/manuals/addons/
GNU General Public License v2.0
103 stars 154 forks source link

[Bug] i.sentinel.mask not working with `metadata` nor `mtd_file` options #729

Open veroandreo opened 2 years ago

veroandreo commented 2 years ago

According to the manual page of i.sentinel.mask, if the user imports Sentinel bands using -j flag in i.sentinel.import, there's no need to set the path to the xml metadata file in S2 scenes (mtd_file nor metadata) which prevents the annoying task of unzipping. However, I cannot get this to work, or most likely I'm not getting the expected behavior right.

If I pass nothing in metadata (i.e., it should take the default as in the example from the manual), I get the message: ERROR: No default metadata files found. Did you use -j in i.sentinel.import? (Yes, I did). If I pass description.json or LOCATION/MAPSET/cell_misc/BAND/description.json with the hope that it will search and replace band names, I get: ERROR: Metadata file <LOCATION/MAPSET/cell_misc/BAND/description.json> not found. Please select the right file

Which is the correct way to use it then? The files are indeed where the default points, but it is one per band, while the metadata parameter takes just one value.

veroandreo commented 2 years ago

I tried with the traditional approach (unzipping the SAFE file and searching for the metadata file to pass through mtd_file option), but now I get stacked with a different error:

Starting cloud and cloud shadow detection
ERROR: Parameter 'file' contains reference to
       <PERMANENT,T20KMA_20220122T141729_B02_10m> mapset, but mapset
       parameter <sentinel2> does not correspond
Traceback (most recent call last):
  File "/home/veroandreo/.grass7/addons/scripts/i.sentinel.mask", line 836, in <module>
    main()
  File "/home/veroandreo/.grass7/addons/scripts/i.sentinel.mask", line 350, in main
    if not gscript.find_file(value, element="cell", mapset=mapset)["file"]:
KeyError: 'file'

I'm working in sentinel2 mapset, why does it search in PERMANENT?

I see also that while I'm using grass 8.1 (dev), it calls addons in .grass7... Could that be the root of these errors? How do I tell grass 8 to use addons in .grass8 folder? (It seems this is not the problem as when I try with grass78, I get the same error)

I'm in Fedora 34 and calling these modules through a python script using grass-session.

veroandreo commented 2 years ago

I found the problem, I was providing full map names with mapset, i.e., bla@sentinel2. i.sentinel.mask does not like them, it only takes map names without the mapset part. Is that a bug or an enhancement??

neteler commented 2 years ago

i.sentinel.mask does not like them, it only takes map names without the mapset part. Is that a bug or an enhancement??

This is a bug.