RuntimeError: no matching Java method overloads found

I started a sentinel-1 pre-processing chain. I would like to write out the subset image I created using:

s1_read = snappy.ProductIO.readProduct(img_path)
parameters = snappy.HashMap() 
parameters.put("copyMetadata", True)
WKTReader = snappy.jpy.get_type('com.vividsolutions.jts.io.WKTReader')
wkt = "POLYGON ((10.49324200996349 47.75585323456224, 10.49324200996349 48.75301300400096, 8.999727904106205 48.75301300400096, 8.999727904106205 47.75585323456224, 10.49324200996349 47.75585323456224))"
geom = WKTReader().read(wkt)
parameters.put("geoRegion", geom)
subset = snappy.GPF.createProduct("Subset", parameters, s1_read)
snappy.ProductIO.writeProduct(subset, "subset", "GeoTiff")

However I receive the following error:
snappy.ProductIO.writeProduct(subset, "subset, “GeoTiff”)
RuntimeError: no matching Java method overloads found.
I found the following link, but it deals with Sentinel-2 Data.
https://forum.step.esa.int/t/snappy-mask-clouds-and-others/1654

my snappy version is 0.7, and I am using a Docker container from the following image:
https://hub.docker.com/repository/docker/deltodon/esa-snap-cpython

Does anyone have confronted the same problem?

That’s strange. Only I can think of is that the subset variable is set to None. But this should actually not happen.
Can you check this?

Try using GeoTIFF.

Good afternoon marpet. I already checked it, and the type of the subset variable after performing the subset is:
“<class ‘org.esa.snap.core.datamodel.Product’>”

After changing GeoTiff for GeoTIFF I received the same error message:

snappy.ProductIO.writeProduct(product, output_path, "GeoTIFF")
RuntimeError: no matching Java method overloads found

I pasted your script into a file with my standard snappy preamble, replaced the filename with that of a MODIS level-2 file, and changed the polygon to wkt="POLYGON ((-78 46, -62 46, -62 30, -78 30, -78 46))".

#! /usr/bin/env python3.7
# https://forum.step.esa.int/t/runtimeerror-no-matching-java-method-overloads-found/24695
import sys
import os
snappy_envar = 'HOME' # windows needs 'USERPROFILE'
envs = os.environ
if not snappy_envar in envs.keys():
    raise Exception('Can’t find snappy')
else:
    snappy_dir = os.path.join(envs.get(snappy_envar), '.snap', 'snap-python')
sys.path.append(snappy_dir)
import snappy
L2_read = snappy.ProductIO.readProduct('./A2006167181000.L2')
parameters = snappy.HashMap() 
parameters.put("copyMetadata", True)
WKTReader = snappy.jpy.get_type('com.vividsolutions.jts.io.WKTReader')
wkt="POLYGON ((-78 46, -62 46, -62 30, -78 30, -78 46))"
geom = WKTReader().read(wkt)
parameters.put("geoRegion", geom)
subset = snappy.GPF.createProduct("Subset", parameters, L2_read)
snappy.ProductIO.writeProduct(subset, "./A2006167181000.L2subset", "GeoTIFF")

This system (Fedora 31) is using python37 with deephaven_jpy-1.20190816.73-cp37-cp37m-linux_x86_64.whl. The “magic” could be specifying the location for
snappy to avoid using some old version installed elsewhere.

1 Like

Hello everyone,
I encountered the same error of no matching Java method overloads found, and even trying the proposed solutions, my problem is not solved.
Any ideas?

1 Like