ubarsc / python-fmask

A set of command line utilities and Python modules that implement the ‘fmask’ algorithm
https://www.pythonfmask.org
GNU General Public License v3.0
75 stars 21 forks source link

A bug calculating landsat angles #28

Closed gillins closed 4 years ago

gillins commented 4 years ago

Original report by Anonymous.


The function sunAnglesForExtent in landsatangls.py

Line 227 Original code : (ul_long, ul_lat, ur_long, ur_lat, lr_long, lr_lat, ll_long, ll_lat) = cornerLatLong

Changed code : (ul_lat, ul_long, ur_lat, ur_long, lr_lat, lr_long, ll_lat, ll_long) = cornerLatLong

Then the output : angle map is correct.

gillins commented 4 years ago

Original comment by Neil Flood (Bitbucket: neilflood, GitHub: neilflood).


That line of code is correct. I cannot reproduce this.

If there is an error further down, we should find it, but the order of values in that tuple is correct as it is.

bnucaowu commented 4 years ago

from rios import fileinfo import numpy file = "/home/LC80420082013220LGN00_B1_toa.TIF" imgInfo = fileinfo.ImageInfo(file) cornerLatLong = imgInfo.getCorners(outEPSG=4326) (ul_lat, ul_long, ur_lat, ur_long, lr_lat, lr_long, ll_lat, ll_long) = cornerLatLong # changed pts = numpy.array([ ... [ul_long, ul_lat], ... [ur_long, ur_lat], ... [ll_long, ll_lat], ... [lr_long, lr_lat] ... ]) longDeg = pts[:, 0] latDeg = pts[:, 1] longDeg array([-98.41048362, -89.37133398, -97.6997143 , -89.84929715]) latDeg array([74.60575466, 74.64178368, 72.2106416 , 72.2415592 ]) cornerLatLong (74.60575466167826, -98.41048362112267, 74.64178367907462, -89.37133397624285, 72.24155919861137, -89.84929715401962, 72.21064160380321, -97.69971430154234) image In my case, the older values in that tuple is wrong.

neilflood commented 4 years ago

After some further investigation, it appears that this occurs when using GDAL-3.x. Furthermore, it seems that this is a deliberate change in the behaviour of GDAL, which everyone is now going to have to cope with. See https://github.com/OSGeo/gdal/issues/1546.

We will have to work out the best approach to dealing with this. Until then, nothing will work with GDAL-3.x.

Thank you for bringing it to our attention.

neilflood commented 4 years ago

With release 1.4.10 of rios, this now works correctly with GDAL 3.x