Extracting single pixel information


#21

This happens because Coord in your code is already the array.

HashMap = jpy.get_type('java.util.HashMap')
inf='E:\diplomatiki\S2A_MSIL1C.SAFE\S2A_MSL2A\S2A_MSIL2A_20170622T090021_N0205_R007_T35SLV_20170622T090154.SAFE\outputs/'
product=ProductIO.readProduct(inf+'resample.dim')

my_coordinates=jpy.array('org.esa.snap.pixex.Coordinate', 5)
my_coordinates[0] = Coord('name1',25.12,35.72, None)

parameters = HashMap()
parameters.put('PexportBands', 1)
parameters.put('PexportExpressionResult', 0)
parameters.put('PexportMasks', 0)
parameters.put('PexportTiePoints', 0)
parameters.put('PoutputDir', 'C:\Users\user\Desktop\te')

parameters.put('coordinates', my_coordinates)
c=GPF.createProduct('PixEx', parameters)

In addition you need to remove the leading ‘P’ from the parameter names. They are only needed on the command line. And you need to replace 1 by True and 0 by False.


#22

I tried but when i checked my module i had an error my_coordinates[0]included_bands[0] = Coord(‘name1’,25.12,35.72,‘none’)
so i changed that to
my_coordinates[0]= Coord(‘name1’,25.12,35.72,‘none’)

and i the following error

Traceback (most recent call last):
File “E:\diplomatiki\doriforikes\statistiki_analysi.py”, line 18, in
my_coordinates[0]= Coord(‘name1’,25.12,35.72,‘none’)
NameError: name ‘Coord’ is not defined

Then i also tried to correct the mentioned error
using that my_coordinates[0]= (‘name1’,25.12,35.72,‘none’)
and i get the following error

Traceback (most recent call last):
File “E:\diplomatiki\doriforikes\statistiki_analysi.py”, line 18, in
my_coordinates[0]= (‘name1’,25.12,35.72,‘none’)
ValueError: cannot convert a Python ‘tuple’ to a Java ‘org.esa.snap.pixex.Coordinate’


#23

Try again the above script. There was just something wrongly paste into it.


#24

I tried and i still get the first error i mentioned

Traceback (most recent call last):
File “E:\diplomatiki\doriforikes\statistiki_analysi.py”, line 18, in
my_coordinates[0] = Coord(‘name1’,25.12,35.72,‘none’)
NameError: name ‘Coord’ is not defined


#25

Add this line at the beginning of the script:

Coord = jpy.get_type('org.esa.snap.pixex.Coordinate')

#26

Now i get this error

Traceback (most recent call last):
File “E:\diplomatiki\doriforikes\statistiki_analysi.py”, line 18, in
my_coordinates[0] = Coord(‘name1’,25.12,35.72,‘none’)
RuntimeError: no matching Java method overloads found


#27

Yes, I said it before. it needs to be replaced by. I’ve wrongly taken this from your script.

my_coordinates[0] = Coord('name1',25.12,35.72, None)

Sorry, but I’m not your debugger. All information you need is in this thread.


#28

Sorry that was my mistake

It works but i don t see any files at the output directory.
Am i missing something?
Sorry again for any inconvenience.


#29

One reason could be that the coordinates are not within the product bounds.


#30

Thank you very much for your help marpet!! It worked!!

One last question
How is it possible to give multiple products at the same time so you will have one output file?


#31

For a single product you can do:

GPF.createProduct('PixEx', parameters, product)

or for multiple products, you can create an array similar to the coordinates and then call
GPF.createProduct(‘PixEx’, parameters, productsArray)

But for PixEx it is best to specify the sourceproductsPath Parameter. In each path, you can use wildcards so it matches multiple product files.


#32

A post was split to a new topic: Coordinates can not be read from file for pixel extraction