I have aerial imagery as RGB jpgs and I would like to be able to clip them to a specific extent but retain a world file so I can use them in other software. I could do this by splitting them and then clipping and then joining them back together but that is not exactly a smart solution if doing it regularly. I have considered using a custom sized composer but that is a bit rough.

This functionality is supported by by the clipper tool but for some reason the XYZ driver is chosen instead of JPEG or GTIFF - this can be corrected by editing the command manually.


You can clip the aerial imagery using the clipper tool located under Raster -> Extract -> Clipper, as you can see below'

enter image description here

You can draw the required extent on the aerial imagery and the coordinates will be written automatically on the clipper window. You need to add -b 1 -b 2 -b 3 and so on depending on the number of bands. The -b is to select band for output. You can refer to gdal_translate for more information.

Here is the output:

enter image description here


Even with an input RGB in JPEG format, I could clip the image and get an RGB in JPEG format multiband by default without setting multiband -b as you can see below, and without getting XYZ as out format:

enter image description here

Here is the output:

enter image description here

I think there is a problem in somewhere in your settings. I cannot confirm whether the problem resulted from the OSX or not because I am using windows.

  • This works for Multiband imagery? every time I try it I just get a single band raster out. – Sethinacan Feb 8 '17 at 12:01
  • It should do. If not can you give us a link to some sample data to understand why not? – MappaGnosis Feb 8 '17 at 12:14
  • You need to add -b 1 -b 2 -b 3 and so on depending on the number of bands, but first you need to press on the pencil icon to add -b – ahmadhanb Feb 8 '17 at 12:20
  • Even with a tiff as input it still choses the XYZ driver "-of XYZ" If I change that to Gtiff it works fine. If you would change your answer to include to include that .JPG are not supported then it would be correct. I suspect the .XYZ issue is to do with OSX and Kungchaos. Thanks for the trouble shooting – Sethinacan Feb 8 '17 at 13:05
  • I tested on JPEG and I could get also RGB multiband by default. See the updated answer. – ahmadhanb Feb 8 '17 at 13:31

When you clip any data in most GIS systems I know, you end up with a new file and the original data intact. So, there is no need for your proposed split-clip-rejoin process. You will always have the original raster and its world file.

When you clip a raster you can tell QGIS to generate a world file for the new file. To do this edit the command by clicking on the yellow pencil icon in the Clipper tool and add -co "TFW=YES" (assuming it's a tiff) or generate one afterwards using Raster->Projections->Extract Projection.

You can specify individual bands or multiples of them using the -b switch in the command (see documentation). However, the clipper tool should work fine for multi-band images without and produce a multiband image out. If that is not happening for you, then we'll need some sample data to try and see why not.

Note that the output format of your clip must support multiple bands. If it does not (like XYZ) then you can't store an RGB image in that format and should consider using another format.

  • I get this error when using clipper "Warning 6: XYZ driver only uses the first band of the dataset." – Sethinacan Feb 8 '17 at 12:23
  • It's down to your data type. Just change your rasters to GeoTiff and avoid the issue. – MappaGnosis Feb 8 '17 at 12:24
  • XYZ driver is selected regardless - suspect my system is the issue, probably a OSX path problem – Sethinacan Feb 8 '17 at 13:55

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.