I am trying to extract several pixel values using python and snap. When i run it stops without giving an error as you can see
Any ideas why?
I am trying to extract several pixel values using python and snap. When i run it stops without giving an error as you can see
Any ideas why?
Without knowing the code it is hard to tell.
The code is as follows:
def extract(path,coods,Prefix):
HashMap = jpy.get_type(‘java.util.HashMap’)
product=ProductIO.readProduct(path)
parameters = HashMap()
parameters.put(‘exportBands’, True)
parameters.put(‘PincludeOriginalInput’, True)
parameters.put(‘coordinates’,coods)
parameters.put(‘exportExpressionResult’, False)
parameters.put(‘exportMasks’, True)
parameters.put(‘outputFilePrefix’, Prefix)
parameters.put(‘exportTiePoints’, True)
parameters.put(‘exportExpressionResult’,True)
GPF.createProduct(‘PixEx’,parameters,product)
product.dispose()
return
import snappy
from snappy import ProductIO, GPF, jpy
def find_pixel_values_Cm(Profile_ID,folder):
if len(Profile_ID)==0:
print('No images found to extract pixel values')
return
parameters=['CHL_OC4ME','CHL_OC4ME_err','CHL_NN','CHL_NN_err','KD490_M07','WQSF_lsb_WATER','Oa02_reflectance','Oa03_reflectance']
number_images=len(Profile_ID)
for i in range(0,number_images):
Coord = jpy.get_type('org.esa.snap.pixex.Coordinate')
coods = jpy.array('org.esa.snap.pixex.Coordinate', 1)
coods[0]= Coord('st_'+str(Profile_ID.loc[i, 'Profile_ID']),float(Profile_ID.loc[i, 'Lat']), float(Profile_ID.loc[i, 'Lon']), None)
print (coods)
extract(folder+Profile_ID.loc[i, 'filename']+'/xfdumanifest.xml',coods,'temp')
data = pd.read_table('temp' + '_OL_2_WFR_measurements.txt', header=0, skiprows=6)
for j in range(0,len(parameters)):
temp= (np.array(data[parameters[j]])).tolist()
Profile_ID[parameters[j]] = 'nan'
Profile_ID.loc[i, parameters[j]] = temp
del temp
os.remove('temp' + '_OL_2_WFR_measurements.txt')
os.remove('temp' + '_productIdMap.txt')
Profile_ID=Profile_ID.rename(columns={"KD490_M07": "KD_490", "WQSF_lsb_WATER": "Identified wzter",'Oa02_reflectance':'B2','Oa03_reflectance':'B3'})
return Profile_ID
loops every image contained in a dataframe and then extracting at relevant coordinates the pixel values read the txt which is created and storing the pixel value in another dataframe
Any ideas?