I have a bunch of aerial photographs (>70 covering over 10000km2) that are tiled from which I want to build a VRT and ultimately export multiple (~2000) tiny sections (~300m x 300m) distributed around the whole territory using gdal_translate. That should be fairly easy, however I have some tiles that are represented twice (for 2 differents years) where the difference is in the NODATA. Here is a simple example:

Image 1:enter image description here

Image 2:enter image description here

When I build the VRT using:

"C:\Mrnmicro\Applic\gdal\1.11.1\gdalbuildvrt.exe" -srcnodata "0" -overwrite  "C:\Users\ferba1\Desktop\jeter\testvrt\mosai.vrt" "C:\Users\ferba1\Desktop\jeter\testvrt\*.jp2"

I get a nice result:enter image description here

However, if I try to export the two squares using gdal_translate:

C:\Mrnmicro\Applic\gdal\1.11.1\gdal_translate.exe" -projwin 273000 5246300 273300 5246000 -of "GTiff" "C:\Users\ferba1\Desktop\jeter\testvrt\mosai.vrt" "C:\Users\ferba1\Desktop\jeter\testvrt\nord.tif
C:\Mrnmicro\Applic\gdal\1.11.1\gdal_translate.exe" -projwin 278000 5238300 278400 5238000 -of "GTiff" "C:\Users\ferba1\Desktop\jeter\testvrt\mosai.vrt" "C:\Users\ferba1\Desktop\jeter\testvrt\sud.tif

The red square is all nodata while the blue square is ok. Is there a way that gdal_translate on a vrt with no data like that better deal with missing data when I have overlapping images?


After lots of trials, I've found the problem. It wasn't in the vrt creation like I though first. The problem was caused by the .jp2 format from LizardTech which made gdal fail on a third of my images.

I had to convert all my images to geoTiff which is a way better format. I had to use ArcGIS for that because gdal_translate failed on all images which ever driver I used (OpenJPEG or gdal_ECW_JP2ECW).

After the convertion, my initial code work perfectly.

Your Answer

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

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