OSGeo / grass-addons

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

i.sentinel.import: wrong resolution set for latlong locations #84

Open veroandreo opened 4 years ago

veroandreo commented 4 years ago

Name of the addon i.sentinel.import

Describe the bug When trying to import S2 scenes into a latlong location using i.sentinel.import with -r flag, the resolution is set to 10, 20 or 60 degrees instead of the equivalent of 10, 20 and 60 m in degrees. If I import into a UTM location all is fine, as well as if I use r.importinstead of i.sentinel.import with a latlong location. As you can see below, r.import estimates a resolution, however, r.sentinel.import uses the nominal resolution in meters anyway.

To Reproduce Steps to reproduce the behavior:

  1. Download a S2 scene
    i.sentinel.download settings=your_sentinel_file output=tmp uuid=541021f8-63f5-4e9d-ba28-425c4c8451df
  2. Import into a latlong location - here, I already got messages that the imported map was empty
    i.sentinel.import input=tmp/ pattern='B(02_1|03_1|04_1|08_1|8A_2)0m' extent=input memory=500
    ...
    Estimated target resolution for input band
    <T21JYM_20200126T134201_B11_20m>: 0.00018606630466763683
    Using given resolution for input band <T21JYM_20200126T134201_B11_20m>:
    20.0
    Reprojecting <T21JYM_20200126T134201_B11_20m>...
    ERROR: The reprojected raster <T21JYM_20200126T134201_B11_20m> is empty
    Writing metadata to maps...
  3. Run r.info to check (see below)

Screenshots image

System description (please complete the following information):

neteler commented 4 years ago

Probably we need a change here for LongLat:

https://github.com/OSGeo/grass-addons/blob/f5b90b741b09a63269ee8e782ebcc43378018a08/grass7/imagery/i.sentinel/i.sentinel.import/i.sentinel.import.py#L229

veroandreo commented 4 years ago

ping @landam :) any chance to have a look at this?

lucadelu commented 3 years ago

Probably we need a change here for LongLat:

https://github.com/OSGeo/grass-addons/blob/f5b90b741b09a63269ee8e782ebcc43378018a08/grass7/imagery/i.sentinel/i.sentinel.import/i.sentinel.import.py#L229

The change should be done in _raster_resolution function, the problem it is to get the right value in degree according to the position on the Earth surface.

Could geodesic lenght be useful?

neteler commented 3 years ago

... the problem it is to get the right value in degree according to the position on the Earth surface.

Could geodesic lenght be useful?

We have length_geodesic(), maybe interesting?

veroandreo commented 3 years ago

In this commit in the i.landsat.import addon I propose a simple approach, i.e., using r.import's resolution = estimated when the target location is longlat. What do you think @neteler and @lucadelu ?

lucadelu commented 3 years ago

It could work, did you try if you addons works properly?

veroandreo commented 3 years ago

It could work, did you try if you addons works properly?

Yes, It works as expected. It's r.import who does the resolution estimation for latlong locations.