I realized that reclassification is the tool to go to reduce the polygon count Creating simplified (binned) polygons from raster file? and implemented it in Java using geotools. Unfortunately this is really frustrating due to JAI https://stackoverflow.com/questions/44341018/jai-cant-execute-in-native-spark-only-in-sbt-and-as-a-separate-scala-function
So I want to try it instead using GDAL. Here is a dummy file. How can I interlink gdal_polygonize.py and http://www.gdal.org/gdal_calc steps is it required to write output to file?
ncols 4
nrows 3
xllcorner 0
yllcorner 0
cellsize 1
nodata_value -999
-1 -2 -3 -4
-4 -21 -3 -3
-3 -2 -31 -1
There should be 2 classes [-50 -10[, [-10 0[