Is there any way to generate a virtual batch (.vrt) in batch? I imagine the coordinates should be in a .txt file and related to the name of the images that will be cropped.

There are more than 1,000 rasters and it would be impracticable to carry out the process one by one.

Here is an example of the algorithm used:

gdal_translate -of VRT -projwin -58.5 -19.0 -57.0 -18.0 \ image.tif image.vrt
  • You can find tutorials about how to write a shell script on Linux or a Windows batch file. – user30184 Apr 9 at 19:40
  • See the note here on the --optfile argument, you could create a text file of your projwin/input/output for each then run gdal_translate on those in batch. e.g. for %f (*.txt) do gdal_translate --optfile %f on Windows. Although if you're gonna batch create those text files you might as well just run gdal_translate at the same time... – mikewatt Apr 9 at 21:07

Your Answer

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

Browse other questions tagged or ask your own question.