[gdal-dev] GDAL Java Bindings - No data value using AutoCreateWarpedVRT
johie
jesse.hietanen at gmail.com
Wed Jun 24 06:19:01 PDT 2015
Hi,
I have been working with small application to reproject some raster files
into WGS84. For this purpose I have used GDAL and Java Bindings.
Reprojection works just fine, but the problem is that it creates "black"
bounding box around the warped image (see image below) The problem with this
is that the value of this black area is 0. In my data I have values of 0, so
I cannot really set it as noData later. Below is also the part of my code I
have been using to do this. I have already spent hours with this problem :/
So my question is, is there any way to input some parameter to the
autoCreateWarpedVRT that it changes the Nodata value or is there some way to
change it later? I must use Java bindings on the app :) It is sad that there
are so few examples of how to to actually use the gdal Java bindings
available on the internet.
<http://osgeo-org.1560.x6.nabble.com/file/n5212697/BlackBoxAutoCreateWarpedVRT.png>
Band originalBand = inputDataset.GetRasterBand(1);
Double[] noDataval = new Double[2];
originalBand.GetNoDataValue(noDataval);
SpatialReference dstRef = new SpatialReference("");
dstRef.ImportFromEPSG(4326);
Dataset vrt_ds = gdal.AutoCreateWarpedVRT(inputDataset,
inputDataset.GetProjection(), dstRef.ExportToWkt(),
gdalconst.GRA_NearestNeighbour);
vrt_ds.GetRasterBand(1).SetNoDataValue(noDataval[0]);
Driver GeoTiffDriver = gdal.GetDriverByName("GTiff");
Dataset out_ds = GeoTiffDriver.CreateCopy("C:\\temp\\test.tif",
vrt_ds);
out_ds.GetRasterBand(1).SetNoDataValue(noDataval[0]);
vrt_ds.delete();
inputDataset.delete();
out_ds.delete();
Thanks for your help!
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/gdal-dev-GDAL-Java-Bindings-No-data-value-using-AutoCreateWarpedVRT-tp5212697.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list