RuntimeError: java.lang.ArithmeticException: / by zero

I’m using snap libraries in python via snappy. I run the script for terrain correction of a GRD Sentinel-1 scene image and I’ve got this error : RuntimeError: java.lang.ArithmeticException: / by zero.
I still could not figure out in which step of the terrain correction process the division by “0” occurs.
would you have any idea how to solve this situation and avoid the division by “0”?

  • i thought maybe its from the data set, i tried with another image but the problem occurs again
  • i perform the terrain correction using as an input a radiometric corrected image “sigma0”, so I tried directly the non radiometric corrected image (.zip) and the error persist
  • i thought maybe the interpolation method causes the problem, Im using bicubic and i tried with bilinear, but the error persist still

Thank you

Is this post maybe helping?

thank you marpet, unfortunately it is still not working…
I set “localincidenceangle” to “True” (to save it), I thought maybe in the moment of projecting the “sin(incidence angle)” is needed and that may cause this division by 0! … will investigate more…

could you provide the data product name and the python calls, parameters, etc so I could reproduce the problem?

Thank you Iveci, my image Id is : S1B_IW_GRDH_1SDV_20181029T165756_20181029T165821_013370_018BA0_9981
here are the parameters:

parameters = HashMap()
parameters.put('saveLatLon', 'False')
parameters.put('saveIncidenceAngleFromEllipsoid', 'False')
parameters.put('nodataValueAtSea', 'True')
parameters.put('alignToStandardGrid', 'False')
parameters.put('pixelSpacingInMeter', 10.0)
srs = SpatialReference('PROJCS["UTM Zone 33 / World Geodetic System 1984", GEOGCS["World Geodetic System 1984", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]],      PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]], PROJECTION["Transverse_Mercator"], PARAMETER["central_meridian", 15.0], PARAMETER["latitude_of_origin", 0.0], PARAMETER["scale_factor", 0.9996],  PARAMETER["false_easting", 500000.0], PARAMETER["false_northing", 0.0], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH]]')
code = srs.GetAuthorityName(None) + ':' + srs.GetAuthorityCode(None)
parameters.put('mapProjection', code)
parameters.put('saveBetaNought', 'False')
parameters.put('externalDEMFile', '')
parameters.put('demResamplingMethod', 'BILINEAR_INTERPOLATION')
parameters.put('imgResamplingMethod', 'BILINEAR_INTERPOLATION')
parameters.put('saveSigmaNought', 'False')
parameters.put('incidenceAngleForSigma0', 'Use projected local incidence angle from DEM')
parameters.put('sourceBands', '')
parameters.put('applyRadiometricNormalization', 'False')
parameters.put('externalDEMApplyEGM', 'True')
parameters.put('saveSelectedSourceBand', 'True')
parameters.put('demName', 'SRTM 3Sec')
parameters.put('externalDEMNoDataValue', 0.0)
parameters.put('outputComplex', 'False')
parameters.put('saveProjectedLocalIncidenceAngle', 'False')
parameters.put('incidenceAngleForGamma0', 'Use projected local incidence angle from DEM')
parameters.put('saveGammaNought', 'False')
parameters.put('saveLocalIncidenceAngle', 'False')
parameters.put('standardGridOriginX', 0.0)
parameters.put('saveDEM', 'True')
parameters.put('standardGridOriginY', 0.0)
parameters.put('pixelSpacingInDegree', '8.983152841195215E-5')
parameters.put('externalAuxFile', '')
parameters.put('auxFile', 'Latest Auxiliary File')

but what was done to it before terrain correction? or just read and terrain correct is enough?

just read and terrain correction yes

probably…Im doubting that my computer is not able (maybe) to make the DEM mosaic (as i download automatically in the process) and there are then 0 value then ? !

I tried with the graphical interface -snap (maybe i can see something) and got this error:

java.lang.OutOfMemoryError: Java heap space
at org.esa.snap.core.datamodel.CrsGeoCoding.getPixels(
at org.esa.snap.engine_utilities.gpf.TileGeoreferencing.(
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.computeTileStack(
Caused: org.esa.snap.core.gpf.OperatorException: Java heap space
at org.esa.snap.engine_utilities.gpf.OperatorUtils.catchOperatorException(
at org.esa.s1tbx.sar.gpf.geometric.RangeDopplerGeocodingOp.computeTileStack(
at org.esa.snap.core.gpf.internal.OperatorImageTileStack.computeRect(
at org.esa.snap.core.gpf.internal.OperatorImageTileStack.computeTile(
Caused: org.esa.snap.core.gpf.OperatorException: Java heap space
at org.esa.snap.core.gpf.internal.OperatorExecutor$GPFImagingListener.errorOccurred(
at com.bc.ceres.glevel.MultiLevelImage.getData(
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(
at org.esa.snap.core.gpf.internal.OperatorContext.getSourceTile(
at org.esa.snap.core.gpf.internal.OperatorImage.computeRect(
[catch] at

Our colleague has debugged the problem and created a bugfix:

Hope it will be accepted and released soon through a S1TBX update!


I am facing a similar issue of “java.lang.ArithmeticException: / by zero” when trying to TC a ALOS-2/PALSAR-2 data. Data ID is ALOS2-HBQR1_1__A ORBIT__ALOS2131840340-16103.

Kindly help.


the scene ID is incomplete, are you missing the last digit? 16103x

It is 161031

strangely, I cannot find the image in the official JAXA archive


Can you shortly say where it is located?

Please try the search with ALOS2131840340-161031.
It is a full-pol scene over India acquired on 2016-10-31.


works now, thank you

My guess was that the data lies in some area where no DEM is available. But this is obviously not the case. What preprocessing steps have you already applied?

Prior to TC I simply applied radiometric calibration.

what output format did you select in the calibrations step?
have you tried another DEM for terrain correction?

I had selected complex output format.
I have tried with other DEM also.

I basically wasnt TC [S] that can be multilooked and converted to [T] on which model-based decompositions can be applied.

Is there any other way to do it?


sounds logic to me. This is also the suggested workflow when working with data in PolSARpro. Import, terrain correction (conserving complex information), then comes the polarimetric anaysis.

I just tried it with my ALOS PALSAR and it works.

I will try it with ALOS-2 data as well but as you know, it is considerably larger.