I would like to use Java GDAL bindings to subset a GeoTIFF and write the result in VRT format.

I have found several old posts, one of them states that this functionality is yet to be implemented in Java GDAL bindings:

What is the situation in 2017?

Did anyone try to save VRT from Java using GDAL bindings?

1 Answer 1


You can save a Dataset as a VRT file. Create a VRT driver object, and then copy your custom dataSet into a new Dataset in the following manner:

// dataSet is the subset Dataset object you have created from the orginal GeoTIFF
Driver vrtDriver = GetDriverByName("VRT");
Dataset vrtDataSet = vrtDriver.CreateCopy("sample.vrt", dataSet);

This will create a VRT file called sample.vrt in your working directory. The assumption is that you have already registered your GDAL bindings.

  • Thanks, I have already discovered this way. Nevertheless, accepting your answer
    – Antonio
    Commented Dec 23, 2019 at 19:14
  • and giving you +1
    – Antonio
    Commented Dec 23, 2019 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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