2

I'm using gdal_merge to join several BioClim rasters, which I will then feed into a Java program that "snaps" points to the nearest BioClim raster tile of non-NoData value. However, when I run gdal_merge, it assigns the NoData value of the BioClim file (NoData Value=-3.39999999999999996e+38) to each of the tiles as if it's a proper value (I think).

Running gdal_info on the merged raster shows that value as the minimum, with no indication of a NoData value; whereas running gdal_info on one of the pre-merged raster tiles shows it assigned to the NoData values.

I think this is creating an IndexOutOfBoundsException error when I then run the Java program... preventing me from snapping the points successfully.

I have two questions:

1) How do I use gdal_merge such that the NoData classification of cells are preserved in the merged output?

2) Could something else be causing the IndexOutOfBoundsException? I'm a novice with Java programs.

  • Did you try to assign nodata value gdal.org/gdal_merge.html? – user30184 Mar 31 '16 at 20:12
  • I did, but the gdalinfo statistics indicate the values have not been maintained correctly (e.g., statistics_minimum is now the original NoData value). – jbukoski Mar 31 '16 at 20:25
  • I would try gdal.org/gdalbuildvrt.html next. If that fails you should make a test package with data and actual complete commands. – user30184 Mar 31 '16 at 21:01
1

In order to maintain NoData cells in the output you seem to need to use both the "-n" option (specifying the NoData value for the input) and the "-a_nodata" option (specifying the NoData value for the output). For example:

gdal_merge.py -n -9999 -a_nodata -9999 -o merged.tif in*.tif

My version of gdal_merge does not overwrite existing files (it just touches them), so I have to remove "merged.tif" before running the command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.