From 58be3b1114f923e3630ff075fe9b671973548791 Mon Sep 17 00:00:00 2001 From: Jeroen Dries Date: Mon, 7 Aug 2023 16:48:13 +0200 Subject: [PATCH] force crop force cropping when regrid leads to much smaller tiles, to avoid memory multiplication in serialized rdd --- spark/src/main/scala/geotrellis/spark/regrid/Regrid.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spark/src/main/scala/geotrellis/spark/regrid/Regrid.scala b/spark/src/main/scala/geotrellis/spark/regrid/Regrid.scala index b332b3c8e5..cb0d5a8952 100644 --- a/spark/src/main/scala/geotrellis/spark/regrid/Regrid.scala +++ b/spark/src/main/scala/geotrellis/spark/regrid/Regrid.scala @@ -118,11 +118,12 @@ object Regrid { val xSpan: Interval[Long] = oldXrange intersect newXrange val ySpan: Interval[Long] = oldYrange intersect newYrange + val forceCrop = newW < 0.6*oldW || newH < 0.6*oldH newKey -> (oldTile.crop((xSpan.start - oldXstart).toInt, (ySpan.start - oldYstart).toInt, (xSpan.end - oldXstart).toInt, - (ySpan.end - oldYstart).toInt), + (ySpan.end - oldYstart).toInt),Crop.Options(force=forceCrop)), ((xSpan.start - newXrange.start).toInt, (ySpan.start - newYrange.start).toInt) ) }