[gdal-dev] GDAL - JAVA getting Elevation Data

Mahir Karabacak mkarabacak at meteksan.com
Wed Feb 1 01:02:50 PST 2017


Hi All,

I hava Java code below which gets elevation data according to coordinate. My question; what if I have multiple GeoTiff files, how can I read all into one dataset or merge all data into one dataset?

Thanks in Advance,
Mahir KARABACAK


private static Dataset elevationDataSet;
private static double[] geoTransformsInDoubles;
private static Band rasterBand;
private static double[] invGeoTransformsInDoubles;


elevationDataSet = gdal.Open("M:/maps/20170130011154_1642612357.tif", gdalconst.GA_ReadOnly);
geoTransformsInDoubles = elevationDataSet.GetGeoTransform();
rasterBand = elevationDataSet.GetRasterBand(1);
invGeoTransformsInDoubles = gdal.InvGeoTransform(geoTransformsInDoubles);

double[] pdfGeoX = new double [1];
double[] pdfGeoY = new double [1];
                                
gdal.ApplyGeoTransform(invGeoTransformsInDoubles, lon, lat, pdfGeoX, pdfGeoY);
double [] flt = new double[2];

int readResult = rasterBand.ReadRaster((int)pdfGeoX[0], (int)pdfGeoY[0], 1,1, gdalconst.GDT_CFloat64,flt);

if (readResult == 0)
{
                return flt[0];
}


More information about the gdal-dev mailing list