Skip to content

Commit

Permalink
refactor: remove duplicate variable
Browse files Browse the repository at this point in the history
  • Loading branch information
furqaankhan committed Dec 22, 2023
1 parent c0bb8be commit 7c56cd4
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public static GridCoverage2D setBandNoDataValue(GridCoverage2D raster, int bandI
bands[bandIndex - 1] = RasterUtils.createSampleDimensionWithNoDataValue(bands[bandIndex - 1], noDataValue);

if (replace) {
Double previousNoDataValue = RasterBandAccessors.getBandNoDataValue(raster, bandIndex);
if (previousNoDataValue == null) {
if (rasterNoData == null) {
throw new IllegalArgumentException("The raster provided doesn't have a no-data value. Please provide a raster that has a no-data value to use `replace` option.");
}

Expand All @@ -79,7 +78,7 @@ public static GridCoverage2D setBandNoDataValue(GridCoverage2D raster, int bandI
WritableRaster wr = RasterFactory.createBandedRaster(dataTypeCode, width, height, numBands, null);
double[] bandData = rasterData.getSamples(0, 0, width, height, bandIndex - 1, (double[]) null);
for (int i = 0; i < bandData.length; i++) {
if (bandData[i] == previousNoDataValue) {
if (bandData[i] == rasterNoData) {
bandData[i] = noDataValue;
}
}
Expand Down

0 comments on commit 7c56cd4

Please sign in to comment.