Hello everyone. I have a trouble about java-gdal when I process raster geotif data. I want to convert Dataset type object to Byte array in order to return HttpResponse. But I dont know how to convert. If I write file on disk firstly,then I read the file into FileInputStream,I can convert to byte[],like this:
####code##### String resTifPath = storageLocation + zoom + "-" + col + "-" + row + ".tif"; Driver tifDriver = gdal.GetDriverByName("GTiff"); Dataset datasetTifNew = tifDriver.CreateCopy(resTifPath, datasetTif); //write datasetTif to file on disk Byte[] res =null ; File file = new File(resTifPath); FileInputStream in = null; res = new byte[(int) file.length()]; in = new FileInputStream(file); in.read(res); return res; //It can return byte[] to HttpResponse normally. ##### I found it can use "data_bytes = dataset.ReadAsArray().tobytes()" in python-gdal. But who can tell me how to convert Dataset type object to Byte array directly in Java-gdal? Best Regurds. Thank you very much.
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev