I have several Landsat 8 Scenes, each consisting of 11 bands. I want to mosaic them by creating a VRT and afterwards exporting the mosaic as TIFF again. I tried using GDAL via Python. But maybe it would be easier using Rasterio.

I tried:

rasterio.vrt.WarpedVRT(src_files_to_mosaic, "/.data/out.vrt", crs = "EPSG:32734")

But I get the error (one of several):

The WKT could not be parsed. OGR Error code 5

I think this should be an easy task, but it takes way to long me to figure out what to do.

  • Hard to help without your data files. Can you narrow it down? Does it fail like that on just two of your files (ie is it just one file with some bad WKT somewhere breaking it)? – Spacedman Jan 19 '20 at 17:01
  • I wish I could tell... But I downloaded all the files from the same source, so I think the wkt should be the same everywhere. – Robin Kohrs Jan 19 '20 at 17:09
  • Reading the docs for rasterio.vrt.WarpedVRT tells me you've misunderstood what it does. It takes a single raster and a CRS returns a raster object that is a virtual warped raster on the new CRS. It doesn't create a mosaiced VRT raster file of the inputs. – Spacedman Jan 19 '20 at 19:22
  • ok great, thanks!! Do you know of any gdal utility, that may handle this task? I mean taking a list of hdf-files and creating a mosaiced vrt. – Robin Kohrs Jan 20 '20 at 10:38

With the builtin GDAL utilities you can first make the VRT with gdalbuildvrt:

gdalbuildvrt mosaic_file.vrt *.tif

And then convert to Tiff and reproject with gdalwarp:

gdalwarp -t_srs EPSG:32734 -of GTiff mosaic_file.vrt output.tif
  • thank you very much! I just tried it. Everything seems to work, but than I open the final tif in qgis and all I see is just an image of noise. Like a SAR-phase-image... Do you think this might have to do with the .hdf-file? Do I need the .hdr which accompanies the .hdf-files? – Robin Kohrs Jan 21 '20 at 16:57
  • @RobinKohrs, not sure about the .hdr files, I haven't worked with those often enough. If your are trying to get TIFFs of landsat 8 scenes, checkout Landsat on AWS. – Ryan Jan 21 '20 at 17:41
  • Thanks for the help! The thing is, that I'm working with a product that unfortunately comes as .hdf and I also never worked with it:/ – Robin Kohrs Jan 21 '20 at 19:51

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.