Reading Sentinel-2 data in python

188 views
Skip to first unread message

Emily W

unread,
Mar 2, 2018, 6:43:09 AM3/2/18
to RSGISLib Support

Hi,

I may be missing something obvious. But I am trying to read a sentinel-2 project with python arsci (windows). It recognises that it is a file but reads that it has no bands (produces an empty list using getbandnames)? Am I reading it correctly, I used the MTD_MSIL1C.xml file?

I tried getbandnames on the TCI.jp2 project directly to see if that worked, it could see the bands but does not have a name for them - lists as ('', '', '')
 

runfile('C:/......../Python Scripts/rgdr.py', wdir='C.........../Python Scripts')
Traceback (most recent call last):

  File "<ipython-input-4-c0471b0d77f0>", line 1, in <module>
    runfile('C:/.........../Python Scripts/rgdr.py', wdir='C:............/Python Scripts')

  File "C:\.......\Anaconda3\envs\maskenv\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\......Anaconda3\envs\maskenv\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:............/Python Scripts/rgdr.py", line 18, in <module>
    rsgislib.imageutils.selectImageBands(img, tmp_img, 'KEA', rsgislib.TYPE_16UINT, [2,3,4])

error: Not all the image bands are present within the input image file (Note. Bands are numbered from 1).
----------------------------------------------------------------------------------------------------------------------------------------------------

Script

import rsgislib

import rsgislib.imageutils
import rsgislib.rastergis
import rsgislib.imagecalc
import rsgislib.imagecalc.calcindices

img = 'C:................/cloud/S2A_MSIL1C_20180119T033041_N0206_R018_T47NRC_20180119T084949.SAFE/MTD_MSIL1C.xml'
tmp_img = 'C:/............./cloud/bandsub.kea'

rsgislib.imageutils.selectImageBands(img, tmp_img, 'KEA', rsgislib.TYPE_16UINT, [2,3,4])

bn = rsgislib.imageutils.getBandNames(img)
print (bn)

------------------------------------



Any ideas? 

Daniel Clewley

unread,
Mar 2, 2018, 11:54:04 AM3/2/18
to Emily W, RSGISLib Support
Hi Emily,

I’m not quite sure what you are trying to do. What command are you using in ARCSI?

Thanks,

Dan

--
You received this message because you are subscribed to the Google Groups "RSGISLib Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rsgislib-suppo...@googlegroups.com.
To post to this group, send email to rsgislib...@googlegroups.com.
Visit this group at https://groups.google.com/group/rsgislib-support.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages